Minor code reformatting

This commit is contained in:
misaochan 2016-01-07 17:51:27 +13:00
parent ab7db68d6c
commit b5ee6e3c5e
3 changed files with 1 additions and 16 deletions

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.caching; package fr.free.nrw.commons.caching;
import android.content.Context;
import android.util.Log; import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
@ -29,7 +28,6 @@ public class CacheController {
} }
public void cacheCategory() { public void cacheCategory() {
List<String> pointCatList = new ArrayList<String>(); List<String> pointCatList = new ArrayList<String>();
if (MwVolleyApi.GpsCatExists.getGpsCatExists() == true) { if (MwVolleyApi.GpsCatExists.getGpsCatExists() == true) {
pointCatList.addAll(MwVolleyApi.getGpsCat()); pointCatList.addAll(MwVolleyApi.getGpsCat());
@ -41,7 +39,6 @@ public class CacheController {
} }
public ArrayList findCategory() { public ArrayList findCategory() {
//Convert decLatitude and decLongitude to a coordinate offset range //Convert decLatitude and decLongitude to a coordinate offset range
convertCoordRange(); convertCoordRange();
pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus); pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus);
@ -51,7 +48,6 @@ public class CacheController {
ArrayList<String> flatCatList = new ArrayList<String>(); ArrayList<String> flatCatList = new ArrayList<String>();
if (pointsFound.length != 0) { if (pointsFound.length != 0) {
Log.d(TAG, "Entering for loop"); Log.d(TAG, "Entering for loop");
int index = 0; int index = 0;
for (Point point : pointsFound) { 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 //FIXME: temporary, can't figure out why for loop always only accesses 1 point
flatCatList = ((ArrayList<String>)displayCatList.get(0)); flatCatList = ((ArrayList<String>)displayCatList.get(0));
Log.d(TAG, "Categories found in cache: " + flatCatList.toString()); Log.d(TAG, "Categories found in cache: " + flatCatList.toString());
} else { } else {
Log.d(TAG, "No categories found in cache"); Log.d(TAG, "No categories found in cache");
@ -70,8 +67,6 @@ public class CacheController {
return flatCatList; return flatCatList;
} }
public void convertCoordRange() { public void convertCoordRange() {
//Position, decimal degrees //Position, decimal degrees
double lat = y; double lat = y;

View file

@ -44,7 +44,6 @@ public class MwVolleyApi {
categorySet = new HashSet<String>(); categorySet = new HashSet<String>();
} }
//To get the list of categories for display
public static List<String> getGpsCat() { public static List<String> getGpsCat() {
return categoryList; return categoryList;
} }
@ -55,9 +54,7 @@ public class MwVolleyApi {
Log.d(TAG, "Setting GPS cats from cache: " + categoryList.toString()); Log.d(TAG, "Setting GPS cats from cache: " + categoryList.toString());
} }
public void request(String coords) { public void request(String coords) {
coordsLog = coords; coordsLog = coords;
String apiUrl = buildUrl(coords); String apiUrl = buildUrl(coords);
Log.d("Image", "URL: " + apiUrl); Log.d("Image", "URL: " + apiUrl);

View file

@ -182,7 +182,6 @@ public class ShareActivity
} else { } else {
source = Contribution.SOURCE_EXTERNAL; source = Contribution.SOURCE_EXTERNAL;
} }
mimeType = intent.getType(); mimeType = intent.getType();
} }
@ -195,15 +194,11 @@ public class ShareActivity
//Using global singleton to get CacheController to last longer than the activity lifecycle //Using global singleton to get CacheController to last longer than the activity lifecycle
cacheObj = ((CommonsApplication)this.getApplication()); cacheObj = ((CommonsApplication)this.getApplication());
if (filePath != null) { if (filePath != null) {
//extract the coordinates of image in decimal degrees //extract the coordinates of image in decimal degrees
Log.d(TAG, "Calling GPSExtractor"); Log.d(TAG, "Calling GPSExtractor");
GPSExtractor imageObj = new GPSExtractor(filePath); GPSExtractor imageObj = new GPSExtractor(filePath);
//decimalCoords for MediaWiki API, xyCoords for Quadtree
String decimalCoords = imageObj.getCoords(); String decimalCoords = imageObj.getCoords();
double decLongitude = imageObj.getDecLongitude(); double decLongitude = imageObj.getDecLongitude();
double decLatitude = imageObj.getDecLatitude(); double decLatitude = imageObj.getDecLatitude();
@ -216,14 +211,12 @@ public class ShareActivity
List displayCatList = cacheObj.cacheData.findCategory(); List displayCatList = cacheObj.cacheData.findCategory();
//if no categories found in cache, call MW API to match image coords with nearby Commons categories //if no categories found in cache, call MW API to match image coords with nearby Commons categories
if (displayCatList.size() == 0) { if (displayCatList.size() == 0) {
cacheFound = false; cacheFound = false;
apiCall.request(decimalCoords); apiCall.request(decimalCoords);
Log.d(TAG, "displayCatList size 0, calling MWAPI" + displayCatList.toString()); Log.d(TAG, "displayCatList size 0, calling MWAPI" + displayCatList.toString());
} else { } 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; cacheFound = true;
Log.d(TAG, "Cache found, setting categoryList in MwVolleyApi to " + displayCatList.toString()); Log.d(TAG, "Cache found, setting categoryList in MwVolleyApi to " + displayCatList.toString());
MwVolleyApi.setGpsCat(displayCatList); MwVolleyApi.setGpsCat(displayCatList);