Skip to content

Commit

Permalink
Fix crash due to StateListAnimator.clone missing on some devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 committed Oct 28, 2020
1 parent 49b34eb commit c7462a1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,13 @@ class PreferencesAdapter @VisibleForTesting constructor(
else -> R.layout.map_preference
}
val view = layoutInflater.inflate(layout, parent, false)
view.stateListAnimator = stateListAnimator?.clone()
view.stateListAnimator = try {
stateListAnimator?.clone()
} catch (e: NoSuchMethodError) {
// Some awful Android 5 devices apparently don't implement the clone method,
// although it's part of the Android SDK since API 21. Thus, we catch it and return null instead.
null
}
if (viewType > 0)
layoutInflater.inflate(viewType, view.findViewById(R.id.map_widget_frame), true)
return ViewHolder(view)
Expand Down

0 comments on commit c7462a1

Please sign in to comment.