package com.zhaohaoting.framework.view.indicator.viewpager;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;

/**
 * author：Created by zhaohaoting on 2018/8/1
 * email：526309416@qq.com
 * desc：第一张不能左划 最后一张不能右划
 */
public class EventViewPager extends ViewPager {

    private float downX;
    private float moveX;
    private float distance = 12f;

    public EventViewPager(@NonNull Context context) {
        super(context);
    }

    public EventViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

//    @Override
//    public boolean dispatchTouchEvent(MotionEvent ev) {
//        switch (ev.getAction()) {
//            case MotionEvent.ACTION_DOWN:
//                downX = ev.getX();
//                break;
//            case MotionEvent.ACTION_MOVE:
//                moveX = ev.getX();
//                if ((getCurrentItem() == 0 && moveX - downX > distance) || getAdapter().getCount() <= 0 || (getCurrentItem() == getAdapter().getCount() - 1 && downX - moveX > distance)) {
//                    requestDisallowInterceptTouchEvent(false);
//                }
//                break;
//        }
//        return super.dispatchTouchEvent(ev);
//    }
}
