From 6248f0db76d4d73af9ffe0211749387e6d78d0b5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 31 May 2017 23:36:43 +0200 Subject: [PATCH] reuse the same list of media at thumbnails and fullscreen view --- .../simplemobiletools/gallery/activities/MediaActivity.kt | 7 ++++++- .../gallery/activities/ViewPagerActivity.kt | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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) {}