package com.kfzs.libs.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by realicing on 2018/4/10.
 * realicing@sina.com
 */
public class TimeEditText extends CompleteCommitEditText{


    public TimeEditText(Context context) {
        super(context);
    }

    public TimeEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public TimeEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private long totalFocusTime;
    private long startTime;
    @Override
    public void onFocusChange(View view, boolean b) {
        super.onFocusChange(view, b);
        if(b){
            startTime = System.currentTimeMillis();
        } else {
            if(startTime != 0){
                totalFocusTime += (System.currentTimeMillis() - startTime);
            }
        }
    }

    public long getTotalFocusTime() {
        return totalFocusTime;
    }
}
