aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2013-05-22 00:28:42 +0200
committerSamuel Tardieu <sam@rfc1149.net>2013-05-22 00:37:53 +0200
commit1f221d6bd93f3b14f4362fc7c3c7d8698de41516 (patch)
treebbc7a933962449b1207d46d51fc74447bb1bcc53
parent9ba8167a4cd257bf65ea928bbd0f005bb088cab9 (diff)
downloadcgeo-1f221d6bd93f3b14f4362fc7c3c7d8698de41516.zip
cgeo-1f221d6bd93f3b14f4362fc7c3c7d8698de41516.tar.gz
cgeo-1f221d6bd93f3b14f4362fc7c3c7d8698de41516.tar.bz2
fix #2749: ensure that item has not changed before redrawing
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 43ce65f..b670ec9 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -2063,6 +2063,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
holder = new LogViewHolder(rowView);
rowView.setTag(holder);
}
+ holder.setPosition(position);
final LogEntry log = getItem(position);
@@ -2144,10 +2145,12 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
/** Loads the Log Images outside the ui thread. */
private class LogImageLoader extends AsyncTask<String, Progress, Spanned> {
- private LogViewHolder holder;
+ final private LogViewHolder holder;
+ final private int position;
public LogImageLoader(LogViewHolder holder) {
this.holder = holder;
+ this.position = holder.getPosition();
}
@Override
@@ -2157,7 +2160,10 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
@Override
protected void onPostExecute(Spanned result) {
- holder.text.setText(result);
+ // Ensure that this holder and its view still references the right item before updating the text.
+ if (position == holder.getPosition()) {
+ holder.text.setText(result);
+ }
}
}
@@ -2170,8 +2176,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
final TextView text;
final TextView images;
final ImageView statusMarker;
+ private int position;
- public LogViewHolder(View base) {
+ public LogViewHolder(final View base) {
date = (TextView) base.findViewById(R.id.added);
type = (TextView) base.findViewById(R.id.type);
author = (TextView) base.findViewById(R.id.author);
@@ -2180,6 +2187,15 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
images = (TextView) base.findViewById(R.id.log_images);
statusMarker = (ImageView) base.findViewById(R.id.log_mark);
}
+
+ public int getPosition() {
+ return position;
+ }
+
+ public void setPosition(final int position) {
+ this.position = position;
+ }
+
}
}