Allow the file chooser to preserve the current path across device orientation changes.
authorXavi Artigas <xartigas@fluendo.com>
Mon, 12 Nov 2012 09:09:56 +0000 (10:09 +0100)
committerXavi Artigas <xartigas@fluendo.com>
Mon, 12 Nov 2012 09:09:56 +0000 (10:09 +0100)
gst-sdk/tutorials/android-tutorial-5/src/com/lamerman/FileDialog.java

index fc56383..e2ef765 100644 (file)
@@ -137,7 +137,12 @@ public class FileDialog extends ListActivity {
 
         });
 
-        String startPath = getIntent().getStringExtra(START_PATH);
+        String startPath;
+        if (savedInstanceState != null) {
+            startPath = savedInstanceState.getString("currentPath");
+        } else {
+            startPath = getIntent().getStringExtra(START_PATH);
+        }
         startPath = startPath != null ? startPath : ROOT;
         getDir(startPath);
 
@@ -320,4 +325,10 @@ public class FileDialog extends ListActivity {
         }
     }
 
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        outState.putString("currentPath", currentPath);
+        super.onSaveInstanceState(outState);
+    }
+
 }