OSDN Git Service

Open drawer only on first update.
authorBen Lin <linben@google.com>
Wed, 13 Apr 2016 18:48:04 +0000 (11:48 -0700)
committerBen Lin <linben@google.com>
Wed, 13 Apr 2016 20:19:55 +0000 (13:19 -0700)
Bug: 27406768
Change-Id: Ib95ecf68be3ba68bf08ccf7311c641e2e934e9c6

packages/DocumentsUI/src/com/android/documentsui/dirlist/FragmentTuner.java

index 016cc9e..e6217b2 100644 (file)
@@ -195,6 +195,10 @@ public abstract class FragmentTuner {
      */
     private static final class FilesTuner extends FragmentTuner {
 
+        // We use this to keep track of whether a model has been previously loaded or not so we can
+        // open the drawer on empty directories on first launch
+        private boolean mModelPreviousLoaded;
+
         public FilesTuner(Context context, State state) {
             super(context, state);
         }
@@ -230,10 +234,12 @@ public abstract class FragmentTuner {
         @Override
         void onModelLoaded(Model model, @ResultType int resultType, boolean isSearch) {
             // When launched into empty root, open drawer.
-            if (model.isEmpty() && !mState.hasInitialLocationChanged() && !isSearch) {
+            if (model.isEmpty() && !mState.hasInitialLocationChanged() && !isSearch
+                    && !mModelPreviousLoaded) {
                 // This noops on layouts without drawer, so no need to guard.
                 ((BaseActivity) mContext).setRootsDrawerOpen(true);
             }
+            mModelPreviousLoaded = true;
         }
 
         @Override