Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed POI id to String and removed hashCode. #555

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cyclestreets.app/src/main/assets/whatsnew.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<h3>Release 3.12</h3>
<i>There are no new features in this release. We are updated a number of our
dependencies, including our underlying maps display.</i>
<li>POI issue fixed.</li>

<h3>Release 3.11</h3>
<strong>Features</strong>
Expand Down
3 changes: 2 additions & 1 deletion cyclestreets.app/src/main/play/release-notes/en-GB/beta.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
There are no new features in this release. We are updated a number of our
dependencies, including our underlying maps display.
dependencies, including our underlying maps display.
POI issue fixed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class POI
{
private final int id;
private final String id;
private final String name;
private final String notes;
private final String url;
Expand All @@ -16,7 +16,7 @@ public class POI

private POICategory category;

public POI(final int id,
public POI(final String id,
final String name,
final String notes,
final String url,
Expand All @@ -35,7 +35,7 @@ public POI(final int id,

public void setCategory(final POICategory category) { this.category = category; }

public int id() { return id; }
public String id() { return id; }
public String name() { return stringOrBlank(name); }
public String notes() { return stringOrBlank(notes); }
public String url() { return stringOrBlank(url); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class PoiTypesDto {
}


fun poiIcon(context: Context, id: String): Drawable {
val key = "poi_${id}"
fun poiIcon(context: Context, type: String): Drawable {
val key = "poi_${type}"
val res = context.resources
val resPackage = res.getResourcePackageName(defaultResId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static POI toPoi(Feature feature) {
if (TextUtils.isEmpty(website))
website = osmTags.get("url");

return new POI(Integer.parseInt(feature.getProperty("id")),
return new POI(feature.getProperty("id"),
feature.getProperty("name"),
feature.getProperty("notes"),
website,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private static void validatePois(List<POI> pois) {

// happy path
POI poi = pois.get(0);
assertThat(poi.id()).isEqualTo(101399);
assertThat(poi.id()).isEqualTo("101399");
assertThat(poi.name()).isEqualTo("Chris's Bikes");
assertThat(poi.notes()).isEqualTo("The notes section");
assertThat(poi.phone()).isEqualTo("01234 567890");
Expand All @@ -203,7 +203,7 @@ private static void validatePois(List<POI> pois) {

// website provided within `osmTags.url`, but not in `website`
poi = pois.get(6);
assertThat(poi.id()).isEqualTo(113267);
assertThat(poi.id()).isEqualTo("113267");
assertThat(poi.name()).isEqualTo("Bicycle Ambulance");
assertThat(poi.notes()).isEqualTo("");
assertThat(poi.phone()).isEqualTo("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"type": "Feature",
"properties": {
"id": "101399",
"id": "alpha_101399",
"name": "Chris's Bikes",
"notes": "The notes section",
"osmTags": {
Expand Down Expand Up @@ -113,7 +113,7 @@
{
"type": "Feature",
"properties": {
"id": "113267",
"id": "some-other-characters-113267",
"name": "Bicycle Ambulance",
"notes": "",
"osmTags": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class Journey private constructor(wp: Waypoints? = null) {
// For circular route pois, the id isn't returned in the API, so will create an artificial one.
var id = 0
for (poi in jdo.pois) {
val circularRoutePoi = POI(id,
val circularRoutePoi = POI(id.toString(),
poi.name,
"",
poi.website,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.osmdroid.events.ZoomEvent
import org.osmdroid.util.BoundingBox
import org.osmdroid.views.MapView
import org.osmdroid.views.overlay.OverlayItem
import java.util.Objects


private val TAG = Logging.getTag(POIOverlay::class.java)
Expand Down Expand Up @@ -362,7 +363,7 @@ class POIOverlay(mapView: CycleMapView) : LiveItemOverlay<POIOverlayItem?>(mapVi
}


class POIOverlayItem(val poi: POI) : OverlayItem(poi.id().toString(), poi.name(),
class POIOverlayItem(val poi: POI) : OverlayItem(poi.id(), poi.name(),
poi.notes(), poi.position()) {

init {
Expand All @@ -381,7 +382,7 @@ class POIOverlay(mapView: CycleMapView) : LiveItemOverlay<POIOverlayItem?>(mapVi
}

override fun hashCode(): Int {
return poi.id()
return Objects.hashCode(poi.id())
}

override fun toString(): String {
Expand Down