mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
fix issue with loading blank images
This commit is contained in:
parent
205345bb72
commit
a07e6e002c
1 changed files with 16 additions and 2 deletions
|
|
@ -20,7 +20,8 @@ import java.util.Collections
|
|||
import java.util.Date
|
||||
|
||||
fun PixelArtView.loadImage(imageName: String?, imageFormat: String? = null) {
|
||||
if (imageName != null) {
|
||||
val shouldLoadImage = DataBindingUtils.existsAsImage(imageName)
|
||||
if (shouldLoadImage && imageName != null) {
|
||||
val fullname = DataBindingUtils.getFullFilename(imageName, imageFormat)
|
||||
if (tag == fullname) {
|
||||
return
|
||||
|
|
@ -39,11 +40,14 @@ fun PixelArtView.loadImage(imageName: String?, imageFormat: String? = null) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tag = null
|
||||
setImageDrawable(null)
|
||||
bitmap = null
|
||||
}
|
||||
}
|
||||
|
||||
object DataBindingUtils {
|
||||
|
||||
fun loadImage(context: Context, imageName: String, imageResult: (Drawable) -> Unit) {
|
||||
loadImage(context, imageName, null, imageResult)
|
||||
}
|
||||
|
|
@ -84,6 +88,16 @@ object DataBindingUtils {
|
|||
view.background = drawable
|
||||
}
|
||||
|
||||
fun existsAsImage(imageName: String?): Boolean {
|
||||
if (imageName == null) {
|
||||
return false
|
||||
}
|
||||
if (imageName == "shop_") {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
class LayoutWeightAnimation(internal var view: View, internal var targetWeight: Float) : Animation() {
|
||||
private var initializeWeight: Float = 0.toFloat()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue