[Android] Refactor initial fragment loading

Geoffrey Métais git at videolan.org
Wed Aug 23 18:17:42 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Aug 23 17:51:41 2017 +0200| [023accc34dbf172429a6565d2dae4059f0f1d235] | committer: Geoffrey Métais

Refactor initial fragment loading

> https://code.videolan.org/videolan/vlc-android/commit/023accc34dbf172429a6565d2dae4059f0f1d235
---

 .../src/org/videolan/vlc/gui/MainActivity.java       | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index d5b7a0049..41d9f1c5e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -142,15 +142,9 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
                             fm.beginTransaction().hide(fragment).commit();
                         }
                     }
-            mCurrentFragmentId = savedInstanceState.getInt("current", R.id.nav_video);
-            if (!currentIdIsExtension()) {
-                String tag = getTag(mCurrentFragmentId);
-                if (mFragmentsStack.containsKey(tag))
-                    mCurrentFragment = mFragmentsStack.get(tag).get();
-            }
-        } else {
+            mCurrentFragmentId = savedInstanceState.getInt("current", mSettings.getInt("fragment_id", R.id.nav_video));
+        } else
             reloadPreferences();
-        }
 
         /* Set up the action bar */
         prepareActionBar();
@@ -251,7 +245,8 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
     @Override
     protected void onStart() {
         super.onStart();
-        mCurrentFragmentId = mSettings.getInt("fragment_id", R.id.nav_video);
+        if (mCurrentFragment == null && !currentIdIsExtension())
+            showFragment(mCurrentFragmentId);
         if (mMediaLibrary.isInitiated()) {
             /* Load media items from database and storage */
             if (mScanNeeded && Permissions.canReadStorage())
@@ -334,13 +329,6 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
             mExtensionServiceConnection = null;
     }
 
-    @Override
-    protected void onResumeFragments() {
-        super.onResumeFragments();
-        if (mCurrentFragment == null && !currentIdIsExtension())
-            showFragment(mCurrentFragmentId);
-    }
-
     protected void onSaveInstanceState(Bundle outState) {
         if (mCurrentFragment instanceof ExtensionBrowser)
             mCurrentFragment = null;



More information about the Android mailing list