diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 8e9d307c3..3892816ff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -46,6 +46,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private var mLoadedInitialPhotos = false private var mStoredAnimateGifs = true private var mStoredCropThumbnails = true + private var mLastDrawnHashCode = 0 private var mLastMediaModified = 0 private var mLastMediaHandler = Handler() @@ -393,9 +394,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { media_refresh_layout.isRefreshing = false checkLastMediaChanged() - if (media.hashCode() == mMedia.hashCode()) + if (mLastDrawnHashCode == 0) + mLastDrawnHashCode = media.hashCode() + + if (media.hashCode() == mMedia.hashCode() && media.hashCode() == mLastDrawnHashCode) return + mLastDrawnHashCode = media.hashCode() mMedia = media setupAdapter() storeFolder() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 652ac5b8d..95024233f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -27,6 +27,7 @@ import com.simplemobiletools.commons.dialogs.PropertiesDialog import com.simplemobiletools.commons.dialogs.RenameItemDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.activities.MediaActivity.Companion.mMedia import com.simplemobiletools.gallery.adapters.MyPagerAdapter import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask import com.simplemobiletools.gallery.dialogs.SaveAsDialog @@ -42,7 +43,6 @@ import java.util.* class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener { lateinit var mOrientationEventListener: OrientationEventListener - private var mMedia = ArrayList() private var mPath = "" private var mDirectory = "" @@ -98,8 +98,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View mDirectory = File(mPath).parent title = mPath.getFilenameFromPath() - if (MediaActivity.mMedia.isNotEmpty()) - gotMedia(MediaActivity.mMedia) + if (mMedia.isNotEmpty()) + gotMedia(mMedia) reloadViewPager() scanPath(mPath) {}