Commits

Bastien Léonard committed 251a86a

Added state save/restoration in MediaFilesActivity

Comments (0)

Files changed (1)

src/net/alwaysdata/bastien_leonard/media_hider/MediaFilesActivity.java

     public void onCreate(Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
-        loadImages = true;
-        loadAudio = true;
-        loadVideo = true;
+
+        if (savedInstanceState == null)
+        {
+            loadImages = true;
+            loadAudio = true;
+            loadVideo = true;
+        }
+        else
+        {
+            loadImages = savedInstanceState.getBoolean("loadImages");
+            loadAudio = savedInstanceState.getBoolean("loadAudio");
+            loadVideo = savedInstanceState.getBoolean("loadVideo");
+        }
+
         loadMediaDirs();
         SimpleAdapter adapter = new SimpleAdapter(
             this, data, android.R.layout.simple_list_item_2,
     }
 
     @Override
+    public void onSaveInstanceState(Bundle outState)
+    {
+        super.onSaveInstanceState(outState);
+        outState.putBoolean("loadImages", loadImages);
+        outState.putBoolean("loadAudio", loadAudio);
+        outState.putBoolean("loadVideo", loadVideo);
+    }
+
+
+    @Override
     public boolean onCreateOptionsMenu(Menu menu)
     {
         MenuInflater inflater = getMenuInflater();
         labels[IMAGES] = "Images";
         labels[AUDIO] = "Audio";
         labels[VIDEO] = "Video";
+        boolean[] values = new boolean[3];
+        values[IMAGES] = loadImages;
+        values[AUDIO] = loadAudio;
+        values[VIDEO] = loadVideo;
 
         switch (id)
         {
             AlertDialog.Builder builder = new AlertDialog.Builder(this);
             builder.setMultiChoiceItems(
                 labels,
-                new boolean[] {true, true, true},
+                values,
                 new DialogInterface.OnMultiChoiceClickListener()
                 {
                     public void onClick(DialogInterface dialog, int which,