package com.usai.apex.KPI;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ListView;

public class KPIListView extends ListView {

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

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

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

    @Override
    public boolean onTouchEvent(MotionEvent event) {

         if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
             if (mListener != null) {
                 mListener.KPIListViewTouched(true);
             }
        } else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
             if (mListener != null) {
                 mListener.KPIListViewTouched(false);
             }
        }

        return super.onTouchEvent(event);
    }

    private KPIListViewTouchListener mListener;

    public void setListener(KPIListViewTouchListener listener) {
        this.mListener = mListener;
    }

    public interface KPIListViewTouchListener {
        void KPIListViewTouched(boolean t);
    }
}
