Skip to content

Commit

Permalink
Prevent possible crash due to post-ing on a View.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrant committed Jan 23, 2025
1 parent 8b82ef1 commit 2effb28
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wikipedia.feed.announcement

import android.app.Activity
import android.content.Context
import android.net.Uri
import android.view.LayoutInflater
Expand Down Expand Up @@ -65,6 +66,9 @@ class AnnouncementCardView(context: Context) : DefaultFeedCardView<AnnouncementC
if (it.aspectRatio() != 0.0) {
binding.viewAnnouncementHeaderImage.scaleType = ImageView.ScaleType.FIT_CENTER
binding.viewAnnouncementHeaderImage.post {
if ((context as? Activity)?.isDestroyed == true) {
return@post
}
binding.viewAnnouncementHeaderImage.updateLayoutParams {
height = (binding.viewAnnouncementHeaderImage.width / it.aspectRatio()).toInt()
}
Expand Down

0 comments on commit 2effb28

Please sign in to comment.