CacheController backbone up

For area category caching logic
This commit is contained in:
misaochan 2016-01-05 18:30:10 +13:00
parent 09505c0c17
commit dcd5d60002
3 changed files with 30 additions and 2 deletions

View file

@ -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;
}
}

View file

@ -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){

View file

@ -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);
}
}