package com.sheep.gamegroup.util;

import android.os.CountDownTimer;

/**
 * Created by ljy on 2018/3/15.
 */

public abstract class SelfCountDownTimer extends CountDownTimer{
    public static final int FULL_SECOND = 60;
    private int countTime;
    /**
     * @param millisInFuture    The number of millis in the future from the call
     *                          to {@link #start()} until the countdown is done and {@link #onFinish()}
     *                          is called.
     * @param countDownInterval The interval along the way to receive
     *                          {@link #onTick(long)} callbacks.
     */
    public SelfCountDownTimer(long millisInFuture, long countDownInterval, int full_second) {
        super(millisInFuture, countDownInterval);
        countTime = full_second;
    }

    public void reset(int full_second){
        this.cancel();
        countTime = full_second;
        onTimerRest();
    }

    @Override
    public void onTick(long millisUntilFinished) {
        countTime--;
        onTimerTick(millisUntilFinished, countTime);
    }

    @Override
    public void onFinish() {
        onTimerFinish();
    }

    public abstract void onTimerRest();
    public abstract void onTimerTick(long millisUntilFinished, int counTime);
    public abstract void onTimerFinish();
}
