修改名称。
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package com.xscm.moduleutil.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class RankRecycleView extends RecyclerView {
|
||||
private float mDownPosX = 0;
|
||||
private float mDownPosY = 0;
|
||||
public RankRecycleView(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public RankRecycleView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public RankRecycleView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
final float x = ev.getX();
|
||||
final float y = ev.getY();
|
||||
|
||||
final int action = ev.getAction();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mDownPosX = x;
|
||||
mDownPosY = y;
|
||||
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
final float deltaX = Math.abs(x - mDownPosX);
|
||||
final float deltaY = Math.abs(y - mDownPosY);
|
||||
//拦截左右滑动
|
||||
if (deltaX > deltaY) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
final float x = ev.getX();
|
||||
final float y = ev.getY();
|
||||
|
||||
final int action = ev.getAction();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mDownPosX = x;
|
||||
mDownPosY = y;
|
||||
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
final float deltaX = Math.abs(x - mDownPosX);
|
||||
final float deltaY = Math.abs(y - mDownPosY);
|
||||
//拦截左右滑动
|
||||
if (deltaX > deltaY) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user