mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Minor code reformatting
This commit is contained in:
parent
ab7db68d6c
commit
b5ee6e3c5e
3 changed files with 1 additions and 16 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package fr.free.nrw.commons.caching;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -29,7 +28,6 @@ public class CacheController {
|
|||
}
|
||||
|
||||
public void cacheCategory() {
|
||||
|
||||
List<String> pointCatList = new ArrayList<String>();
|
||||
if (MwVolleyApi.GpsCatExists.getGpsCatExists() == true) {
|
||||
pointCatList.addAll(MwVolleyApi.getGpsCat());
|
||||
|
|
@ -41,7 +39,6 @@ public class CacheController {
|
|||
}
|
||||
|
||||
public ArrayList findCategory() {
|
||||
|
||||
//Convert decLatitude and decLongitude to a coordinate offset range
|
||||
convertCoordRange();
|
||||
pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus);
|
||||
|
|
@ -51,7 +48,6 @@ public class CacheController {
|
|||
ArrayList<String> flatCatList = new ArrayList<String>();
|
||||
|
||||
if (pointsFound.length != 0) {
|
||||
|
||||
Log.d(TAG, "Entering for loop");
|
||||
int index = 0;
|
||||
for (Point point : pointsFound) {
|
||||
|
|
@ -63,6 +59,7 @@ public class CacheController {
|
|||
}
|
||||
//FIXME: temporary, can't figure out why for loop always only accesses 1 point
|
||||
flatCatList = ((ArrayList<String>)displayCatList.get(0));
|
||||
|
||||
Log.d(TAG, "Categories found in cache: " + flatCatList.toString());
|
||||
} else {
|
||||
Log.d(TAG, "No categories found in cache");
|
||||
|
|
@ -70,8 +67,6 @@ public class CacheController {
|
|||
return flatCatList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void convertCoordRange() {
|
||||
//Position, decimal degrees
|
||||
double lat = y;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ public class MwVolleyApi {
|
|||
categorySet = new HashSet<String>();
|
||||
}
|
||||
|
||||
//To get the list of categories for display
|
||||
public static List<String> getGpsCat() {
|
||||
return categoryList;
|
||||
}
|
||||
|
|
@ -55,9 +54,7 @@ public class MwVolleyApi {
|
|||
Log.d(TAG, "Setting GPS cats from cache: " + categoryList.toString());
|
||||
}
|
||||
|
||||
|
||||
public void request(String coords) {
|
||||
|
||||
coordsLog = coords;
|
||||
String apiUrl = buildUrl(coords);
|
||||
Log.d("Image", "URL: " + apiUrl);
|
||||
|
|
|
|||
|
|
@ -182,7 +182,6 @@ public class ShareActivity
|
|||
} else {
|
||||
source = Contribution.SOURCE_EXTERNAL;
|
||||
}
|
||||
|
||||
mimeType = intent.getType();
|
||||
}
|
||||
|
||||
|
|
@ -195,15 +194,11 @@ public class ShareActivity
|
|||
//Using global singleton to get CacheController to last longer than the activity lifecycle
|
||||
cacheObj = ((CommonsApplication)this.getApplication());
|
||||
|
||||
|
||||
|
||||
if (filePath != null) {
|
||||
//extract the coordinates of image in decimal degrees
|
||||
Log.d(TAG, "Calling GPSExtractor");
|
||||
GPSExtractor imageObj = new GPSExtractor(filePath);
|
||||
//decimalCoords for MediaWiki API, xyCoords for Quadtree
|
||||
String decimalCoords = imageObj.getCoords();
|
||||
|
||||
double decLongitude = imageObj.getDecLongitude();
|
||||
double decLatitude = imageObj.getDecLatitude();
|
||||
|
||||
|
|
@ -216,14 +211,12 @@ public class ShareActivity
|
|||
List displayCatList = cacheObj.cacheData.findCategory();
|
||||
|
||||
//if no categories found in cache, call MW API to match image coords with nearby Commons categories
|
||||
|
||||
if (displayCatList.size() == 0) {
|
||||
cacheFound = false;
|
||||
apiCall.request(decimalCoords);
|
||||
Log.d(TAG, "displayCatList size 0, calling MWAPI" + displayCatList.toString());
|
||||
|
||||
} else {
|
||||
//TODO: Set categoryList in MwVolleyApi. Not filling up right. Maybe do global singleton for MwVolleyApi? Can't do that, we want new cats for each upload, so new instance of mwapi
|
||||
cacheFound = true;
|
||||
Log.d(TAG, "Cache found, setting categoryList in MwVolleyApi to " + displayCatList.toString());
|
||||
MwVolleyApi.setGpsCat(displayCatList);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue