Skip to content

Commit fd00b26

Browse files
committed
add a helper function to determine if the file is an image
1 parent 424ca7d commit fd00b26

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,22 @@ class PropertiesDialog : DialogFragment() {
4040
properties_files_count_label.visibility = View.VISIBLE
4141
properties_files_count.visibility = View.VISIBLE
4242
properties_files_count.text = mFilesCnt.toString()
43+
} else if (mItem.isImage()) {
44+
4345
}
4446

4547
val file = File(mItem.path)
4648
properties_last_modified.text = formatLastModified(file.lastModified())
4749
}
4850

4951
return AlertDialog.Builder(context)
50-
.setTitle(resources.getString(title))
51-
.setView(infoView)
52-
.setPositiveButton(R.string.ok, null)
53-
.create()
52+
.setTitle(resources.getString(title))
53+
.setView(infoView)
54+
.setPositiveButton(R.string.ok, null)
55+
.create()
5456
}
5557

56-
fun getItemSize(): String {
58+
private fun getItemSize(): String {
5759
if (mItem.isDirectory) {
5860
mShowHidden = Config.newInstance(context).showHidden
5961
return getDirectorySize(File(mItem.path)).formatSize()

library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.simplemobiletools.filepicker.models
22

3+
import android.graphics.BitmapFactory
4+
35
class FileDirItem(val path: String, val name: String, val isDirectory: Boolean, val children: Int, val size: Long) :
46
Comparable<FileDirItem> {
57

@@ -16,4 +18,10 @@ class FileDirItem(val path: String, val name: String, val isDirectory: Boolean,
1618
override fun toString(): String {
1719
return "FileDirItem{name=$name, isDirectory=$isDirectory, path=$path, children=$children, size=$size}"
1820
}
21+
22+
fun isImage(): Boolean {
23+
val options = BitmapFactory.Options()
24+
options.inJustDecodeBounds = true
25+
return options.outWidth !== -1 && options.outHeight !== -1
26+
}
1927
}

0 commit comments

Comments
 (0)