mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-11 09:20:51 +01:00
handle gif and video thumbnails too
This commit is contained in:
parent
81a4dd0621
commit
faf721a9b1
@ -50,8 +50,8 @@ class ItemsAdapter(context: Context, private val mItems: List<FileDirItem>) : Ba
|
||||
viewHolder.icon.setImageBitmap(mDirectoryBmp)
|
||||
viewHolder.details.text = getChildrenCnt(item)
|
||||
} else {
|
||||
if (item.isImage()) {
|
||||
Glide.with(mContext).load(item.path).diskCacheStrategy(DiskCacheStrategy.RESULT).centerCrop().crossFade().into(viewHolder.icon)
|
||||
if (item.isImage() || item.isVideo()) {
|
||||
Glide.with(mContext).load(item.path).diskCacheStrategy(getCacheStrategy(item)).centerCrop().crossFade().into(viewHolder.icon)
|
||||
} else {
|
||||
viewHolder.icon.setImageBitmap(mFileBmp)
|
||||
}
|
||||
@ -61,6 +61,8 @@ class ItemsAdapter(context: Context, private val mItems: List<FileDirItem>) : Ba
|
||||
return view
|
||||
}
|
||||
|
||||
private fun getCacheStrategy(item: FileDirItem) = if (item.isGif()) DiskCacheStrategy.NONE else DiskCacheStrategy.RESULT
|
||||
|
||||
private fun getChildrenCnt(item: FileDirItem): String {
|
||||
val children = item.children
|
||||
return mRes.getQuantityString(R.plurals.items, children, children)
|
||||
|
@ -22,6 +22,10 @@ class FileDirItem(val path: String, val name: String, val isDirectory: Boolean,
|
||||
return "FileDirItem{name=$name, isDirectory=$isDirectory, path=$path, children=$children, size=$size}"
|
||||
}
|
||||
|
||||
fun isGif() = name.toLowerCase().endsWith(".gif")
|
||||
fun isVideo() = getMimeType().startsWith("video")
|
||||
fun isAudio() = getMimeType().startsWith("audio")
|
||||
|
||||
fun isImage(): Boolean {
|
||||
val options = BitmapFactory.Options()
|
||||
options.inJustDecodeBounds = true
|
||||
@ -29,14 +33,6 @@ class FileDirItem(val path: String, val name: String, val isDirectory: Boolean,
|
||||
return options.outWidth != -1 && options.outHeight != -1
|
||||
}
|
||||
|
||||
fun isVideo(): Boolean {
|
||||
return getMimeType().startsWith("video")
|
||||
}
|
||||
|
||||
fun isAudio(): Boolean {
|
||||
return getMimeType().startsWith("audio")
|
||||
}
|
||||
|
||||
fun getMimeType(): String {
|
||||
try {
|
||||
val retriever = MediaMetadataRetriever()
|
||||
|
Loading…
x
Reference in New Issue
Block a user