private static RequestQueue getInternalQueue(Context context) { if (internalQueue == null) { synchronized (Factory.class) { if (internalQueue == null) { internalQueue = Volley.newRequestQueue(context); } } } return internalQueue; } }
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context) { return newRequestQueue(context, null); }
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @param stack An {@link HttpStack} to use for the network, or null for default. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context, HttpStack stack) { return newRequestQueue(context, stack, -1); }
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link android.content.Context} to use for creating the cache dir. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context) { return newRequestQueue(context, null); } }
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * You may set a maximum size of the disk cache in bytes. * * @param context A {@link Context} to use for creating the cache dir. * @param maxDiskCacheBytes the maximum size of the disk cache, in bytes. Use -1 for default size. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context, int maxDiskCacheBytes) { return newRequestQueue(context, null, maxDiskCacheBytes); }
public static void init(Context context) { mRequestQueue = Volley.newRequestQueue(context); }
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context) { return newRequestQueue(context, null); } }
public static RequestQueue getInstace(Context pContext){ if(instance==null){ instance= Volley.newRequestQueue(pContext); } return instance; } }
public static RequestQueue getRequestQueue() { if (sRequestQueue == null) { sRequestQueue = Volley.newRequestQueue(sContext); } return sRequestQueue; } }
private Api(Context context) { this.requestQueue = Volley.newRequestQueue(context.getApplicationContext()); QueryListener queryListener = new QueryListener() { @Override public void onSearchCompleted(Query query, List<Photo> photos) { lastQueryResult = new QueryResult(query, photos); } @Override public void onSearchFailed(Query query, Exception e) { lastQueryResult = null; } }; queryListeners.add(queryListener); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestQueue=Volley.newRequestQueue(this); } @Click({R.id.top_bar_linear_back,R.id.btn_string,R.id.btn_json,R.id.btn_image_request,R.id.btn_image_loader,R.id.btn_image_network,R.id.btn_string_post,R.id.btn_loader_list,R.id.btn_gson,R.id.btn_fdv_get_params,R.id.btn_fdv_post_params})
private VolleyManager(Context ctxt) { queue=Volley.newRequestQueue(ctxt); imageLoader=new ImageLoader(queue, new LruBitmapCache(ctxt)); }
@Before public void setUp() throws IOException { MockitoAnnotations.initMocks(this); waitForResponseLatch = new CountDownLatch(1); doAnswer(new CountDown()).when(callback).onDataReady(any(InputStream.class)); doAnswer(new CountDown()).when(callback).onLoadFailed(any(Exception.class)); requestQueue = Volley.newRequestQueue(RuntimeEnvironment.application); mockWebServer = new MockWebServer(); mockWebServer.start(); streamCaptor = ArgumentCaptor.forClass(InputStream.class); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestQueue= Volley.newRequestQueue(this); imageLoader=new ImageLoader(requestQueue,new Fdv_ImageCache()); } @AfterViews
private RequestQueue getVolleyQueue() { if (sVolleyQueue == null) { Context context = mContext.getApplicationContext(); sVolleyQueue = Volley.newRequestQueue(context, new NetworkStack()); } return sVolleyQueue; }
private void sendMsg() { RequestQueue queue = Volley.newRequestQueue(getContext()); StringRequest request = new StringRequest(Request.Method.POST, "http://ar.qsboy.com/j/applyCaptcha", response -> { Log.i(TAG, "sendMsg: " + response); captcha = response; }, error -> Log.e(TAG, "sendMsg: " + error)) { @Override protected Map<String, String> getParams() { Map<String, String> map = new HashMap<>(); map.put("phone", phone); return map; } }; queue.add(request); }
/** * 支付宝支付业务 */ public void pay(String type) { StringRequest request = new StringRequest(Request.Method.POST, "http://ar.qsboy.com/j/pay", response -> { Log.i(TAG, "sendMsg: " + response); Runnable payRunnable = () -> { PayTask alipay = new PayTask(activity); Map<String, String> result = alipay.payV2(response, true); Log.i("msp", result.toString()); Message msg = new Message(); msg.what = SDK_PAY_FLAG; msg.obj = result; mHandler.sendMessage(msg); }; Thread payThread = new Thread(payRunnable); payThread.start(); }, error -> Log.e(TAG, "sendMsg: " + error)) { @Override protected Map<String, String> getParams() { Map<String, String> map = new HashMap<>(); map.put("type", type); return map; } }; RequestQueue queue = Volley.newRequestQueue(activity); queue.add(request); }
private boolean verifyCaptcha(String captcha) { RequestQueue queue = Volley.newRequestQueue(getContext()); RequestFuture future = RequestFuture.newFuture(); StringRequest request = new StringRequest(Request.Method.POST, "http://ar.qsboy.com/j/verifyCaptcha", future, future) { @Override protected Map<String, String> getParams() { Map<String, String> map = new HashMap<>(); map.put("phone", phone); map.put("captcha", captcha); return map; } }; queue.add(request); try { String s = (String) future.get(5, TimeUnit.SECONDS); boolean isValid = s != null && s.length() > 0; if (isValid) { Gson gson = new Gson(); gson.fromJson(s, App.User.class); } return isValid; } catch (InterruptedException | ExecutionException | TimeoutException e) { e.printStackTrace(); return false; } }
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context) { return newRequestQueue(context, null); }
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @param stack An {@link HttpStack} to use for the network, or null for default. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context, HttpStack stack) { return newRequestQueue(context, stack, -1); }