mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-14 19:00:36 +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.icon.setImageBitmap(mDirectoryBmp)
|
||||||
viewHolder.details.text = getChildrenCnt(item)
|
viewHolder.details.text = getChildrenCnt(item)
|
||||||
} else {
|
} else {
|
||||||
if (item.isImage()) {
|
if (item.isImage() || item.isVideo()) {
|
||||||
Glide.with(mContext).load(item.path).diskCacheStrategy(DiskCacheStrategy.RESULT).centerCrop().crossFade().into(viewHolder.icon)
|
Glide.with(mContext).load(item.path).diskCacheStrategy(getCacheStrategy(item)).centerCrop().crossFade().into(viewHolder.icon)
|
||||||
} else {
|
} else {
|
||||||
viewHolder.icon.setImageBitmap(mFileBmp)
|
viewHolder.icon.setImageBitmap(mFileBmp)
|
||||||
}
|
}
|
||||||
@ -61,6 +61,8 @@ class ItemsAdapter(context: Context, private val mItems: List<FileDirItem>) : Ba
|
|||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getCacheStrategy(item: FileDirItem) = if (item.isGif()) DiskCacheStrategy.NONE else DiskCacheStrategy.RESULT
|
||||||
|
|
||||||
private fun getChildrenCnt(item: FileDirItem): String {
|
private fun getChildrenCnt(item: FileDirItem): String {
|
||||||
val children = item.children
|
val children = item.children
|
||||||
return mRes.getQuantityString(R.plurals.items, children, 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}"
|
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 {
|
fun isImage(): Boolean {
|
||||||
val options = BitmapFactory.Options()
|
val options = BitmapFactory.Options()
|
||||||
options.inJustDecodeBounds = true
|
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
|
return options.outWidth != -1 && options.outHeight != -1
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isVideo(): Boolean {
|
|
||||||
return getMimeType().startsWith("video")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isAudio(): Boolean {
|
|
||||||
return getMimeType().startsWith("audio")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getMimeType(): String {
|
fun getMimeType(): String {
|
||||||
try {
|
try {
|
||||||
val retriever = MediaMetadataRetriever()
|
val retriever = MediaMetadataRetriever()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user