Skip to content

Commit 4f4587f

Browse files
pshmaskara
authored and
maskara
committed
Moved code to reduce feature envy.
1 parent e589d0e commit 4f4587f

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

app/src/main/java/fr/free/nrw/commons/location/LatLng.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package fr.free.nrw.commons.location;
22

33
import android.location.Location;
4+
import android.net.Uri;
45
import android.support.annotation.NonNull;
56

67
/**
@@ -11,15 +12,15 @@ public class LatLng {
1112
private final double latitude;
1213
private final double longitude;
1314
private final float accuracy;
14-
15+
1516
/**
1617
* Accepts latitude and longitude.
1718
* North and South values are cut off at 90°
18-
*
19+
*
1920
* @param latitude the latitude
2021
* @param longitude the longitude
2122
* @param accuracy the accuracy
22-
*
23+
*
2324
* Examples:
2425
* the Statue of Liberty is located at 40.69° N, 74.04° W
2526
* The Statue of Liberty could be constructed as LatLng(40.69, -74.04, 1.0)
@@ -43,7 +44,7 @@ public LatLng(double latitude, double longitude, float accuracy) {
4344
public static LatLng from(@NonNull Location location) {
4445
return new LatLng(location.getLatitude(), location.getLongitude(), location.getAccuracy());
4546
}
46-
47+
4748
/**
4849
* creates a hash code for the longitude and longitude
4950
*/
@@ -153,4 +154,8 @@ public double getLongitude() {
153154
public double getLatitude() {
154155
return latitude;
155156
}
157+
158+
public Uri getGmmIntentUri() {
159+
return Uri.parse("geo:0,0?q=" + latitude + "," + longitude);
160+
}
156161
}

app/src/main/java/fr/free/nrw/commons/nearby/Place.java

+12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ public void setDistance(String distance) {
4646
this.distance = distance;
4747
}
4848

49+
public boolean hasWikipediaLink() {
50+
return !(siteLinks == null || Uri.EMPTY.equals(siteLinks.getWikipediaLink()));
51+
}
52+
53+
public boolean hasWikidataLink() {
54+
return !(siteLinks == null || Uri.EMPTY.equals(siteLinks.getWikidataLink()));
55+
}
56+
57+
public boolean hasCommonsLink() {
58+
return !(siteLinks == null || Uri.EMPTY.equals(siteLinks.getCommonsLink()));
59+
}
60+
4961
@Override
5062
public boolean equals(Object o) {
5163
if (o instanceof Place) {

0 commit comments

Comments
 (0)