mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
properly display OTG file thumbnails
This commit is contained in:
parent
55fa9a04d5
commit
771e59b5cf
3 changed files with 15 additions and 8 deletions
|
@ -46,7 +46,7 @@ ext {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.12.11'
|
implementation 'com.simplemobiletools:commons:3.12.12'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
|
||||||
implementation 'com.android.support:multidex:1.0.2'
|
implementation 'com.android.support:multidex:1.0.2'
|
||||||
implementation 'com.google.code.gson:gson:2.8.2'
|
implementation 'com.google.code.gson:gson:2.8.2'
|
||||||
|
|
|
@ -10,10 +10,7 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
|
||||||
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
|
||||||
import com.simplemobiletools.commons.extensions.isActivityDestroyed
|
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.commons.views.FastScroller
|
import com.simplemobiletools.commons.views.FastScroller
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
|
@ -38,6 +35,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
||||||
private var loadImageInstantly = false
|
private var loadImageInstantly = false
|
||||||
private var delayHandler = Handler(Looper.getMainLooper())
|
private var delayHandler = Handler(Looper.getMainLooper())
|
||||||
private var currentMediaHash = media.hashCode()
|
private var currentMediaHash = media.hashCode()
|
||||||
|
private val hasOTGConnected = activity.hasOTGConnected()
|
||||||
|
|
||||||
private var scrollHorizontally = config.scrollHorizontally
|
private var scrollHorizontally = config.scrollHorizontally
|
||||||
private var animateGifs = config.animateGifs
|
private var animateGifs = config.animateGifs
|
||||||
|
@ -290,15 +288,20 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
||||||
photo_name.text = medium.name
|
photo_name.text = medium.name
|
||||||
photo_name.tag = medium.path
|
photo_name.tag = medium.path
|
||||||
|
|
||||||
|
var thumbnailPath = medium.path
|
||||||
|
if (hasOTGConnected && activity.isPathOnOTG(thumbnailPath)) {
|
||||||
|
thumbnailPath = thumbnailPath.getOTGPublicPath(context)
|
||||||
|
}
|
||||||
|
|
||||||
if (loadImageInstantly) {
|
if (loadImageInstantly) {
|
||||||
activity.loadImage(medium.type, medium.path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
activity.loadImage(medium.type, thumbnailPath, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
||||||
} else {
|
} else {
|
||||||
medium_thumbnail.setImageDrawable(null)
|
medium_thumbnail.setImageDrawable(null)
|
||||||
medium_thumbnail.isHorizontalScrolling = scrollHorizontally
|
medium_thumbnail.isHorizontalScrolling = scrollHorizontally
|
||||||
delayHandler.postDelayed({
|
delayHandler.postDelayed({
|
||||||
val isVisible = visibleItemPaths.contains(medium.path)
|
val isVisible = visibleItemPaths.contains(medium.path)
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
activity.loadImage(medium.type, medium.path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
activity.loadImage(medium.type, thumbnailPath, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
||||||
}
|
}
|
||||||
}, IMAGE_LOAD_DELAY)
|
}, IMAGE_LOAD_DELAY)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,12 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
val lastItem = curMedia.last()
|
val lastItem = curMedia.last()
|
||||||
val parentDir = if (hasOTG && context.isPathOnOTG(firstItem.path)) firstItem.path.getParentPath() else File(firstItem.path).parent
|
val parentDir = if (hasOTG && context.isPathOnOTG(firstItem.path)) firstItem.path.getParentPath() else File(firstItem.path).parent
|
||||||
var thumbnail = firstItem.path
|
var thumbnail = firstItem.path
|
||||||
|
if (thumbnail.startsWith(OTG_PATH)) {
|
||||||
|
thumbnail = thumbnail.getOTGPublicPath(context)
|
||||||
|
}
|
||||||
|
|
||||||
albumCovers.forEach {
|
albumCovers.forEach {
|
||||||
if (it.path == parentDir && File(it.tmb).exists()) {
|
if (it.path == parentDir && context.getDoesFilePathExist(it.tmb)) {
|
||||||
thumbnail = it.tmb
|
thumbnail = it.tmb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue