Don't pass Activity into MwVolleyApi.

This commit is contained in:
Dmitry Brant 2017-05-26 16:20:55 -04:00
parent b07432fce2
commit bb5a6691f1
2 changed files with 4 additions and 10 deletions

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.upload; package fr.free.nrw.commons.upload;
import android.content.Context;
import android.net.Uri; import android.net.Uri;
import com.android.volley.Cache; import com.android.volley.Cache;
@ -21,6 +20,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import fr.free.nrw.commons.CommonsApplication;
import timber.log.Timber; import timber.log.Timber;
/** /**
@ -32,15 +32,13 @@ public class MwVolleyApi {
private static RequestQueue REQUEST_QUEUE; private static RequestQueue REQUEST_QUEUE;
private static final Gson GSON = new GsonBuilder().create(); private static final Gson GSON = new GsonBuilder().create();
private Context context;
protected static Set<String> categorySet; protected static Set<String> categorySet;
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/";
public MwVolleyApi(Context context) { public MwVolleyApi() {
this.context = context;
categorySet = new HashSet<>(); categorySet = new HashSet<>();
} }
@ -94,12 +92,8 @@ public class MwVolleyApi {
} }
private synchronized RequestQueue getQueue() { private synchronized RequestQueue getQueue() {
return getQueue(context);
}
private static RequestQueue getQueue(Context context) {
if (REQUEST_QUEUE == null) { if (REQUEST_QUEUE == null) {
REQUEST_QUEUE = Volley.newRequestQueue(context); REQUEST_QUEUE = Volley.newRequestQueue(CommonsApplication.getInstance());
} }
return REQUEST_QUEUE; return REQUEST_QUEUE;
} }

View file

@ -402,7 +402,7 @@ public class ShareActivity
app.getCacheData().setQtPoint(decLongitude, decLatitude); app.getCacheData().setQtPoint(decLongitude, decLatitude);
} }
MwVolleyApi apiCall = new MwVolleyApi(this); MwVolleyApi apiCall = new MwVolleyApi();
List<String> displayCatList = app.getCacheData().findCategory(); List<String> displayCatList = app.getCacheData().findCategory();
boolean catListEmpty = displayCatList.isEmpty(); boolean catListEmpty = displayCatList.isEmpty();