[Android] src: Save directory view status too

Edward Wang git at videolan.org
Sat Jun 23 06:13:20 CEST 2012


android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Fri Jun 22 23:53:23 2012 -0400| [5dd3d23df3a47092013639bfba8ea8a6aa914670] | committer: Edward Wang

src: Save directory view status too

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=5dd3d23df3a47092013639bfba8ea8a6aa914670
---

 vlc-android/src/org/videolan/vlc/gui/MainActivity.java |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 9698ed1..72b1f9c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -117,11 +117,12 @@ public class MainActivity extends SherlockFragmentActivity {
         mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
         mActionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
 
-        int tabToShow = getSharedPreferences("MainActivity", MODE_PRIVATE).getInt("tab", 0);
+        SharedPreferences sharedPrefs = getSharedPreferences("MainActivity", MODE_PRIVATE);
+        int tabToShow = sharedPrefs.getInt("tab", VIDEO_TAB);
+        Boolean isMediaLib = sharedPrefs.getBoolean("medialibrary", true);
 
         addMediaLibraryTabs(tabToShow);
         mCurrentViewTab = tabToShow;
-        mMediaLibraryActive = true;
         mDirectoryView = new DirectoryViewFragment(this);
         mDirectoryView.setRetainInstance(true); /* Retain instance across attach/detach */
         getSupportFragmentManager().beginTransaction()
@@ -130,6 +131,11 @@ public class MainActivity extends SherlockFragmentActivity {
         getSupportFragmentManager().beginTransaction()
             .detach(mDirectoryView)
             .commit();
+        mMediaLibraryActive = true;
+
+        /* Restore directory view if it was active last */
+        if(!isMediaLib)
+            showDirectoryView();
 
         // Add mini audio player
         mAudioPlayer = (AudioMiniPlayer) findViewById(R.id.audio_mini_player);
@@ -196,7 +202,8 @@ public class MainActivity extends SherlockFragmentActivity {
     @Override
     protected void onPause() {
         SharedPreferences.Editor editor = getSharedPreferences("MainActivity", MODE_PRIVATE).edit();
-        editor.putInt("tab", mActionBar.getSelectedNavigationIndex());
+        editor.putInt("tab", mCurrentViewTab);
+        editor.putBoolean("medialibrary", mMediaLibraryActive);
         editor.commit();
         mAudioController.removeAudioPlayer(mAudioPlayer);
         super.onPause();



More information about the Android mailing list