mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Added if cache found logic
This commit is contained in:
parent
0a33dc5dae
commit
85f0ae2a15
2 changed files with 21 additions and 10 deletions
|
|
@ -34,6 +34,7 @@ public class MwVolleyApi {
|
||||||
private String coordsLog;
|
private String coordsLog;
|
||||||
|
|
||||||
protected static Set<String> categorySet;
|
protected static Set<String> categorySet;
|
||||||
|
private static List<String> categoryList;
|
||||||
|
|
||||||
private static final String MWURL = "https://commons.wikimedia.org/";
|
private static final String MWURL = "https://commons.wikimedia.org/";
|
||||||
|
|
||||||
|
|
@ -44,8 +45,12 @@ public class MwVolleyApi {
|
||||||
|
|
||||||
//To get the list of categories for display
|
//To get the list of categories for display
|
||||||
public static List<String> getGpsCat() {
|
public static List<String> getGpsCat() {
|
||||||
List<String> list = new ArrayList<String>(categorySet);
|
categoryList = new ArrayList<String>(categorySet);
|
||||||
return list;
|
return categoryList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setGpsCat(List cachedList) {
|
||||||
|
categoryList = new ArrayList<String>(cachedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,11 @@ public class ShareActivity
|
||||||
public void uploadActionInitiated(String title, String description) {
|
public void uploadActionInitiated(String title, String description) {
|
||||||
Toast startingToast = Toast.makeText(getApplicationContext(), R.string.uploading_started, Toast.LENGTH_LONG);
|
Toast startingToast = Toast.makeText(getApplicationContext(), R.string.uploading_started, Toast.LENGTH_LONG);
|
||||||
startingToast.show();
|
startingToast.show();
|
||||||
|
|
||||||
//Has to be called after apiCall.request()
|
//Has to be called after apiCall.request()
|
||||||
cacheObj.cacheData.cacheCategory();
|
cacheObj.cacheData.cacheCategory();
|
||||||
|
Log.d("Cache", "Cache the categories found");
|
||||||
|
|
||||||
uploadController.startUpload(title, mediaUri, description, mimeType, source, new UploadController.ContributionUploadProgress() {
|
uploadController.startUpload(title, mediaUri, description, mimeType, source, new UploadController.ContributionUploadProgress() {
|
||||||
public void onUploadStarted(Contribution contribution) {
|
public void onUploadStarted(Contribution contribution) {
|
||||||
ShareActivity.this.contribution = contribution;
|
ShareActivity.this.contribution = contribution;
|
||||||
|
|
@ -203,16 +206,19 @@ public class ShareActivity
|
||||||
Log.d("Coords", "Decimal coords of image: " + decimalCoords);
|
Log.d("Coords", "Decimal coords of image: " + decimalCoords);
|
||||||
cacheObj.cacheData.setQtPoint(decLongitude, decLatitude);
|
cacheObj.cacheData.setQtPoint(decLongitude, decLatitude);
|
||||||
|
|
||||||
|
MwVolleyApi apiCall = new MwVolleyApi(this);
|
||||||
|
|
||||||
List displayCatList = cacheObj.cacheData.findCategory();
|
List displayCatList = cacheObj.cacheData.findCategory();
|
||||||
|
|
||||||
//TODO: If categories found from cache in that area, skip API call and display those categories instead
|
//if no categories found in cache, call MW API to match image coords with nearby Commons categories
|
||||||
|
if (displayCatList.size() == 0) {
|
||||||
//TODO: If no categories found from cache in that area, call MW API
|
apiCall.request(decimalCoords);
|
||||||
|
Log.d("Cache", "displayCatList size 0, calling MWAPI");
|
||||||
//asynchronous calls to MediaWiki Commons API to match image coords with nearby Commons categories
|
} else {
|
||||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
//TODO: Set categoryList in MwVolleyApi
|
||||||
apiCall.request(decimalCoords);
|
MwVolleyApi.setGpsCat(displayCatList);
|
||||||
|
Log.d("Cache", "Cache found, setting categoryList in MwVolleyApi to " + displayCatList.toString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue