aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/ImageUtils.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-11-28 14:27:34 +0100
committerSamuel Tardieu <sam@rfc1149.net>2014-11-28 14:27:34 +0100
commitb181ef02fa057df18f0d071acbd628806d130591 (patch)
tree56cc18e970d7609498876356d68133958b49481e /main/src/cgeo/geocaching/utils/ImageUtils.java
parent7471f6e941665779391b6c251c8aecd3895e0a04 (diff)
downloadcgeo-b181ef02fa057df18f0d071acbd628806d130591.zip
cgeo-b181ef02fa057df18f0d071acbd628806d130591.tar.gz
cgeo-b181ef02fa057df18f0d071acbd628806d130591.tar.bz2
fix #4481: cache rendering leads to ANR
This fix is only partially correct, in that it will not recompute the whole layout (including the position of line breaks) when images are loaded.
Diffstat (limited to 'main/src/cgeo/geocaching/utils/ImageUtils.java')
-rw-r--r--main/src/cgeo/geocaching/utils/ImageUtils.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/utils/ImageUtils.java b/main/src/cgeo/geocaching/utils/ImageUtils.java
index e2ae7f5..15d2da1 100644
--- a/main/src/cgeo/geocaching/utils/ImageUtils.java
+++ b/main/src/cgeo/geocaching/utils/ImageUtils.java
@@ -348,7 +348,6 @@ public final class ImageUtils {
@SuppressWarnings("deprecation")
public ContainerDrawable(@NonNull final TextView view, final Observable<? extends Drawable> drawableObservable) {
this.view = view;
- drawable = null;
setBounds(0, 0, 0, 0);
updateFrom(drawableObservable);
}
@@ -364,7 +363,13 @@ public final class ImageUtils {
public void call(final Drawable newDrawable) {
setBounds(0, 0, newDrawable.getIntrinsicWidth(), newDrawable.getIntrinsicHeight());
drawable = newDrawable;
- view.setText(view.getText());
+ view.invalidateDrawable(this);
+ // This is necessary to force a layout recomputation. Appending text takes much less time
+ // than setting the whole text. However, if many images are drawn one after the other without
+ // line breaks or text between them, the rendering might be incorrect as is the case in
+ // for http://coord.info/GC49CQC.
+ // TODO: find a better way to make the view get redrawn, or use a different kind of view
+ view.append("");
}
public final void updateFrom(final Observable<? extends Drawable> drawableObservable) {