[Android] src: Fix the save currently loaded view functionality

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:40:54 2012 -0400| [987c8314510669e0c6935ed127cfeeea9ade070e] | committer: Edward Wang

src: Fix the save currently loaded view functionality

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

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

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index c0363f1..9698ed1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -117,10 +117,7 @@ public class MainActivity extends SherlockFragmentActivity {
         mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
         mActionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
 
-        int tabToShow = 0;
-        if (savedInstanceState != null) {
-            tabToShow = savedInstanceState.getInt("tab", 0);
-        }
+        int tabToShow = getSharedPreferences("MainActivity", MODE_PRIVATE).getInt("tab", 0);
 
         addMediaLibraryTabs(tabToShow);
         mCurrentViewTab = tabToShow;
@@ -144,13 +141,6 @@ public class MainActivity extends SherlockFragmentActivity {
         if (getIntent().hasExtra(START_FROM_NOTIFICATION)) {
             Log.d(TAG, "Started from notification.");
             showAudioTab();
-        } else {
-            // load the last tab-state (TODO: Broken)
-            int state = savedInstanceState == null ? VIDEO_TAB : savedInstanceState.getInt("mCurrentState");
-            if(state == VIDEO_TAB)
-                showVideoTab();
-            else
-                showAudioTab();
         }
 
         /* Show info/alpha/beta Warning */
@@ -200,8 +190,14 @@ public class MainActivity extends SherlockFragmentActivity {
         super.onResume();
     }
 
+    /**
+     * Stop audio player and save opened tab
+     */
     @Override
     protected void onPause() {
+        SharedPreferences.Editor editor = getSharedPreferences("MainActivity", MODE_PRIVATE).edit();
+        editor.putInt("tab", mActionBar.getSelectedNavigationIndex());
+        editor.commit();
         mAudioController.removeAudioPlayer(mAudioPlayer);
         super.onPause();
     }
@@ -229,15 +225,6 @@ public class MainActivity extends SherlockFragmentActivity {
     }
 
     /**
-     * Save currently opened tab (video/audio) for above
-     */
-    @Override
-    public void onSaveInstanceState(Bundle savedInstanceState) {
-        super.onSaveInstanceState(savedInstanceState);
-        savedInstanceState.putInt("tab", mActionBar.getSelectedNavigationIndex());
-    }
-
-    /**
      * Handle onClick form menu buttons
      */
     @Override



More information about the Android mailing list