MarkerItem: change UID to hold Object

This commit is contained in:
Hannes Janetzek 2014-02-09 19:59:26 +01:00
parent 025c482725
commit 2df9e8fccc
2 changed files with 23 additions and 17 deletions

View File

@ -181,7 +181,7 @@ public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
Item item = mItemList.get(i); Item item = mItemList.get(i);
if (!bbox.contains(item.mGeoPoint)) if (!bbox.contains(item.geoPoint))
continue; continue;
mapPosition.toScreenPoint(item.getPoint(), mTmpPoint); mapPosition.toScreenPoint(item.getPoint(), mTmpPoint);
@ -243,4 +243,12 @@ public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
return false; return false;
} }
public Item getByUid(Object uid) {
for (Item it : mItemList)
if (it.getUid() == uid)
return it;
return null;
}
} }

View File

@ -45,10 +45,10 @@ public class MarkerItem {
UPPER_LEFT_CORNER, LOWER_LEFT_CORNER UPPER_LEFT_CORNER, LOWER_LEFT_CORNER
} }
public final String mUid; public final Object uid;
public final String mTitle; public final String title;
public final String mDescription; public final String description;
public final GeoPoint mGeoPoint; public final GeoPoint geoPoint;
protected MarkerSymbol mMarker; protected MarkerSymbol mMarker;
/** /**
@ -56,34 +56,32 @@ public class MarkerItem {
* this should be <b>singleLine</b> (no <code>'\n'</code> ) * this should be <b>singleLine</b> (no <code>'\n'</code> )
* @param description * @param description
* a <b>multiLine</b> description ( <code>'\n'</code> possible) * a <b>multiLine</b> description ( <code>'\n'</code> possible)
* @param geoPoint
* ...
*/ */
public MarkerItem(String title, String description, GeoPoint geoPoint) { public MarkerItem(String title, String description, GeoPoint geoPoint) {
this(null, title, description, geoPoint); this(null, title, description, geoPoint);
} }
public MarkerItem(String uid, String title, String description, GeoPoint geoPoint) { public MarkerItem(Object uid, String title, String description, GeoPoint geoPoint) {
mTitle = title; this.title = title;
mDescription = description; this.description = description;
mGeoPoint = geoPoint; this.geoPoint = geoPoint;
mUid = uid; this.uid = uid;
} }
public String getUid() { public Object getUid() {
return mUid; return uid;
} }
public String getTitle() { public String getTitle() {
return mTitle; return title;
} }
public String getSnippet() { public String getSnippet() {
return mDescription; return description;
} }
public GeoPoint getPoint() { public GeoPoint getPoint() {
return mGeoPoint; return geoPoint;
} }
public MarkerSymbol getMarker() { public MarkerSymbol getMarker() {