reuse the same list of media at thumbnails and fullscreen view

This commit is contained in:
tibbi 2017-05-31 23:36:43 +02:00
parent d2713635d5
commit 6248f0db76
2 changed files with 9 additions and 4 deletions

View file

@ -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()

View file

@ -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<Medium>()
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) {}