mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Strip string for categories and add them to a Place
This commit is contained in:
parent
2c6b6f9bea
commit
8133ba1d23
3 changed files with 21 additions and 4 deletions
|
|
@ -580,6 +580,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
SharedPreferences.Editor editor = directPrefs.edit();
|
||||
editor.putString("Title", place.getName());
|
||||
editor.putString("Desc", place.getLongDescription());
|
||||
editor.putString("Category", place.getCategory());
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import java.io.InputStreamReader;
|
|||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
|
@ -99,14 +100,24 @@ public class NearbyPlaces {
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Fields: ["Point(153.073 -27.6111)"^^<http://www.opengis.net/ont/geosparql#wktLiteral>, <http://www.wikidata.org/entity/Q7271010>, "Queensland State Archives"@en, <http://www.wikidata.org/entity/Q327333>, "government agency"@en, , , Images from the Queensland State Archives, <https://en.wikipedia.org/wiki/Queensland_State_Archives>, <https://commons.wikimedia.org/wiki/Category:Images_from_the_Queensland_State_Archives>
|
||||
// Produces: 02-11 21:32:45.015: V/NearbyPlaces(9300): Name: Queensland State Archives, type: government agency, category: Images from the Queensland State Archives, wikipediaSitelink: <https://en.wikipedia.org/wiki/Queensland_State_Archives>, commonsSitelink: <https://commons.wikimedia.org/wiki/Category:Images_from_the_Queensland_State_Archives>
|
||||
|
||||
//TODO: What about items with more than 1 Commons category??? Might need to rearrange categories to the end of the string
|
||||
|
||||
String[] fields = line.split("\t");
|
||||
Timber.v("Fields: " + Arrays.toString(fields));
|
||||
String point = fields[0];
|
||||
String wikiDataLink = Utils.stripLocalizedString(fields[1]);
|
||||
String name = Utils.stripLocalizedString(fields[2]);
|
||||
String type = Utils.stripLocalizedString(fields[4]);
|
||||
String wikipediaSitelink = Utils.stripLocalizedString(fields[7]);
|
||||
String commonsSitelink = Utils.stripLocalizedString(fields[8]);
|
||||
String wikiDataLink = Utils.stripLocalizedString(fields[1]);
|
||||
String icon = fields[5];
|
||||
String category = Utils.stripLocalizedString(fields[7]);
|
||||
String wikipediaSitelink = Utils.stripLocalizedString(fields[8]);
|
||||
String commonsSitelink = Utils.stripLocalizedString(fields[9]);
|
||||
|
||||
Timber.v("Name: " + name + ", type: " + type + ", category: " + category + ", wikipediaSitelink: " + wikipediaSitelink + ", commonsSitelink: " + commonsSitelink);
|
||||
|
||||
double latitude;
|
||||
double longitude;
|
||||
|
|
@ -128,6 +139,7 @@ public class NearbyPlaces {
|
|||
type, // details
|
||||
Uri.parse(icon),
|
||||
new LatLng(latitude, longitude, 0),
|
||||
category,
|
||||
new Sitelinks.Builder()
|
||||
.setWikipediaLink(wikipediaSitelink)
|
||||
.setCommonsLink(commonsSitelink)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public class Place {
|
|||
private final String longDescription;
|
||||
private final Uri secondaryImageUrl;
|
||||
public final LatLng location;
|
||||
private final String category;
|
||||
|
||||
public Bitmap image;
|
||||
public Bitmap secondaryImage;
|
||||
|
|
@ -25,12 +26,13 @@ public class Place {
|
|||
|
||||
|
||||
public Place(String name, Label label, String longDescription,
|
||||
Uri secondaryImageUrl, LatLng location, Sitelinks siteLinks) {
|
||||
Uri secondaryImageUrl, LatLng location, String category, Sitelinks siteLinks) {
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.longDescription = longDescription;
|
||||
this.secondaryImageUrl = secondaryImageUrl;
|
||||
this.location = location;
|
||||
this.category = category;
|
||||
this.siteLinks = siteLinks;
|
||||
}
|
||||
|
||||
|
|
@ -42,6 +44,8 @@ public class Place {
|
|||
|
||||
public String getLongDescription() { return longDescription; }
|
||||
|
||||
public String getCategory() {return category; }
|
||||
|
||||
public void setDistance(String distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue