Prevent crash if WidgetsAdapter is not ready when configuration changes
This commit is contained in:
parent
65ace16fbf
commit
28e0f2d59f
|
@ -55,8 +55,12 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||
binding.widgetsList.scrollToPosition(0)
|
||||
setupViews()
|
||||
|
||||
val appWidgets = (binding.widgetsList.adapter as WidgetsAdapter).widgetListItems
|
||||
val appWidgets = (binding.widgetsList.adapter as? WidgetsAdapter)?.widgetListItems
|
||||
if (appWidgets != null) {
|
||||
setupAdapter(appWidgets)
|
||||
} else {
|
||||
getAppWidgets()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
||||
|
|
Loading…
Reference in New Issue