mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
CacheController backbone up
For area category caching logic
This commit is contained in:
parent
09505c0c17
commit
dcd5d60002
3 changed files with 30 additions and 2 deletions
|
|
@ -0,0 +1,23 @@
|
|||
package fr.free.nrw.commons.caching;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Created by misao on 05-Jan-16.
|
||||
*/
|
||||
public class CacheController {
|
||||
|
||||
private Context context;
|
||||
private String coords;
|
||||
|
||||
public CacheController(Context context, String coords) {
|
||||
this.context = context;
|
||||
this.coords = coords;
|
||||
}
|
||||
|
||||
public String getCoords() {
|
||||
Log.d("Cache", "Coords passed to cache: " + coords);
|
||||
return coords;
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +68,8 @@ public class GPSExtractor {
|
|||
decLongitude = 0 - convertToDegree(longitude);
|
||||
}
|
||||
|
||||
return (String.valueOf(decLatitude) + "|" + String.valueOf(decLongitude));
|
||||
//Have to return Longitude before Latitude for X/Y conversion. Long = X; Lat = Y
|
||||
return ("Long|Lat" + String.valueOf(decLongitude) + "|" + String.valueOf(decLatitude));
|
||||
}
|
||||
|
||||
private double convertToDegree(String stringDMS){
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import android.util.Log;
|
|||
import android.widget.*;
|
||||
|
||||
import fr.free.nrw.commons.*;
|
||||
import fr.free.nrw.commons.caching.CacheController;
|
||||
import fr.free.nrw.commons.modifications.CategoryModifier;
|
||||
import fr.free.nrw.commons.modifications.TemplateRemoveModifier;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
|
|
@ -188,9 +189,12 @@ public class ShareActivity
|
|||
Log.d("Image", "Coords of image: " + coords);
|
||||
|
||||
//TODO: Insert cache query here, only send API request if no cached categories
|
||||
CacheController cacheObj = new CacheController(this, coords);
|
||||
cacheObj.getCoords();
|
||||
|
||||
|
||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
||||
//asynchronous calls to MediaWiki Commons API to match image coords with nearby Commons categories
|
||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
||||
apiCall.request(coords);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue