fix #54, show proper apk file thumbnail

This commit is contained in:
tibbi 2017-12-03 23:46:46 +01:00
parent 5bdb75e6d5
commit e48f5e2821

View File

@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager.adapters
import android.content.ClipData import android.content.ClipData
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.Context import android.content.Context
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.view.Menu import android.view.Menu
@ -394,14 +395,27 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
item_icon.setImageDrawable(folderDrawable) item_icon.setImageDrawable(folderDrawable)
item_details.text = getChildrenCnt(fileDirItem) item_details.text = getChildrenCnt(fileDirItem)
} else { } else {
item_details.text = fileDirItem.size.formatSize()
val path = fileDirItem.path
val options = RequestOptions() val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.error(fileDrawable) .error(fileDrawable)
.centerCrop() .centerCrop()
val path = fileDirItem.path val itemToLoad = if (fileDirItem.name.endsWith(".apk", true)) {
Glide.with(activity).load(path).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(item_icon) val packageInfo = context.packageManager.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES)
item_details.text = fileDirItem.size.formatSize() if (packageInfo != null) {
val appInfo = packageInfo.applicationInfo
appInfo.sourceDir = path
appInfo.publicSourceDir = path
appInfo.loadIcon(context.packageManager)
} else {
path
}
} else {
path
}
Glide.with(activity).load(itemToLoad).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(item_icon)
} }
} }
} }