package com.kfzs.android.view;

import android.content.Context;
import android.graphics.PointF;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by HooRang on 2017/2/27.
 */
public class KFViewPager extends ViewPager {

    float preX = 0;
    public KFViewPager(Context context) {
        super(context);
    }

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


    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        boolean res = super.onInterceptTouchEvent(event);
        if(event.getAction() == MotionEvent.ACTION_DOWN) {
            preX = event.getX();
        } else {
            if( Math.abs(event.getX() - preX)> 4 ) {
                return true;
            } else {
                preX = event.getX();
            }
        }
        return res;

    }


//    /**
//     * 单击
//     */
//    public void onSingleTouch() {
//        if (onSingleTouchListener!= null) {
//
//            onSingleTouchListener.onSingleTouch();
//        }
//    }
//
//    /**
//     * 创建点击事件接口
//     * @author wanpg
//     *
//     */
//    public interface OnSingleTouchListener {
//        public void onSingleTouch();
//    }
//
//    public void setOnSingleTouchListener(OnSingleTouchListener onSingleTouchListener) {
//        this.onSingleTouchListener = onSingleTouchListener;
//    }

}
