From e206fa92caee3088d476bb1b9623d4b44a489cf6 Mon Sep 17 00:00:00 2001
From: tibbi <tibor@kaputa.sk>
Date: Sun, 5 Jun 2016 23:54:01 +0200
Subject: [PATCH] save the directory activities scroll state too

---
 .../simplemobiletools/gallery/activities/MainActivity.java  | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java
index 0ba06ed2a..9f7e27bc9 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java
@@ -9,6 +9,7 @@ import android.graphics.Color;
 import android.media.MediaScannerConnection;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Parcelable;
 import android.provider.MediaStore;
 import android.support.design.widget.CoordinatorLayout;
 import android.support.design.widget.Snackbar;
@@ -55,6 +56,7 @@ public class MainActivity extends AppCompatActivity
     private boolean isSnackbarShown;
     private List<String> toBeDeleted;
     private ActionMode actionMode;
+    private Parcelable state;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -86,12 +88,16 @@ public class MainActivity extends AppCompatActivity
     protected void onResume() {
         super.onResume();
         tryloadGallery();
+        if (state != null && gridView != null)
+            gridView.onRestoreInstanceState(state);
     }
 
     @Override
     protected void onPause() {
         super.onPause();
         deleteDirs();
+        if (gridView != null)
+            state = gridView.onSaveInstanceState();
     }
 
     private void tryloadGallery() {