package com.gh.gamecenter.common.view;

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

import androidx.recyclerview.widget.RecyclerView;

/**
 * Created by LGT on 2016/10/11.
 */
public class RecyclerViewExtended extends RecyclerView {

    private OnDispatchTouchListener mListener;

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

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

    public RecyclerViewExtended(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (mListener != null) {
            mListener.onDispatch(this, ev);
        }
        return super.dispatchTouchEvent(ev);
    }

    public void setOnDispatchTouchListener(OnDispatchTouchListener listener) {
        mListener = listener;
    }

    public interface OnDispatchTouchListener {
        void onDispatch(View v, MotionEvent event);
    }

}
