package com.kfzs.duanduan.view;

import android.os.CountDownTimer;

/**
 * <pre>
 *     sinlov
 *
 *     /\__/\
 *    /`    '\
 *  ≈≈≈ 0  0 ≈≈≈ Hello world!
 *    \  --  /
 *   /        \
 *  /          \
 * |            |
 *  \  ||  ||  /
 *   \_oo__oo_/≡≡≡≡≡≡≡≡o
 *
 * </pre>
 * Created by sinlov on 17/3/1.
 */
public abstract class OneMinuteCountDownTimer extends CountDownTimer {
    private static final int FULL_SECOND = 60;
    private int countTime = FULL_SECOND;

    public OneMinuteCountDownTimer() {
        super(FULL_SECOND * 1000, 1000);
    }

    public void reset() {
        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 countTime);

    public abstract void onTimerFinish();
}
