18034727885
2026-04-27 3a4c1bbb2cf4fb1cdda8a5061b0674f30e7456b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.example.smart.ui.projectevent.widget;
 
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewParent;
 
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
 
/**
 * @author: dai hang
 * @data: 2024/7/2 14:59
 * @description:
 */
public class SlidingConflictRecyclerView extends RecyclerView {
 
    public SlidingConflictRecyclerView(@NonNull Context context) {
        super(context);
    }
 
    public SlidingConflictRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }
 
    public SlidingConflictRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
 
    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        boolean canScrollHorizontally = canScrollHorizontally(-1) || canScrollHorizontally(1);
        boolean canScrollVertically = canScrollVertically(-1) || canScrollVertically(1);
        if (canScrollHorizontally || canScrollVertically) {
            ViewParent parent = getParent();
            if (parent != null) {
                parent.requestDisallowInterceptTouchEvent(true);
            }
        }
        return super.dispatchTouchEvent(event);
    }
 
 
}