Skip to content

Commit

Permalink
Clear before setting resource (#4801)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeniorZhai authored Jul 22, 2024
1 parent 64b7f38 commit 44cf1e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ fun ImageView.loadImage(
onError: ((request: ImageRequest, result: ErrorResult) -> Unit)? = null,
transformation: Transformation? = null,
) {
this.clear()
this.load(data) {
if (base64Holder != null) {
placeholder(base64Holder.toDrawable(layoutParams.width, layoutParams.height))
Expand Down Expand Up @@ -69,7 +68,6 @@ fun ImageView.loadImageCompat(
onError: ((request: ImageRequest, result: ErrorResult) -> Unit)? = null,
transformation: Transformation? = null,
) {
this.clear()
this.load(data) {
if (base64Holder != null) {
placeholder(base64Holder.toDrawable(layoutParams.width, layoutParams.height))
Expand All @@ -94,7 +92,6 @@ fun ImageView.loadImage(
@DrawableRes holder: Int? = null,
base64Holder: String? = null,
) {
this.clear()
this.load(uri) {
if (base64Holder != null) {
placeholder(base64Holder.toDrawable(layoutParams.width, layoutParams.height))
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/one/mixin/android/widget/AvatarView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class AvatarView : ViewAnimator {

fun setNet(padding: Int = context.dpToPx(8f)) {
displayedChild = POS_AVATAR
avatarSimple.clear()
avatarSimple.setBackgroundResource(R.drawable.bg_circle_70_solid_gray)
avatarSimple.setImageResource(R.drawable.ic_transfer_address)
avatarSimple.setPadding(padding)
Expand All @@ -95,15 +96,18 @@ class AvatarView : ViewAnimator {
fun setDeposit() {
displayedChild = POS_AVATAR
avatarSimple.setImageResource(R.drawable.ic_snapshot_deposit)
avatarSimple.clear()
}

fun setWithdrawal() {
displayedChild = POS_AVATAR
avatarSimple.clear()
avatarSimple.setImageResource(R.drawable.ic_snapshot_withdrawal)
}

fun setAnonymous() {
displayedChild = POS_AVATAR
avatarSimple.clear()
avatarSimple.setImageResource(R.drawable.ic_snapshot_anonymous)
}

Expand All @@ -120,6 +124,7 @@ class AvatarView : ViewAnimator {
displayedChild =
if (!url.isNullOrEmpty()) {
avatarSimple.setBackgroundResource(0)
avatarSimple.clear()
avatarSimple.setImageResource(0)
avatarSimple.setPadding(0)
avatarSimple.loadImage(url, R.drawable.ic_avatar_place_holder)
Expand Down

0 comments on commit 44cf1e6

Please sign in to comment.