kotlin.TypeCastException: null cannot be cast to non-null type com.kizitonwose.calendarview.ui.MonthViewHolder
See original GitHub issueHi Kizito!
First of all awesome lib! Kudos for it!
At the moment I’m consuming the CalendarView from an Android Java project.
For testing how stable the lib behave under certain scenarios I enabled Don’t keep activities in Developer Options. After playing around, bringing the calendar view back and forth between foreground and background this exception arises:
kotlin.TypeCastException: null cannot be cast to non-null type com.kizitonwose.calendarview.ui.MonthViewHolder at com.kizitonwose.calendarview.ui.CalendarAdapter.notifyMonthScrollListenerIfNeeded(CalendarAdapter.kt:196) at com.kizitonwose.calendarview.ui.CalendarAdapter$onAttachedToRecyclerView$1.run(CalendarAdapter.kt:52) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Any idea how to fix this?
Thanks in advance!
Federico
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
This issue is fixed in the
fix-crash
branch but has not been released yet. You can get the fix using:implementation 'com.github.kizitonwose:CalendarView:7da609173c'
until version0.2.5
is released.hi @kizitonwose
I am still having this issue. I am using this version implementation ‘com.github.kizitonwose:CalendarView:0.3.2’
Fatal Exception: kotlin.TypeCastException: null cannot be cast to non-null type com.kizitonwose.calendarview.ui.DayBinder<com.kizitonwose.calendarview.ui.ViewContainer> at com.kizitonwose.calendarview.ui.CalendarAdapter.onCreateViewHolder(CalendarAdapter.kt:134) at com.kizitonwose.calendarview.ui.CalendarAdapter.onCreateViewHolder(CalendarAdapter.kt:29) at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078) at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114) at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627) at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851) at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1231) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:1067) at android.view.View.layout(View.java:22415) at android.view.ViewGroup.layout(ViewGroup.java:6594) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3427) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2894) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1942) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8595) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:988) at android.view.Choreographer.doCallbacks(Choreographer.java:765) at android.view.Choreographer.doFrame(Choreographer.java:700) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:967) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7156) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)