diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-11-10 16:48:06 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-11-10 16:48:22 +0100 |
| commit | e4627ac2425adbdddf6f7750eb2cbba7f5e3204b (patch) | |
| tree | 5caf6724210818cbc91b57fc4313e7a9a95cff90 | |
| parent | 4fa47e217d80347d0f39e7c2d6b9719436f3234f (diff) | |
| download | cgeo-e4627ac2425adbdddf6f7750eb2cbba7f5e3204b.zip cgeo-e4627ac2425adbdddf6f7750eb2cbba7f5e3204b.tar.gz cgeo-e4627ac2425adbdddf6f7750eb2cbba7f5e3204b.tar.bz2 | |
fix #3420: Waypoint description gets mixed up
| -rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 35 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/CgeoApplication.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/Waypoint.java | 28 |
3 files changed, 31 insertions, 34 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index f92245c..89e78d6 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -68,6 +68,7 @@ import android.graphics.Bitmap; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; @@ -1814,6 +1815,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } private class WaypointsViewCreator extends AbstractCachingPageViewCreator<ListView> { + private final int VISITED_INSET = (int) (6.6f * CgeoApplication.getInstance().getResources().getDisplayMetrics().density + 0.5f); @Override public ListView getDispatchedView() { @@ -1864,20 +1866,26 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc protected void fillViewHolder(View rowView, final WaypointViewHolder holder, final Waypoint wpt) { // coordinates + final TextView coordinatesView = holder.coordinatesView; if (null != wpt.getCoords()) { - final TextView coordinatesView = holder.coordinatesView; coordinatesView.setOnClickListener(new CoordinatesFormatSwitcher(wpt.getCoords())); coordinatesView.setText(wpt.getCoords().toString()); coordinatesView.setVisibility(View.VISIBLE); } + else { + coordinatesView.setVisibility(View.GONE); + } // info final String waypointInfo = Formatter.formatWaypointInfo(wpt); + final TextView infoView = holder.infoView; if (StringUtils.isNotBlank(waypointInfo)) { - final TextView infoView = holder.infoView; infoView.setText(waypointInfo); infoView.setVisibility(View.VISIBLE); } + else { + infoView.setVisibility(View.GONE); + } // title final TextView nameView = holder.nameView; @@ -1888,7 +1896,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } else { nameView.setText(res.getString(R.string.waypoint)); } - wpt.setIcon(res, nameView); + setWaypointIcon(res, nameView, wpt); // visited if (wpt.isVisited()) { @@ -1901,8 +1909,8 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } // note + final TextView noteView = holder.noteView; if (StringUtils.isNotBlank(wpt.getNote())) { - final TextView noteView = holder.noteView; noteView.setVisibility(View.VISIBLE); if (TextUtils.containsHtml(wpt.getNote())) { noteView.setText(Html.fromHtml(wpt.getNote()), TextView.BufferType.SPANNABLE); @@ -1911,6 +1919,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc noteView.setText(wpt.getNote()); } } + else { + noteView.setVisibility(View.GONE); + } final View wpNavView = holder.wpNavView; wpNavView.setOnClickListener(new View.OnClickListener() { @@ -1946,6 +1957,22 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } }); } + + private void setWaypointIcon(final Resources res, final TextView nameView, final Waypoint wpt) { + final WaypointType waypointType = wpt.getWaypointType(); + final Drawable icon; + if (wpt.isVisited()) { + LayerDrawable ld = new LayerDrawable(new Drawable[] { + res.getDrawable(waypointType.markerId), + res.getDrawable(R.drawable.tick) }); + ld.setLayerInset(0, 0, 0, VISITED_INSET, VISITED_INSET); + ld.setLayerInset(1, VISITED_INSET, VISITED_INSET, 0, 0); + icon = ld; + } else { + icon = res.getDrawable(waypointType.markerId); + } + nameView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); + } } private class InventoryViewCreator extends AbstractCachingPageViewCreator<ListView> { diff --git a/main/src/cgeo/geocaching/CgeoApplication.java b/main/src/cgeo/geocaching/CgeoApplication.java index 2c419cf..0af8117 100644 --- a/main/src/cgeo/geocaching/CgeoApplication.java +++ b/main/src/cgeo/geocaching/CgeoApplication.java @@ -37,8 +37,6 @@ public class CgeoApplication extends Application { @Override public void onCreate() { new Thread(statusUpdater).start(); - // Initialize densitiy related waypoint data - Waypoint.initializeScale(); } @Override diff --git a/main/src/cgeo/geocaching/Waypoint.java b/main/src/cgeo/geocaching/Waypoint.java index b204bdd..6f28aa1 100644 --- a/main/src/cgeo/geocaching/Waypoint.java +++ b/main/src/cgeo/geocaching/Waypoint.java @@ -5,11 +5,6 @@ import cgeo.geocaching.geopoint.Geopoint; import org.apache.commons.lang3.StringUtils; -import android.content.res.Resources; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; -import android.widget.TextView; - import java.util.HashMap; import java.util.List; import java.util.Map; @@ -33,13 +28,6 @@ public class Waypoint implements IWaypoint, Comparable<Waypoint> { private int cachedOrder = ORDER_UNDEFINED; private boolean own = false; private boolean visited = false; - // preliminary default for mdpi screens - private static int VISITED_INSET = 7; - - public static void initializeScale() { - // Calculate visited inset based on screen density - VISITED_INSET = (int) (6.6f * CgeoApplication.getInstance().getResources().getDisplayMetrics().density + 0.5f); - } /** * require name and type for every waypoint @@ -64,22 +52,6 @@ public class Waypoint implements IWaypoint, Comparable<Waypoint> { id = -1; } - public void setIcon(final Resources res, final TextView nameView) { - Drawable icon; - if (visited) { - LayerDrawable ld = new LayerDrawable(new Drawable[] { - res.getDrawable(waypointType.markerId), - res.getDrawable(R.drawable.tick) }); - ld.setLayerInset(0, 0, 0, VISITED_INSET, VISITED_INSET); - ld.setLayerInset(1, VISITED_INSET, VISITED_INSET, 0, 0); - icon = ld; - } else { - icon = res.getDrawable(waypointType.markerId); - } - final Drawable fIcon = icon; - nameView.setCompoundDrawablesWithIntrinsicBounds(fIcon, null, null, null); - } - public void merge(final Waypoint old) { if (StringUtils.isBlank(prefix)) { setPrefix(old.prefix); |
