aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-12-04 18:26:24 +0100
committerBananeweizen <bananeweizen@gmx.de>2012-12-04 18:26:24 +0100
commit16705d8dfcd30e10b66bc993ef8fe61229d6367a (patch)
treef9b97d4361cc8d9dff80ef92d5fe20956f5fd0cf /main/src/cgeo/geocaching
parent472ecb9980b39b3a2945119d9a347e90d24e0443 (diff)
downloadcgeo-16705d8dfcd30e10b66bc993ef8fe61229d6367a.zip
cgeo-16705d8dfcd30e10b66bc993ef8fe61229d6367a.tar.gz
cgeo-16705d8dfcd30e10b66bc993ef8fe61229d6367a.tar.bz2
#2223: change creation of spannables
Diffstat (limited to 'main/src/cgeo/geocaching')
-rw-r--r--main/src/cgeo/geocaching/cgCache.java14
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java14
-rw-r--r--main/src/cgeo/geocaching/ui/CacheListAdapter.java23
3 files changed, 15 insertions, 36 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index a0f16e9..6978bfa 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -38,7 +38,6 @@ import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.text.Html;
-import android.text.Spannable;
import java.util.ArrayList;
import java.util.Calendar;
@@ -66,7 +65,6 @@ public class cgCache implements ICache, IWaypoint {
private String guid = "";
private CacheType cacheType = CacheType.UNKNOWN;
private String name = "";
- private Spannable nameSp = null;
private String ownerDisplayName = "";
private String ownerUserId = "";
private Date hidden = null;
@@ -227,9 +225,6 @@ public class cgCache implements ICache, IWaypoint {
if (StringUtils.isBlank(name)) {
name = other.name;
}
- if (StringUtils.isBlank(nameSp)) {
- nameSp = other.nameSp;
- }
if (StringUtils.isBlank(ownerDisplayName)) {
ownerDisplayName = other.ownerDisplayName;
}
@@ -376,7 +371,6 @@ public class cgCache implements ICache, IWaypoint {
(direction != null ? direction.equals(other.direction) : null == other.direction) &&
(distance != null ? distance.equals(other.distance) : null == other.distance) &&
(elevation != null ? elevation.equals(other.elevation) : null == other.elevation) &&
- nameSp == other.nameSp &&
rating == other.rating &&
votes == other.votes &&
myVote == other.myVote &&
@@ -808,14 +802,6 @@ public class cgCache implements ICache, IWaypoint {
this.detailed = detailed;
}
- public Spannable getNameSp() {
- return nameSp;
- }
-
- public void setNameSp(Spannable nameSp) {
- this.nameSp = nameSp;
- }
-
public void setHidden(final Date hidden) {
if (hidden == null) {
this.hidden = null;
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 3ab1120..f2a86d9 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -44,10 +44,6 @@ import org.json.JSONObject;
import android.net.Uri;
import android.text.Html;
-import android.text.Spannable;
-import android.text.Spanned;
-import android.text.style.ForegroundColorSpan;
-import android.text.style.StrikethroughSpan;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -222,16 +218,6 @@ public abstract class GCParser {
Log.w("GCParser.parseSearch: Failed to parse favourite count");
}
- if (cache.getNameSp() == null) {
- cache.setNameSp((new Spannable.Factory()).newSpannable(cache.getName()));
- if (cache.isDisabled() || cache.isArchived()) { // strike
- cache.getNameSp().setSpan(new StrikethroughSpan(), 0, cache.getNameSp().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- if (cache.isArchived()) {
- cache.getNameSp().setSpan(new ForegroundColorSpan(cgeoapplication.getInstance().getResources().getColor(R.color.archived_cache_color)), 0, cache.getNameSp().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- }
-
searchResult.addCache(cache);
}
diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
index 65d3fbc..a2221c9 100644
--- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java
+++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
@@ -390,17 +390,24 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> {
holder.logStatusMark.setVisibility(View.GONE);
}
- if (cache.getNameSp() == null) {
- cache.setNameSp((new Spannable.Factory()).newSpannable(cache.getName()));
- if (cache.isDisabled() || cache.isArchived()) { // strike
- cache.getNameSp().setSpan(new StrikethroughSpan(), 0, cache.getNameSp().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- if (cache.isArchived()) {
- cache.getNameSp().setSpan(new ForegroundColorSpan(res.getColor(R.color.archived_cache_color)), 0, cache.getNameSp().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spannable spannable = null;
+ if (cache.isDisabled() || cache.isArchived()) { // strike
+ spannable = Spannable.Factory.getInstance().newSpannable(cache.getName());
+ spannable.setSpan(new StrikethroughSpan(), 0, spannable.toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+ if (cache.isArchived()) { // red color
+ if (spannable == null) {
+ spannable = Spannable.Factory.getInstance().newSpannable(cache.getName());
}
+ spannable.setSpan(new ForegroundColorSpan(res.getColor(R.color.archived_cache_color)), 0, spannable.toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
- holder.text.setText(cache.getNameSp(), TextView.BufferType.SPANNABLE);
+ if (spannable != null) {
+ holder.text.setText(spannable, TextView.BufferType.SPANNABLE);
+ }
+ else {
+ holder.text.setText(cache.getName());
+ }
holder.text.setCompoundDrawablesWithIntrinsicBounds(getCacheIcon(cache), null, null, null);
if (cache.getInventoryItems() > 0) {