mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
Remove unnecessary call to getCachedMedia
This commit is contained in:
parent
46533e4b45
commit
ccb9b60a12
1 changed files with 16 additions and 22 deletions
|
@ -59,6 +59,7 @@ import kotlinx.android.synthetic.main.bottom_actions.*
|
|||
import java.io.File
|
||||
import java.io.OutputStream
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener {
|
||||
private val REQUEST_VIEW_VIDEO = 1
|
||||
|
||||
|
@ -133,24 +134,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
window.attributes = attributes
|
||||
}
|
||||
|
||||
// show the selected image asap, while loading the rest in the background to allow swiping between them. Needed at third party intents
|
||||
if (mMediaFiles.isEmpty() && mPath.isNotEmpty() && mDirectory != FAVORITES) {
|
||||
getCachedMedia(mPath.getParentPath(), false, false) { thumbnailItems ->
|
||||
// if we have nothing cached from the given folder, at least show the selected image asap
|
||||
if (thumbnailItems.isEmpty()) {
|
||||
val filename = mPath.getFilenameFromPath()
|
||||
val folder = mPath.getParentPath()
|
||||
val type = getTypeFromPath(mPath)
|
||||
val medium = Medium(null, filename, mPath, folder, 0, 0, 0, type, 0, false, 0L, 0L)
|
||||
thumbnailItems.add(medium)
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
gotMedia(thumbnailItems)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setupOrientation()
|
||||
invalidateOptionsMenu()
|
||||
|
||||
|
@ -388,7 +371,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
}
|
||||
|
||||
refreshViewPager()
|
||||
// show the selected image asap, while loading the rest in the background to allow swiping between them. Might be needed at third party intents
|
||||
if (mMediaFiles.isEmpty() && mPath.isNotEmpty() && mDirectory != FAVORITES) {
|
||||
val filename = mPath.getFilenameFromPath()
|
||||
val folder = mPath.getParentPath()
|
||||
val type = getTypeFromPath(mPath)
|
||||
val medium = Medium(null, filename, mPath, folder, 0, 0, 0, type, 0, false, 0L, 0L)
|
||||
mMediaFiles.add(medium)
|
||||
gotMedia(mMediaFiles as ArrayList<ThumbnailItem>, refetchViewPagerPosition = true)
|
||||
}
|
||||
|
||||
refreshViewPager(true)
|
||||
view_pager.offscreenPageLimit = 2
|
||||
|
||||
if (config.blackBackground) {
|
||||
|
@ -1233,10 +1226,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
}
|
||||
|
||||
private fun refreshViewPager() {
|
||||
private fun refreshViewPager(refetchPosition: Boolean = false) {
|
||||
if (config.getFolderSorting(mDirectory) and SORT_BY_RANDOM == 0) {
|
||||
GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
|
||||
gotMedia(it)
|
||||
GetMediaAsynctask(applicationContext, mDirectory, isPickImage = false, isPickVideo = false, showAll = mShowAll) {
|
||||
gotMedia(it, refetchViewPagerPosition = refetchPosition)
|
||||
}.execute()
|
||||
}
|
||||
}
|
||||
|
@ -1270,6 +1263,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
updateActionbarTitle()
|
||||
updatePagerItems(mMediaFiles.toMutableList())
|
||||
|
||||
invalidateOptionsMenu()
|
||||
checkOrientation()
|
||||
initBottomActions()
|
||||
|
|
Loading…
Reference in a new issue