package com.tofly.ghrq_route.common.ui.view;

/**
 * Created by Amu on 2017/5/22.
 */

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.viewpager.widget.ViewPager;

/**
 * ViewPager 不支持wrapContent自适应高度的解决方案
 */
public class BigImageViewPager extends ViewPager implements BigImageView.OnMovingListener {

    private boolean mbIsChildDrag = false;

    /**
     * Constructor
     *
     * @param context the context
     */
    public BigImageViewPager(Context context) {
        super(context);
    }

    /**
     * Constructor
     *
     * @param context the context
     * @param attrs the attribute set
     */
    public BigImageViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {
        if(mbIsChildDrag)
            return false;
        return super.onInterceptTouchEvent(arg0);
    }

    @Override
    public void startDrag() {
        // TODO Auto-generated method stub
        mbIsChildDrag = true;
    }


    @Override
    public void stopDrag() {
        // TODO Auto-generated method stub
        mbIsChildDrag = false;
    }

}
