package com.casic.dcms.base;

import android.view.KeyEvent;

import com.casic.dcms.utils.ToastHelper;

public abstract class DoubleClickExitActivity extends BaseActivity {

    private long clickTime = 0;

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (System.currentTimeMillis() - clickTime > 2000) {
                ToastHelper.showToast("再按一次退出程序", ToastHelper.DEFAULT);
                clickTime = System.currentTimeMillis();
                return true;
            } else {
                return super.onKeyDown(keyCode, event);
            }
        }
        return super.onKeyDown(keyCode, event);
    }
}
