mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-17 22:08:00 +01:00
reuse the list of media files of thumbnail view at the fullscreen view
This commit is contained in:
parent
28a2f59514
commit
5758b2eee1
2 changed files with 30 additions and 18 deletions
|
@ -37,8 +37,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
private val SAVE_MEDIA_CNT = 40
|
||||
private val LAST_MEDIA_CHECK_PERIOD = 3000L
|
||||
|
||||
private var mMedia = ArrayList<Medium>()
|
||||
|
||||
private var mPath = ""
|
||||
private var mIsGetImageIntent = false
|
||||
private var mIsGetVideoIntent = false
|
||||
|
@ -51,6 +49,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
private var mLastMediaModified = 0
|
||||
private var mLastMediaHandler = Handler()
|
||||
|
||||
companion object {
|
||||
var mMedia = ArrayList<Medium>()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_media)
|
||||
|
@ -95,6 +97,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
config.temporarilyShowHidden = false
|
||||
mMedia.clear()
|
||||
}
|
||||
|
||||
private fun tryloadGallery() {
|
||||
|
|
|
@ -97,6 +97,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
mDirectory = File(mPath).parent
|
||||
title = mPath.getFilenameFromPath()
|
||||
|
||||
if (MediaActivity.mMedia.isNotEmpty())
|
||||
gotMedia(MediaActivity.mMedia)
|
||||
|
||||
reloadViewPager()
|
||||
scanPath(mPath) {}
|
||||
setupOrientationEventListener()
|
||||
|
@ -379,8 +383,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
}
|
||||
|
||||
private fun isDirEmpty(): Boolean {
|
||||
return if (mMedia.size <= 0) {
|
||||
private fun isDirEmpty(media: ArrayList<Medium>): Boolean {
|
||||
return if (media.isEmpty()) {
|
||||
deleteDirectoryIfEmpty()
|
||||
finish()
|
||||
true
|
||||
|
@ -415,10 +419,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
private fun reloadViewPager() {
|
||||
GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
|
||||
mMedia = it
|
||||
if (isDirEmpty())
|
||||
return@GetMediaAsynctask
|
||||
gotMedia(it)
|
||||
}.execute()
|
||||
}
|
||||
|
||||
private fun gotMedia(media: ArrayList<Medium>) {
|
||||
if (isDirEmpty(media) || mMedia.hashCode() == media.hashCode()) {
|
||||
return
|
||||
}
|
||||
|
||||
mMedia = media
|
||||
if (mPos == -1) {
|
||||
mPos = getProperPosition()
|
||||
} else {
|
||||
|
@ -429,7 +439,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
updatePagerItems()
|
||||
invalidateOptionsMenu()
|
||||
checkOrientation()
|
||||
}.execute()
|
||||
}
|
||||
|
||||
private fun getProperPosition(): Int {
|
||||
|
|
Loading…
Reference in a new issue