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