mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-03 08:13:55 +01:00
Added template for RequestQueue singleton
This commit is contained in:
parent
898f98851d
commit
c60c886708
3 changed files with 64 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
package fr.free.nrw.commons.upload;
|
||||
|
||||
/**
|
||||
* Created by misao on 03-Jan-16.
|
||||
*/
|
||||
public class MwVolley {
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package fr.free.nrw.commons.upload;
|
|||
|
||||
import android.content.*;
|
||||
import android.os.*;
|
||||
|
||||
import com.android.volley.Response;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import android.net.*;
|
||||
import android.support.v4.app.NavUtils;
|
||||
|
|
@ -10,6 +12,8 @@ import com.actionbarsherlock.view.MenuItem;
|
|||
import android.util.Log;
|
||||
import android.widget.*;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import fr.free.nrw.commons.*;
|
||||
import fr.free.nrw.commons.modifications.CategoryModifier;
|
||||
import fr.free.nrw.commons.modifications.TemplateRemoveModifier;
|
||||
|
|
@ -203,6 +207,13 @@ public class ShareActivity
|
|||
requestAuthToken();
|
||||
}
|
||||
|
||||
private class ResponseListener<T> implements Response.Listener<T>{
|
||||
@Override
|
||||
public void onResponse(T response){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package fr.free.nrw.commons.upload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.LruCache;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.toolbox.ImageLoader;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
|
||||
/**
|
||||
* Created by misao on 03-Jan-16.
|
||||
*/
|
||||
public class VolleyRequestQueue {
|
||||
private static VolleyRequestQueue mInstance;
|
||||
private RequestQueue mRequestQueue;
|
||||
private ImageLoader mImageLoader;
|
||||
private static Context mContext;
|
||||
|
||||
private VolleyRequestQueue(Context context) {
|
||||
mContext = context;
|
||||
mRequestQueue = getRequestQueue();
|
||||
}
|
||||
|
||||
public static synchronized VolleyRequestQueue getInstance(Context context) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new VolleyRequestQueue(context);
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
public RequestQueue getRequestQueue() {
|
||||
if (mRequestQueue == null) {
|
||||
// getApplicationContext() is key, it keeps you from leaking the
|
||||
// Activity or BroadcastReceiver if someone passes one in.
|
||||
mRequestQueue = Volley.newRequestQueue(mContext.getApplicationContext());
|
||||
}
|
||||
return mRequestQueue;
|
||||
}
|
||||
|
||||
public <T> void addToRequestQueue(Request<T> req) {
|
||||
getRequestQueue().add(req);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue