mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Minor refactoring
Make buildURL private
This commit is contained in:
parent
4a400df5dd
commit
38cf720b4b
2 changed files with 13 additions and 13 deletions
|
|
@ -30,12 +30,23 @@ public class MwVolleyApi {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void request(String coords) {
|
||||||
|
|
||||||
|
String apiUrl = buildUrl(coords);
|
||||||
|
Log.d("Image", "URL: " + apiUrl);
|
||||||
|
|
||||||
|
JsonRequest<QueryResponse> request = new QueryRequest(apiUrl,
|
||||||
|
new LogResponseListener<QueryResponse>(), new LogResponseErrorListener());
|
||||||
|
getQueue().add(request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds URL with image coords for MediaWiki API calls
|
* Builds URL with image coords for MediaWiki API calls
|
||||||
* Example URL: https://commons.wikimedia.org/w/api.php?action=query&prop=categories|coordinates|pageprops&format=json&clshow=!hidden&coprop=type|name|dim|country|region|globe&codistancefrompoint=38.11386944444445|13.356263888888888&
|
* Example URL: https://commons.wikimedia.org/w/api.php?action=query&prop=categories|coordinates|pageprops&format=json&clshow=!hidden&coprop=type|name|dim|country|region|globe&codistancefrompoint=38.11386944444445|13.356263888888888&
|
||||||
* generator=geosearch&redirects=&ggscoord=38.11386944444445|13.356263888888888&ggsradius=100&ggslimit=10&ggsnamespace=6&ggsprop=type|name|dim|country|region|globe&ggsprimary=all&formatversion=2
|
* generator=geosearch&redirects=&ggscoord=38.11386944444445|13.356263888888888&ggsradius=100&ggslimit=10&ggsnamespace=6&ggsprop=type|name|dim|country|region|globe&ggsprimary=all&formatversion=2
|
||||||
*/
|
*/
|
||||||
public String buildUrl (String coords){
|
private String buildUrl (String coords){
|
||||||
|
|
||||||
Uri.Builder builder = Uri.parse("https://commons.wikimedia.org/").buildUpon();
|
Uri.Builder builder = Uri.parse("https://commons.wikimedia.org/").buildUpon();
|
||||||
|
|
||||||
|
|
@ -60,13 +71,6 @@ public class MwVolleyApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void request(String apiUrl) {
|
|
||||||
|
|
||||||
JsonRequest<QueryResponse> request = new QueryRequest(apiUrl,
|
|
||||||
new LogResponseListener<QueryResponse>(), new LogResponseErrorListener());
|
|
||||||
getQueue().add(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized RequestQueue getQueue() {
|
private synchronized RequestQueue getQueue() {
|
||||||
return getQueue(context);
|
return getQueue(context);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -188,12 +188,8 @@ public class ShareActivity
|
||||||
Log.d("Image", "Coords of image: " + coords);
|
Log.d("Image", "Coords of image: " + coords);
|
||||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
MwVolleyApi apiCall = new MwVolleyApi(this);
|
||||||
|
|
||||||
//build URL with image coords for MediaWiki API calls
|
|
||||||
String apiUrl = apiCall.buildUrl(coords);
|
|
||||||
Log.d("Image", "URL: " + apiUrl);
|
|
||||||
|
|
||||||
//asynchronous calls to MediaWiki Commons API to match image coords with nearby Commons categories
|
//asynchronous calls to MediaWiki Commons API to match image coords with nearby Commons categories
|
||||||
apiCall.request(apiUrl);
|
apiCall.request(coords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue