[Android] Fix IllegalStateException on BottomNavigationBehavior saving state

Nicolas Pomepuy git at videolan.org
Fri Jun 12 14:09:06 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jun 12 07:12:28 2020 +0200| [721ed9b1d22bc77a765c692368d70b6a50b68a3e] | committer: Nicolas Pomepuy

Fix IllegalStateException on BottomNavigationBehavior saving state

> https://code.videolan.org/videolan/vlc-android/commit/721ed9b1d22bc77a765c692368d70b6a50b68a3e
---

 .../src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt
index af6327612..5902dbd93 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/BottomNavigationBehavior.kt
@@ -62,11 +62,14 @@ class BottomNavigationBehavior<V : View>(context: Context, attrs: AttributeSet)
     private var forceTranslation: Float = -1F
 
     override fun onSaveInstanceState(parent: CoordinatorLayout, child: V): Parcelable? {
-        return BottomNavigationBehaviorState(super.onSaveInstanceState(parent, child), child.translationY)
+        val superState = super.onSaveInstanceState(parent, child)
+        superState?.let {
+            return BottomNavigationBehaviorState(superState, child.translationY)
+        }
+        return superState
     }
 
     override fun onRestoreInstanceState(parent: CoordinatorLayout, child: V, state: Parcelable) {
-
         val ss = state as BottomNavigationBehaviorState
         super.onRestoreInstanceState(parent, child, ss.superState!!)
         this.forceTranslation = ss.translation



More information about the Android mailing list