add a helper function to determine if the file is an image
This commit is contained in:
parent
424ca7dfb5
commit
fd00b26f9b
|
@ -40,6 +40,8 @@ class PropertiesDialog : DialogFragment() {
|
||||||
properties_files_count_label.visibility = View.VISIBLE
|
properties_files_count_label.visibility = View.VISIBLE
|
||||||
properties_files_count.visibility = View.VISIBLE
|
properties_files_count.visibility = View.VISIBLE
|
||||||
properties_files_count.text = mFilesCnt.toString()
|
properties_files_count.text = mFilesCnt.toString()
|
||||||
|
} else if (mItem.isImage()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val file = File(mItem.path)
|
val file = File(mItem.path)
|
||||||
|
@ -47,13 +49,13 @@ class PropertiesDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return AlertDialog.Builder(context)
|
return AlertDialog.Builder(context)
|
||||||
.setTitle(resources.getString(title))
|
.setTitle(resources.getString(title))
|
||||||
.setView(infoView)
|
.setView(infoView)
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.create()
|
.create()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getItemSize(): String {
|
private fun getItemSize(): String {
|
||||||
if (mItem.isDirectory) {
|
if (mItem.isDirectory) {
|
||||||
mShowHidden = Config.newInstance(context).showHidden
|
mShowHidden = Config.newInstance(context).showHidden
|
||||||
return getDirectorySize(File(mItem.path)).formatSize()
|
return getDirectorySize(File(mItem.path)).formatSize()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.simplemobiletools.filepicker.models
|
package com.simplemobiletools.filepicker.models
|
||||||
|
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
|
|
||||||
class FileDirItem(val path: String, val name: String, val isDirectory: Boolean, val children: Int, val size: Long) :
|
class FileDirItem(val path: String, val name: String, val isDirectory: Boolean, val children: Int, val size: Long) :
|
||||||
Comparable<FileDirItem> {
|
Comparable<FileDirItem> {
|
||||||
|
|
||||||
|
@ -16,4 +18,10 @@ class FileDirItem(val path: String, val name: String, val isDirectory: Boolean,
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
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 isImage(): Boolean {
|
||||||
|
val options = BitmapFactory.Options()
|
||||||
|
options.inJustDecodeBounds = true
|
||||||
|
return options.outWidth !== -1 && options.outHeight !== -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue