From 7c85dd391d67d7d66e47ab96fdea4e1fcd966034 Mon Sep 17 00:00:00 2001 From: misaochan Date: Sat, 2 Jan 2016 16:22:39 +1300 Subject: [PATCH] Rearranged some classes --- .../free/nrw/commons/upload/MwVolleyApi.java | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/commons/src/main/java/fr/free/nrw/commons/upload/MwVolleyApi.java b/commons/src/main/java/fr/free/nrw/commons/upload/MwVolleyApi.java index b3d82709c..ac6d4eaa1 100644 --- a/commons/src/main/java/fr/free/nrw/commons/upload/MwVolleyApi.java +++ b/commons/src/main/java/fr/free/nrw/commons/upload/MwVolleyApi.java @@ -39,30 +39,6 @@ public class MwVolleyApi { categorySet = new HashSet(); } - //To get the list of categories for display - public static List getGpsCat() { - List list = new ArrayList(categorySet); - return list; - } - - public void request(String coords) { - - //If <10 categories found, repeat API call with incremented radius - for (int radius=100; radius<=10000; radius=radius*10) { - String apiUrl = buildUrl(coords, radius); - Log.d("Repeat", "URL: " + apiUrl); - - JsonRequest request = new QueryRequest(apiUrl, - new LogResponseListener(), new LogResponseErrorListener()); - getQueue().add(request); - Log.d("Repeat", "Repeating API call with radius " + Integer.toString(radius)); - - if (categorySet.size()>=10) { - break; - } - } - } - /** * Builds URL with image coords for MediaWiki API calls * Example URL: https://commons.wikimedia.org/w/api.php?action=query&prop=categories|coordinates|pageprops&format=json&clshow=!hidden&coprop=type|name|dim|country|region|globe&codistancefrompoint=38.11386944444445|13.356263888888888& @@ -92,6 +68,42 @@ public class MwVolleyApi { return builder.toString(); } + //To get the list of categories for display + public static List getGpsCat() { + List list = new ArrayList(categorySet); + return list; + } + + public static class GpsCatExists { + private static boolean gpsCatExists; + + public static void setGpsCatExists(boolean gpsCat) { + gpsCatExists = gpsCat; + } + + public static boolean getGpsCatExists() { + return gpsCatExists; + } + } + + public void request(String coords) { + + //If <10 categories found, repeat API call with incremented radius + for (int radius=100; radius<=10000; radius=radius*10) { + String apiUrl = buildUrl(coords, radius); + Log.d("Repeat", "URL: " + apiUrl); + + JsonRequest request = new QueryRequest(apiUrl, + new LogResponseListener(), new LogResponseErrorListener()); + getQueue().add(request); + Log.d("Repeat", "Repeating API call with radius " + Integer.toString(radius)); + + if (categorySet.size()>=10) { + break; + } + } + } + private synchronized RequestQueue getQueue() { return getQueue(context); } @@ -150,18 +162,6 @@ public class MwVolleyApi { } } - public static class GpsCatExists { - private static boolean gpsCatExists; - - public static void setGpsCatExists(boolean gpsCat) { - gpsCatExists = gpsCat; - } - - public static boolean getGpsCatExists() { - return gpsCatExists; - } - } - private static class QueryResponse { private Query query = new Query(); @@ -234,7 +234,7 @@ public class MwVolleyApi { } } - private static class Category { + private static class Category { private String title; @Override