yannecer / NCalendar

一款安卓日历,仿miui,钉钉,华为的日历,万年历、365、周日历,月日历,月视图、周视图滑动切换,农历,节气,Andriod Calendar , MIUI Calendar,小米日历
Apache License 2.0
1.59k stars 314 forks source link

android 5.0以下设备依旧滑动崩溃问题,以及 下载最新源码里代码和添加依赖中.class文件中代码有不一致问题 #2

Closed JackL124 closed 5 years ago

JackL124 commented 7 years ago

3bgy1 t1 rbashfj3 tcq4

1 如图 Android5.0以下设备触摸滑动recycleview导致抽象方法没有实现崩溃问题 2 添加依赖后代码少了一个非空判断,会导致初始化控件后直接滑动recycleview抛空指针,必须选择除这周之外任意一周滑动recycleview才不会崩溃,而下载的源码已经做了非空处理,不会抛异常

yannecer commented 7 years ago

@Jessewprf 你好,5.0的崩溃问题,我重写了那几个方法,现在在4.2.2上面正常了,你重新拉下代码试下,compile代码也已经同步了

shipan commented 5 years ago

在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();
}