jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/342255 )
Change subject: Prevent possible crash when rendering feed card.
......................................................................
Prevent possible crash when rendering feed card.
In CardLargeHeaderView, we animate the background color of the view to
match the dominant color of the image.
The patch of d67f70027a63 seems to have incorrectly modified the attribute
on which this animation is keyed.
This patch fixes the animator, and gives it an arguably more compatible
attribute on which to key the animation.
This patch also adds a check for whether the view is attached to a window
before starting the animation.
Bug: T160299
Change-Id: Ic1a40209189c905dea0f8c4d61cfe6412a674692
---
M app/src/main/java/org/wikipedia/feed/view/CardLargeHeaderView.java
1 file changed, 9 insertions(+), 2 deletions(-)
Approvals:
Niedzielski: Looks good to me, approved
jenkins-bot: Verified
Mholloway: Looks good to me, but someone else must approve
diff --git a/app/src/main/java/org/wikipedia/feed/view/CardLargeHeaderView.java
b/app/src/main/java/org/wikipedia/feed/view/CardLargeHeaderView.java
index 01ba8fa..1051f71 100644
--- a/app/src/main/java/org/wikipedia/feed/view/CardLargeHeaderView.java
+++ b/app/src/main/java/org/wikipedia/feed/view/CardLargeHeaderView.java
@@ -9,6 +9,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
+import android.support.v4.view.ViewCompat;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -61,6 +62,9 @@
post(new Runnable() {
@Override
public void run() {
+ if
(!ViewCompat.isAttachedToWindow(CardLargeHeaderView.this)) {
+ return;
+ }
animateBackgroundColor(CardLargeHeaderView.this,
mainColor);
if (faceLocation != null) {
imageView.getHierarchy().setActualImageFocusPoint(faceLocation);
@@ -76,9 +80,12 @@
private void animateBackgroundColor(@NonNull View view, @ColorInt int
targetColor) {
final int animDuration = 500;
- final ObjectAnimator animator =
ObjectAnimator.ofObject(view.getBackground(), "tint",
- new ArgbEvaluator(), targetColor);
+ ObjectAnimator animator = ObjectAnimator.ofInt(view,
"backgroundColor",
+ ContextCompat.getColor(view.getContext(),
R.color.gray_background),
+ targetColor);
+ animator.setEvaluator(new ArgbEvaluator());
animator.setDuration(animDuration);
+ animator.setupStartValues();
animator.start();
}
}
--
To view, visit https://gerrit.wikimedia.org/r/342255
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1a40209189c905dea0f8c4d61cfe6412a674692
Gerrit-PatchSet: 3
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits