Closed JackL124 closed 5 years ago
@Jessewprf 你好,5.0的崩溃问题,我重写了那几个方法,现在在4.2.2上面正常了,你重新拉下代码试下,compile代码也已经同步了
在NCalendar类中 初始化NestedScrollingParentHelper public NCalendar(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); }
private NestedScrollingParentHelper mParentHelper; private void init() { mParentHelper = new NestedScrollingParentHelper(this); }
然后实现NestedScrollingParent中的下面方法
@Override public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) { if (target instanceof RecyclerView) { return true; } return false; }
@Override
public void onNestedScrollAccepted(View child, View target, int axes) {
mParentHelper.onNestedScrollAccepted(child, target, axes);
}
@Override
public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
}
//返回值:是否消费了fling
@Override
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) {
return false;
}
@Override
public int getNestedScrollAxes() {
return mParentHelper.getNestedScrollAxes();
}
1 如图 Android5.0以下设备触摸滑动recycleview导致抽象方法没有实现崩溃问题 2 添加依赖后代码少了一个非空判断,会导致初始化控件后直接滑动recycleview抛空指针,必须选择除这周之外任意一周滑动recycleview才不会崩溃,而下载的源码已经做了非空处理,不会抛异常