[Android] Init variables before instances

Geoffrey Métais git at videolan.org
Wed Apr 4 18:35:42 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 21 12:08:15 2018 +0100| [8acecd08d706a2d94242c582222f5b1ec323e6bf] | committer: Geoffrey Métais

Init variables before instances

> https://code.videolan.org/videolan/vlc-android/commit/8acecd08d706a2d94242c582222f5b1ec323e6bf
---

 vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
index 030ed380f..b495a454c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
@@ -56,22 +56,22 @@ class Navigator(private val activity: MainActivity,
         state: Bundle?
 ): NavigationView.OnNavigationItemSelectedListener, LifecycleObserver {
 
+    private val fragmentsStack = SimpleArrayMap<String, WeakReference<Fragment>>()
+    var currentFragmentId = 0
+    var currentFragment: Fragment? = null
+        private set
+
     init {
         activity.lifecycle.addObserver(this)
         state?.let {
             val fm = activity.supportFragmentManager
             currentFragment = fm.getFragment(it, "current_fragment")
+            currentFragmentId = it.getInt("current", settings.getInt("fragment_id", R.id.nav_video))
             //Restore fragments stack
             restoreFragmentsStack(fm)
-            currentFragmentId = it.getInt("current", settings.getInt("fragment_id", R.id.nav_video))
         }
     }
 
-    var currentFragmentId = 0
-    var currentFragment: Fragment? = null
-    private set
-    private val fragmentsStack = SimpleArrayMap<String, WeakReference<Fragment>>()
-
     private fun getNewFragment(id: Int): Fragment {
         return when (id) {
             R.id.nav_audio -> AudioBrowserFragment()



More information about the Android mailing list