aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-06-02 19:47:36 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-06-02 19:47:36 +0200
commitd2494279b07b4675d0303cce90e615934c422850 (patch)
tree0fe912ed11a7f0d6c141f84bfdffed360467d296
parentf17865dcd020d5b8d488fa5fb6b98ec72409c92d (diff)
downloadcgeo-d2494279b07b4675d0303cce90e615934c422850.zip
cgeo-d2494279b07b4675d0303cce90e615934c422850.tar.gz
cgeo-d2494279b07b4675d0303cce90e615934c422850.tar.bz2
refactoring: extract some common code out of log viewers
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java55
-rw-r--r--main/src/cgeo/geocaching/LogViewHolder.java46
-rw-r--r--main/src/cgeo/geocaching/TrackableActivity.java23
3 files changed, 56 insertions, 68 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index bdc1921..58765bc 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -2156,7 +2156,6 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
LogViewHolder holder = (LogViewHolder) rowView.getTag();
if (null == holder) {
holder = new LogViewHolder(rowView);
- rowView.setTag(holder);
}
holder.setPosition(position);
@@ -2173,11 +2172,11 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
holder.author.setText(StringEscapeUtils.unescapeHtml4(log.author));
// finds count
- holder.count.setVisibility(View.VISIBLE);
+ holder.countOrLocation.setVisibility(View.VISIBLE);
if (log.found == -1) {
- holder.count.setVisibility(View.GONE);
+ holder.countOrLocation.setVisibility(View.GONE);
} else {
- holder.count.setText(res.getQuantityString(R.plurals.cache_counts, log.found, log.found));
+ holder.countOrLocation.setText(res.getQuantityString(R.plurals.cache_counts, log.found, log.found));
}
// logtext, avoid parsing HTML if not necessary
@@ -2215,11 +2214,11 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
// colored marker
int marker = log.type.markerId;
if (marker != 0) {
- holder.statusMarker.setVisibility(View.VISIBLE);
- holder.statusMarker.setImageResource(marker);
+ holder.marker.setVisibility(View.VISIBLE);
+ holder.marker.setImageResource(marker);
}
else {
- holder.statusMarker.setVisibility(View.GONE);
+ holder.marker.setVisibility(View.GONE);
}
if (null == convertView) {
@@ -2263,48 +2262,6 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
- private class LogViewHolder {
- final TextView date;
- final TextView type;
- final TextView author;
- final TextView count;
- final TextView text;
- final TextView images;
- final ImageView statusMarker;
- private int position;
-
- 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);
- count = (TextView) base.findViewById(R.id.count_or_location);
- text = (TextView) base.findViewById(R.id.log);
- images = (TextView) base.findViewById(R.id.log_images);
- statusMarker = (ImageView) base.findViewById(R.id.log_mark);
- }
-
- /**
- * Read the position of the cursor pointed to by this holder. <br/>
- * This must be called by the UI thread.
- *
- * @return the cursor position
- */
- public int getPosition() {
- return position;
- }
-
- /**
- * Set the position of the cursor pointed to by this holder. <br/>
- * This must be called by the UI thread.
- *
- * @param position
- * the cursor position
- */
- public void setPosition(final int position) {
- this.position = position;
- }
-
- }
}
private class WaypointsViewCreator extends AbstractCachingPageViewCreator<ScrollView> {
diff --git a/main/src/cgeo/geocaching/LogViewHolder.java b/main/src/cgeo/geocaching/LogViewHolder.java
new file mode 100644
index 0000000..1fb3f55
--- /dev/null
+++ b/main/src/cgeo/geocaching/LogViewHolder.java
@@ -0,0 +1,46 @@
+package cgeo.geocaching;
+
+import butterknife.InjectView;
+import butterknife.Views;
+
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class LogViewHolder {
+ @InjectView(R.id.added) protected TextView date ;
+ @InjectView(R.id.type) protected TextView type;
+ @InjectView(R.id.author) protected TextView author;
+ @InjectView(R.id.count_or_location) protected TextView countOrLocation;
+ @InjectView(R.id.log) protected TextView text;
+ @InjectView(R.id.log_images) protected TextView images;
+ @InjectView(R.id.log_mark) protected ImageView marker;
+
+ private int position;
+
+ public LogViewHolder(View rowView) {
+ Views.inject(this, rowView);
+ rowView.setTag(this);
+ }
+
+ /**
+ * Read the position of the cursor pointed to by this holder. <br/>
+ * This must be called by the UI thread.
+ *
+ * @return the cursor position
+ */
+ public int getPosition() {
+ return position;
+ }
+
+ /**
+ * Set the position of the cursor pointed to by this holder. <br/>
+ * This must be called by the UI thread.
+ *
+ * @param position
+ * the cursor position
+ */
+ public void setPosition(final int position) {
+ this.position = position;
+ }
+} \ No newline at end of file
diff --git a/main/src/cgeo/geocaching/TrackableActivity.java b/main/src/cgeo/geocaching/TrackableActivity.java
index 1295181..383b327 100644
--- a/main/src/cgeo/geocaching/TrackableActivity.java
+++ b/main/src/cgeo/geocaching/TrackableActivity.java
@@ -387,21 +387,6 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
public class LogsViewCreator extends AbstractCachingPageViewCreator<ListView> {
- protected class LogViewHolder {
- @InjectView(R.id.added) protected TextView added ;
- @InjectView(R.id.type) protected TextView type;
- @InjectView(R.id.author) protected TextView author;
- @InjectView(R.id.count_or_location) protected TextView location;
- @InjectView(R.id.log) protected TextView text;
- @InjectView(R.id.log_images) protected TextView images;
- @InjectView(R.id.log_mark) protected ImageView marker;
-
- public LogViewHolder(View rowView) {
- Views.inject(this, rowView);
- rowView.setTag(this);
- }
- }
-
@Override
public ListView getDispatchedView() {
view = (ListView) getLayoutInflater().inflate(R.layout.trackable_logs_view, null);
@@ -430,19 +415,19 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
protected void fillViewHolder(LogViewHolder holder, final LogEntry log) {
if (log.date > 0) {
- holder.added.setText(Formatter.formatShortDateVerbally(log.date));
+ holder.date.setText(Formatter.formatShortDateVerbally(log.date));
}
holder.type.setText(log.type.getL10n());
holder.author.setText(Html.fromHtml(log.author), TextView.BufferType.SPANNABLE);
if (StringUtils.isBlank(log.cacheName)) {
- holder.location.setVisibility(View.GONE);
+ holder.countOrLocation.setVisibility(View.GONE);
} else {
- holder.location.setText(Html.fromHtml(log.cacheName));
+ holder.countOrLocation.setText(Html.fromHtml(log.cacheName));
final String cacheGuid = log.cacheGuid;
final String cacheName = log.cacheName;
- holder.location.setOnClickListener(new View.OnClickListener() {
+ holder.countOrLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
CacheDetailActivity.startActivityGuid(TrackableActivity.this, cacheGuid, Html.fromHtml(cacheName).toString());