properly show photo thumbnail at OTG files

This commit is contained in:
tibbi 2018-02-21 21:49:13 +01:00
parent 0467112cc7
commit 5d3466b565
2 changed files with 10 additions and 3 deletions

View file

@ -45,7 +45,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.12.17'
implementation 'com.simplemobiletools:commons:3.12.18'
implementation files('../libs/RootTools.jar')

View file

@ -46,6 +46,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
private lateinit var folderDrawable: Drawable
private lateinit var fileDrawable: Drawable
private var currentItemsHash = fileDirItems.hashCode()
private val hasOTGConnected = activity.hasOTGConnected()
init {
initDrawables()
@ -484,7 +485,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
.error(fileDrawable)
.centerCrop()
val itemToLoad = if (fileDirItem.name.endsWith(".apk", true)) {
var itemToLoad = if (fileDirItem.name.endsWith(".apk", true)) {
val packageInfo = context.packageManager.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES)
if (packageInfo != null) {
val appInfo = packageInfo.applicationInfo
@ -497,10 +498,16 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
} else {
path
}
if (!activity.isActivityDestroyed()) {
if (hasOTGConnected && itemToLoad is String && itemToLoad.startsWith(OTG_PATH)) {
itemToLoad = itemToLoad.getOTGPublicPath(activity)
}
Glide.with(activity).load(itemToLoad).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(item_icon)
}
}
}
}
private fun getChildrenCnt(item: FileDirItem): String {
val children = item.children