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