more offline stuff/bugfixes

This commit is contained in:
Finnley Somdahl 2023-11-20 00:39:14 -06:00
parent 3dfcc9fc31
commit 4db301ca7a
29 changed files with 341 additions and 119 deletions

View file

@ -420,7 +420,13 @@ fun String.findBetween(a: String, b: String): String? {
fun ImageView.loadImage(url: String?, size: Int = 0) {
if (!url.isNullOrEmpty()) {
loadImage(FileUrl(url), size)
val localFile = File(url)
if (localFile.exists()) {
loadLocalImage(localFile, size)
}
else {
loadImage(FileUrl(url), size)
}
}
}
@ -433,6 +439,14 @@ fun ImageView.loadImage(file: FileUrl?, size: Int = 0) {
}
}
fun ImageView.loadLocalImage(file: File?, size: Int = 0) {
if (file?.exists() == true) {
tryWith {
Glide.with(this.context).load(file).transition(withCrossFade()).override(size).into(this)
}
}
}
class SafeClickListener(
private var defaultInterval: Int = 1000,
private val onSafeCLick: (View) -> Unit