mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
allow directory comparison end in result 0
This commit is contained in:
parent
59bba6fc2e
commit
865df01f3a
5 changed files with 27 additions and 19 deletions
|
@ -121,8 +121,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.viewpager_menu, menu)
|
||||
menu.findItem(R.id.menu_set_as_wallpaper).isVisible = getCurrentMedium().isImage
|
||||
menu.findItem(R.id.menu_edit).isVisible = getCurrentMedium().isImage
|
||||
menu.findItem(R.id.menu_set_as_wallpaper).isVisible = getCurrentMedium().isImage()
|
||||
menu.findItem(R.id.menu_edit).isVisible = getCurrentMedium().isImage()
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ class MediaAdapter(val activity: SimpleActivity, val media: MutableList<Medium>,
|
|||
|
||||
val path = medium.path
|
||||
val timestampSignature = StringSignature(medium.timestamp.toString())
|
||||
if (medium.isGif) {
|
||||
if (medium.isGif()) {
|
||||
Glide.with(activity).load(path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).signature(timestampSignature).into(itemView.medium_thumbnail)
|
||||
} else {
|
||||
Glide.with(activity).load(path).diskCacheStrategy(DiskCacheStrategy.RESULT).signature(timestampSignature)
|
||||
|
|
|
@ -27,7 +27,7 @@ class PhotoFragment : ViewPagerFragment(), View.OnClickListener {
|
|||
medium.path = context.getRealPathFromURI(Uri.parse(medium.path)) ?: ""
|
||||
|
||||
subsamplingView = view.photo_view
|
||||
if (medium.isGif) {
|
||||
if (medium.isGif()) {
|
||||
subsamplingView.visibility = View.GONE
|
||||
view.gif_view.apply {
|
||||
visibility = View.VISIBLE
|
||||
|
|
|
@ -5,6 +5,10 @@ import com.simplemobiletools.gallery.SORT_BY_NAME
|
|||
import com.simplemobiletools.gallery.SORT_DESCENDING
|
||||
|
||||
class Directory(val path: String, val thumbnail: String, val name: String, var mediaCnt: Int, val timestamp: Long, var size: Long) : Comparable<Directory> {
|
||||
companion object {
|
||||
var sorting: Int = 0
|
||||
}
|
||||
|
||||
fun addSize(bytes: Long) {
|
||||
size += bytes
|
||||
}
|
||||
|
@ -14,9 +18,19 @@ class Directory(val path: String, val thumbnail: String, val name: String, var m
|
|||
if (sorting and SORT_BY_NAME != 0) {
|
||||
res = name.toLowerCase().compareTo(other.name.toLowerCase())
|
||||
} else if (sorting and SORT_BY_DATE != 0) {
|
||||
res = if (timestamp > other.timestamp) 1 else -1
|
||||
res = if (timestamp == other.timestamp)
|
||||
0
|
||||
else if (timestamp > other.timestamp)
|
||||
1
|
||||
else
|
||||
-1
|
||||
} else {
|
||||
res = if (size > other.size) 1 else -1
|
||||
res = if (size == other.size)
|
||||
0
|
||||
else if (size > other.size)
|
||||
1
|
||||
else
|
||||
-1
|
||||
}
|
||||
|
||||
if (sorting and SORT_DESCENDING != 0) {
|
||||
|
@ -26,8 +40,4 @@ class Directory(val path: String, val thumbnail: String, val name: String, var m
|
|||
}
|
||||
|
||||
override fun toString() = "Directory {path=$path, thumbnail=$thumbnail, name=$name, mediaCnt=$mediaCnt, timestamp=$timestamp, size $size}"
|
||||
|
||||
companion object {
|
||||
var sorting: Int = 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,14 @@ import com.simplemobiletools.gallery.SORT_DESCENDING
|
|||
import java.io.Serializable
|
||||
|
||||
class Medium(val name: String, var path: String, val isVideo: Boolean, val timestamp: Long, val size: Long) : Serializable, Comparable<Medium> {
|
||||
val isGif: Boolean
|
||||
get() = path.toLowerCase().endsWith(".gif")
|
||||
companion object {
|
||||
private val serialVersionUID = -6553149466975455L
|
||||
var sorting: Int = 0
|
||||
}
|
||||
|
||||
val isImage: Boolean
|
||||
get() = !isGif && !isVideo
|
||||
fun isGif() = path.toLowerCase().endsWith(".gif")
|
||||
|
||||
fun isImage() = !isGif() && !isVideo
|
||||
|
||||
fun getMimeType() = if (isVideo) "video/*" else "image/*"
|
||||
|
||||
|
@ -41,9 +44,4 @@ class Medium(val name: String, var path: String, val isVideo: Boolean, val times
|
|||
}
|
||||
|
||||
override fun toString() = "Medium {name=$name, path=$path, isVideo=$isVideo, timestamp=$timestamp, size=$size}"
|
||||
|
||||
companion object {
|
||||
private val serialVersionUID = -6553149466975455L
|
||||
var sorting: Int = 0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue