Replaced TAGs in logs

This commit is contained in:
misaochan 2016-01-07 17:33:35 +13:00
parent 207ee2bfac
commit 9c58e28371
3 changed files with 28 additions and 18 deletions

View file

@ -15,6 +15,8 @@ public class CacheController {
private Point[] pointsFound; private Point[] pointsFound;
private double xMinus, xPlus, yMinus, yPlus; private double xMinus, xPlus, yMinus, yPlus;
private static final String TAG = CacheController.class.getName();
public CacheController() { public CacheController() {
quadTree = new QuadTree(-180, -90, +180, +90); quadTree = new QuadTree(-180, -90, +180, +90);
} }
@ -22,8 +24,8 @@ public class CacheController {
public void setQtPoint(double decLongitude, double decLatitude) { public void setQtPoint(double decLongitude, double decLatitude) {
x = decLongitude; x = decLongitude;
y = decLatitude; y = decLatitude;
Log.d("Cache", "New QuadTree created"); Log.d(TAG, "New QuadTree created");
Log.d("Cache", "X (longitude) value: " + x + ", Y (latitude) value: " + y); Log.d(TAG, "X (longitude) value: " + x + ", Y (latitude) value: " + y);
} }
public void cacheCategory() { public void cacheCategory() {
@ -31,9 +33,9 @@ public class CacheController {
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());
Log.d("Cache", "Categories being cached: " + pointCatList); Log.d(TAG, "Categories being cached: " + pointCatList);
} else { } else {
Log.d("Cache", "No categories found, so no categories cached"); Log.d(TAG, "No categories found, so no categories cached");
} }
quadTree.set(x, y, pointCatList); quadTree.set(x, y, pointCatList);
} }
@ -44,26 +46,26 @@ public class CacheController {
convertCoordRange(); convertCoordRange();
pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus); pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus);
ArrayList displayCatList = new ArrayList(); ArrayList displayCatList = new ArrayList();
Log.d("Cache", "Points found in quadtree: " + pointsFound); Log.d(TAG, "Points found in quadtree: " + pointsFound);
ArrayList<String> flatCatList = new ArrayList<String>(); ArrayList<String> flatCatList = new ArrayList<String>();
if (pointsFound.length != 0) { if (pointsFound.length != 0) {
Log.d("Cache", "Entering for loop"); Log.d(TAG, "Entering for loop");
int index = 0; int index = 0;
for (Point point : pointsFound) { for (Point point : pointsFound) {
Log.d("Cache", "Nearby point: " + point.toString()); Log.d(TAG, "Nearby point: " + point.toString());
Object cat = point.getValue(); Object cat = point.getValue();
Log.d("Cache", "Nearby cat: " + cat); Log.d(TAG, "Nearby cat: " + cat);
displayCatList.add(index, cat); displayCatList.add(index, cat);
index++; index++;
} }
//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("Cache", "Categories found in cache: " + flatCatList.toString()); Log.d(TAG, "Categories found in cache: " + flatCatList.toString());
} else { } else {
Log.d("Cache", "No categories found in cache"); Log.d(TAG, "No categories found in cache");
} }
return flatCatList; return flatCatList;
} }
@ -89,6 +91,6 @@ public class CacheController {
yMinus = lat - dLat * 180/Math.PI; yMinus = lat - dLat * 180/Math.PI;
xPlus = lon + dLon * 180/Math.PI; xPlus = lon + dLon * 180/Math.PI;
xMinus = lon - dLon * 180/Math.PI; xMinus = lon - dLon * 180/Math.PI;
Log.d("Cache", "Search within: xMinus=" + xMinus + ", yMinus=" + yMinus + ", xPlus=" + xPlus + ", yPlus=" + yPlus); Log.d(TAG, "Search within: xMinus=" + xMinus + ", yMinus=" + yMinus + ", xPlus=" + xPlus + ", yPlus=" + yPlus);
} }
} }

View file

@ -37,6 +37,7 @@ public class MwVolleyApi {
private static List<String> categoryList; private static List<String> categoryList;
private static final String MWURL = "https://commons.wikimedia.org/"; private static final String MWURL = "https://commons.wikimedia.org/";
private static final String TAG = MwVolleyApi.class.getName();
public MwVolleyApi(Context context) { public MwVolleyApi(Context context) {
this.context = context; this.context = context;
@ -52,7 +53,7 @@ public class MwVolleyApi {
public static void setGpsCat(List cachedList) { public static void setGpsCat(List cachedList) {
categoryList = new ArrayList<String>(); categoryList = new ArrayList<String>();
categoryList.addAll(cachedList); categoryList.addAll(cachedList);
Log.d("Cache", "Setting GPS cats from cache: " + categoryList.toString()); Log.d(TAG, "Setting GPS cats from cache: " + categoryList.toString());
} }

View file

@ -49,6 +49,9 @@ public class ShareActivity
private UploadController uploadController; private UploadController uploadController;
private CommonsApplication cacheObj; private CommonsApplication cacheObj;
private boolean cacheFound;
private static final String TAG = ShareActivity.class.getName();
public ShareActivity() { public ShareActivity() {
super(WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE); super(WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE);
@ -58,9 +61,11 @@ public class ShareActivity
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() if (cacheFound == false) {
cacheObj.cacheData.cacheCategory(); //Has to be called after apiCall.request()
Log.d("Cache", "Cache the categories found"); 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) {
@ -213,12 +218,14 @@ public class ShareActivity
//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;
apiCall.request(decimalCoords); apiCall.request(decimalCoords);
Log.d("Cache", "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 //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("Cache", "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);
} }