Java 类com.android.volley.RequestQueue 实例源码

项目:IelloAndroidApp    文件:HelperRete.java   
/**
 * Effettua una web request sincrona tramite Volley API, restituendo in risposta
 * l'oggetto JSON scaricato.
 */
public static JSONObject volleySyncRequest(Context c, String url) {

    // configurazione della webRequest
    RequestFuture<JSONObject> future = RequestFuture.newFuture();
    JsonObjectRequest request = new JsonObjectRequest(url, null, future, future);
    RequestQueue requestQueue = Volley.newRequestQueue(c);
    requestQueue.add(request);

    // esecuzione sincrona della webRequest
    try {
        // limita la richiesta bloccante a un massimo di 10 secondi, quindi restituisci
        // la risposta.
        return future.get(10, TimeUnit.SECONDS);

    } catch (InterruptedException | TimeoutException | ExecutionException e) {
        e.printStackTrace();
    }

    return null;
}
项目:Library-Token-Automation    文件:Submit.java   
private void getData(String rollnumber) {

        String url = DATA_URL+rollnumber;
        loading = ProgressDialog.show(this,"Please wait...","Fetching...",false,false);
        StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                loading.dismiss();
                showJSON(response);
            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(Submit.this,error.getMessage().toString(),Toast.LENGTH_LONG).show();
                    }
                });

        RequestQueue requestQueue = Volley.newRequestQueue(this);
        requestQueue.add(stringRequest);
    }
项目:IelloAndroidAdminApp    文件:HelperRete.java   
/**
 * Effettua una web request sincrona tramite Volley API, restituendo in risposta
 * l'oggetto JSON scaricato.
 */
static JSONObject volleySyncRequest(Context c, String url) {

    // configurazione della webRequest
    RequestFuture<JSONObject> future = RequestFuture.newFuture();
    JsonObjectRequest request = new JsonObjectRequest(url, null, future, future);
    RequestQueue requestQueue = Volley.newRequestQueue(c);
    requestQueue.add(request);

    // esecuzione sincrona della webRequest
    try {
        // limita la richiesta bloccante a un massimo di 10 secondi, quindi restituisci
        // la risposta.
        return future.get(10, TimeUnit.SECONDS);

    } catch (InterruptedException | TimeoutException | ExecutionException e) {
        e.printStackTrace();
    }

    return null;
}
项目:TrackIt-Android    文件:SearchActivity.java   
private void loadSearchSuggestions(final String query) {
    String showName = query.replaceAll("\\s", "+");
    RequestQueue requestQueue = VolleySingleton.getInstance().getRequestQueue();
    JsonArrayRequest req = new JsonArrayRequest(
            API.TV_MAZE_SEARCH + showName,
            new Response.Listener<JSONArray>() {
                @Override
                public void onResponse(JSONArray response) {
                    List<SearchSuggestions> searchSuggestions = new ArrayList<>();
                    JSONObject object;
                    try {
                        for (int j = 0; j < response.length() && searchSuggestions.size() < 5; j++) {
                            object = response.getJSONObject(j).getJSONObject("show");
                            SearchSuggestions suggestion = new SearchSuggestions(object.getString("name"));
                            if (!searchSuggestions.contains(suggestion)) {
                                searchSuggestions.add(suggestion);
                            }
                        }
                    } catch (JSONException e) {
                        //Log.e("JSON exception", e.getMessage());
                    }
                    if (searchView.isSearchBarFocused()) {
                        searchView.swapSuggestions(searchSuggestions);
                    }
                    searchView.hideProgress();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    searchView.hideProgress();
                }
            });
    req.setRetryPolicy(new DefaultRetryPolicy(
            5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    requestQueue.add(req);
}
项目:android-volley-file-upload    文件:MyApplication.java   
public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(getApplicationContext());
    }

    return mRequestQueue;
}
项目:Goalie_Android    文件:BaseTest.java   
private RequestQueue newVolleyRequestQueueForTest(final Context context) {
    File cacheDir = new File(context.getCacheDir(), "cache/volley");
    Network network = new BasicNetwork(new HurlStack());
    ResponseDelivery responseDelivery = new ExecutorDelivery(Executors.newSingleThreadExecutor());
    RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network, 4, responseDelivery);
    queue.start();

    return queue;
}
项目:Nearby    文件:CustomApplication.java   
public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(getApplicationContext());
    }

    return mRequestQueue;
}
项目:Codeforces    文件:ImageLoaderTest.java   
@Test
public void publicMethods() throws Exception {
    // Catch API breaking changes.
    ImageLoader.getImageListener(null, -1, -1);
    mImageLoader.setBatchedResponseDelay(1000);

    assertNotNull(ImageLoader.class.getConstructor(RequestQueue.class,
            ImageLoader.ImageCache.class));

    assertNotNull(ImageLoader.class.getMethod("getImageListener", ImageView.class,
            int.class, int.class));
    assertNotNull(ImageLoader.class.getMethod("isCached", String.class, int.class, int.class));
    assertNotNull(ImageLoader.class.getMethod("isCached", String.class, int.class, int.class,
            ImageView.ScaleType.class));
    assertNotNull(ImageLoader.class.getMethod("get", String.class,
            ImageLoader.ImageListener.class));
    assertNotNull(ImageLoader.class.getMethod("get", String.class,
            ImageLoader.ImageListener.class, int.class, int.class));
    assertNotNull(ImageLoader.class.getMethod("get", String.class,
            ImageLoader.ImageListener.class, int.class, int.class, ImageView.ScaleType.class));
    assertNotNull(ImageLoader.class.getMethod("setBatchedResponseDelay", int.class));

    assertNotNull(ImageLoader.ImageListener.class.getMethod("onResponse",
            ImageLoader.ImageContainer.class, boolean.class));
}
项目:GitHub    文件:Volley.java   
/**
 * 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) {
    File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR);

    String userAgent = "volley/0";
    try {
        String packageName = context.getPackageName();
        PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
        userAgent = packageName + "/" + info.versionCode;
    } catch (NameNotFoundException e) {
    }

    if (stack == null) {
        if (Build.VERSION.SDK_INT >= 9) {
            stack = new HurlStack();
        } else {
            // Prior to Gingerbread, HttpUrlConnection was unreliable.
            // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html
            stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent));
        }
    }

    Network network = new BasicNetwork(stack);

    RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network);
    queue.start();

    return queue;
}
项目:GitHub    文件:VolleyUrlLoader.java   
private static RequestQueue getInternalQueue(Context context) {
  if (internalQueue == null) {
    synchronized (Factory.class) {
      if (internalQueue == null) {
        internalQueue = Volley.newRequestQueue(context);
      }
    }
  }
  return internalQueue;
}
项目:GeekZone    文件:BaseRequestQueue.java   
/**
 * Creates a normal network request instance of the worker pool and calls
 * which is based on OkHttpClient
 * {@link com.android.volley.RequestQueue#start()} on it.
 */
public static RequestQueue newOkHttpRequestQueue(Context context) {
    return newRequestQueue(context,
            false,
            new OkHttpStack(BaseSSLSocketFactory.getInstance("TLS")),
            DEFAULT_NETWORK_THREAD_POOL_SIZE);
}
项目:FlyHttp    文件:VolleyControllerSingleton.java   
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(mCtx.getApplicationContext());
    }
    return mRequestQueue;
}
项目:GitHub    文件:VolleyUrlLoader.java   
private static RequestQueue getInternalQueue(Context context) {
  if (internalQueue == null) {
    synchronized (Factory.class) {
      if (internalQueue == null) {
        internalQueue = Volley.newRequestQueue(context);
      }
    }
  }
  return internalQueue;
}
项目:Wings2K16    文件:AppController.java   
public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(getApplicationContext());
    }

    return mRequestQueue;
}
项目:ShotsNewsApp    文件:MySingleton.java   
public RequestQueue getRequestQueue()
{
    if(requestQueue==null)
    {
        requestQueue= Volley.newRequestQueue(mContext);

    }
    return requestQueue;
}
项目:security-config    文件:RemoteDataSource.java   
public RemoteDataSource(String url) {
        mUrl = url;
        // TODO: context should be Application context + this should be a singleton
//        mRequestQueue = Volley.newRequestQueue(context.getApplicationContext());
        mRequestQueue = new RequestQueue(new NoCache(), new BasicNetwork(new HurlStack()));
        //TODO: disable volley cache
        mRequestQueue.start();
    }
项目:ShotsNewsApp    文件:TestLoginActivity.java   
void getImage()                                                                                 //profile pic
    {
        ImageRequest request = new ImageRequest("http://ec2-52-14-50-89.us-east-2.compute.amazonaws.com/static/userdata/"+email+"/thumb.png",     ///"+email+" in btw userdata/  /thumb.png
                new Response.Listener<Bitmap>() {
                    @Override
                    public void onResponse(Bitmap bitmap) {
                        pro=bitmap;
                        ByteArrayOutputStream baos=new  ByteArrayOutputStream();
                        bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
                        byte [] b=baos.toByteArray();
                        String temp= Base64.encodeToString(b, Base64.DEFAULT);

                        SharedPreferences.Editor editor=sharedPreferences.edit();
                        editor.putString("profile_pic",temp);
                        editor.commit();
                        //   Log.e("mytag","Saved propic"+pro);
                        //count++;
                    }
                }, 0, 0, null,
                new Response.ErrorListener() {
                    public void onErrorResponse(VolleyError error) {
                        // mImageView.setImageResource(R.drawable.image_load_error);
                        Log.e("Home_Acitivity","No img found");
                        //count++;
                    }
                });
//        MySingleton.getMyInstance(getApplicationContext()).addToReqQue(request);
        RequestQueue queue= Volley.newRequestQueue(TestLoginActivity.this);
        queue.add(request);
    }
项目:WeatherPlus    文件:AppController.java   
public void cancelPendingRequests(final Object tag) {
    if (mRequestQueue != null && tag != null) {
        mRequestQueue.cancelAll(new RequestQueue.RequestFilter() {
            @Override
            public boolean apply(Request<?> request) {
                return request.getTag().equals(tag);
            }
        });
    }
}
项目:Blockly    文件:LuaActivity.java   
/**
 * 用于保存XML文件的网络请求
 */
public void andrUpload(){
    RequestQueue requestQueue = MyApplication.getRequestQueue();
    sharedPreferences = MyApplication.getSharedPreferences();
    userId = sharedPreferences.getString("email","");
    token = sharedPreferences.getString("token","");
    JSONObject jsonObject = new JSONObject();
    String fileName = dialogMsg+"_"+getWorkspaceSavePath();
    try{
        jsonObject.put("fileName",fileName);
        jsonObject.put("fileString",AbstractBlocklyActivity.xmltostring);//AbstractBlocklyActivity.xmltostring
        jsonObject.put("fileId",0);//这里应该通过一个方法来判断id的值,先暂时写成这样
        jsonObject.put("userId",userId);
        jsonObject.put("token",token);

    }catch (JSONException e){
        e.printStackTrace();
    }
    Log.d("AndrUpload_JsonObj",jsonObject.toString());

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_upload, jsonObject, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            uploadReceive uploadReceive = new uploadReceive();
            uploadReceive.setStatus(response.optString("status"));
            uploadReceive.setErrMsg(response.optString("errMsg"));
            Log.d("AndrUpload_Response",response.toString());

            judge_upload(uploadReceive.getStatus(),uploadReceive.getErrMsg());
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("AndrUpload_Error",error.toString(),error);
        }
    });

    requestQueue.add(jsonObjectRequest);

}
项目:BookED    文件:VolleySingleton.java   
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(mCtx.getApplicationContext());
    }
    return mRequestQueue;
}
项目:CompassDemo    文件:RegisterActivity.java   
private void registerUser() {
    Random rand = new Random();
    int number = (100000 + rand.nextInt(899999));
    final String userid = Integer.toString(number);
    final String email = editTextEmail.getText().toString().trim();
    final String password = editTextPassword.getText().toString().trim();
    final String confirmpassword = editTextConfirmPassword.getText().toString().trim();

    StringRequest stringRequest = new StringRequest(Request.Method.POST, UserPref.getRegisterURL(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Toast.makeText(RegisterActivity.this,response,Toast.LENGTH_LONG).show();
                    Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(RegisterActivity.this,error.toString(),Toast.LENGTH_LONG).show();
                }

            }){
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<>();
            params.put(KEY_USERID, userid);
            params.put(KEY_EMAIL, email);
            params.put(KEY_PASSWORD, password);
            return params;
        }
    };
    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
}
项目:CompassDemo    文件:UploadLoanImagesActivity.java   
private void setloanamount() {
    final SharedPreferences sharedPreferences = getSharedPreferences(UserPref.getSharedPrefName(), Context.MODE_PRIVATE);
    final String useramount = editTextSendAmount.getText().toString().trim();
    final String loanid = sharedPreferences.getString(UserPref.getSearchedloanidSharedPref(), "Not Available");
    StringRequest stringRequest = new StringRequest(Request.Method.POST, UserPref.getSetloanUrl(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Toast.makeText(UploadLoanImagesActivity.this,response,Toast.LENGTH_LONG).show();
                    finish();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(UploadLoanImagesActivity.this,error.toString(),Toast.LENGTH_LONG).show();
                }

            }){
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<>();
            params.put(KEY_AMOUNT, useramount);
            params.put(KEY_LOANID, loanid);
            return params;
        }
    };
    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
}
项目:mybotproject-Android    文件:AppController.java   
public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(getApplicationContext());
    }

    return mRequestQueue;
}
项目:Blockly    文件:LuaActivity.java   
/**
 * 用于更新XML文件的网络请求
 */
public void andrUpdate(String returnedFileName,String returnedFileId){
    RequestQueue requestQueue = MyApplication.getRequestQueue();
    sharedPreferences = MyApplication.getSharedPreferences();
    userId = sharedPreferences.getString("email","");
    token = sharedPreferences.getString("token","");
    JSONObject jsonObject = new JSONObject();
    String fileName = dialogMsg+"_"+getWorkspaceSavePath();
    try{
        jsonObject.put("fileName",returnedFileName);
        jsonObject.put("fileString",AbstractBlocklyActivity.xmltostring);//AbstractBlocklyActivity.xmltostring
        jsonObject.put("fileId",returnedFileId);//这里应该通过一个方法来判断id的值,先暂时写成这样
        jsonObject.put("userId",userId);
        jsonObject.put("token",token);

    }catch (JSONException e){
        e.printStackTrace();
    }
    Log.d("AndrUpdate_JsonObj",jsonObject.toString());

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_upload, jsonObject, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            uploadReceive uploadReceive = new uploadReceive();
            uploadReceive.setStatus(response.optString("status"));
            uploadReceive.setErrMsg(response.optString("errMsg"));
            Log.d("AndrUpdate_Response",response.toString());

            judge_upload(uploadReceive.getStatus(),uploadReceive.getErrMsg());
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("AndrUpdate_Error",error.toString(),error);
        }
    });

    requestQueue.add(jsonObjectRequest);

}
项目:GeekZone    文件:BaseRequestQueue.java   
/**
 * Creates a normal network request instance of the worker pool and calls
 * which is based on OkHttpClient
 * {@link com.android.volley.RequestQueue#start()} on it.
 */
public static RequestQueue newOkHttpRequestQueueWithoutSSL(Context context) {
    return newRequestQueue(context,
            false,
            new OkHttpStack(),
            DEFAULT_NETWORK_THREAD_POOL_SIZE);
}
项目:FancyTab    文件:VolleySingleton.java   
private RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        cookieManager = new CookieManager();
        CookieHandler.setDefault(cookieManager);

        mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
    }
    return mRequestQueue;
}
项目:android-perftracking    文件:RuntimeContentProvider.java   
@Override
public boolean onCreate() {
  Context context = getContext();
  if (context == null) {
    return false;
  }
  if (!AppPerformanceConfig.enabled) {
    return false; // Return when instrumentation is disabled
  }

  RequestQueue queue = new RequestQueue(new NoCache(), new BasicNetwork(new HurlStack()));
  queue.start();

  BatteryInfoStore batteryInfoStore = new BatteryInfoStore(context);

  String subscriptionKey = Util.getSubscriptionKey(context);

  String configUrlPrefix = Util
      .getMeta(context, "com.rakuten.tech.mobile.perf.ConfigurationUrlPrefix");
  String relayAppId = Util.getRelayAppId(context);
  ConfigStore configStore = new ConfigStore(context, queue, relayAppId, subscriptionKey,
      configUrlPrefix);

  // Read last config from cache
  Config config = createConfig(context, configStore.getObservable().getCachedValue(), relayAppId);
  if (config != null) {
    String locationUrlPrefix = Util
        .getMeta(context, "com.rakuten.tech.mobile.perf.LocationUrlPrefix");
    LocationStore locationStore = new LocationStore(context, queue, subscriptionKey,
        locationUrlPrefix);
    // Initialise Tracking Manager
    TrackingManager.initialize(context, config, locationStore.getObservable(),
        batteryInfoStore.getObservable());
    Metric.start("_launch");
  }
  return false;
}
项目:android-perftracking    文件:LocationStore.java   
LocationStore(@NonNull Context context, @NonNull RequestQueue requestQueue,
    @Nullable String subscriptionKey, @Nullable String urlPrefix) {
  this.prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
  this.requestQueue = requestQueue;
  this.subscriptionKey = subscriptionKey;
  this.urlPrefix = urlPrefix;
  this.handler = new Handler(Looper.getMainLooper());

  getObservable().publish(readLocationFromCache());
  loadLocationFromApi();
  handler.postDelayed(periodicLocationCheck, TIME_INTERVAL);
}
项目:android-perftracking    文件:ConfigStore.java   
ConfigStore(@NonNull Context context, @NonNull RequestQueue requestQueue,
    @NonNull String relayAppId, @Nullable String subscriptionKey, @Nullable String urlPrefix) {
  this.packageManager = context.getPackageManager();
  this.packageName = context.getPackageName();
  this.appId = relayAppId;
  this.res = context.getResources();
  this.prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
  this.requestQueue = requestQueue;
  this.subscriptionKey = subscriptionKey;
  this.urlPrefix = urlPrefix;
  getObservable().publish(readConfigFromCache());
  handler = new Handler(Looper.getMainLooper());
  loadConfigurationFromApi();
  handler.postDelayed(periodicCheck, TIME_INTERVAL);
}
项目:eBread    文件:VolleyRequest.java   
private RequestQueue getRequestQueue() {
    if (mContext == null) { return null; }
    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;
}
项目:FrappeSyncAdapter    文件:FrappeNoteApi.java   
public RequestQueue getRequestQueue() {
    // lazy initialize the request queue, the queue instance will be
    // created when it is accessed for the first time
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(mContext);
    }
    return mRequestQueue;
}
项目:FrappeSyncAdapter    文件:FrappeNoteApi.java   
public RequestQueue getSerialRequestQueue() {
    if (mSerialRequestQueue == null) {
        mSerialRequestQueue = prepareSerialRequestQueue(mContext);
        mSerialRequestQueue.start();
    }
    return mSerialRequestQueue;
}
项目:ShotsNewsApp    文件:SplashScreenActivity.java   
void getImage()                                                                                 //profile pic
    {
        ImageRequest request = new ImageRequest("http://ec2-52-14-50-89.us-east-2.compute.amazonaws.com/static/userdata/"+name+"/thumb.png",     ///"+email+" in btw userdata/  /thumb.png
                new Response.Listener<Bitmap>() {
                    @Override
                    public void onResponse(Bitmap bitmap) {
                        pro=bitmap;
                        ByteArrayOutputStream baos=new  ByteArrayOutputStream();
                        bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
                        byte [] b=baos.toByteArray();
                        String temp= Base64.encodeToString(b, Base64.DEFAULT);

                        SharedPreferences.Editor editor=sharedPreferences.edit();
                        editor.putString("profile_pic",temp);
                        editor.commit();
                        Log.e("mytag","Saved propic"+pro);
                        //count++;
                    }
                }, 0, 0, null,
                new Response.ErrorListener() {
                    public void onErrorResponse(VolleyError error) {
                        // mImageView.setImageResource(R.drawable.image_load_error);
                        Log.e("Home_Acitivity","No img found");
                        //count++;
                    }
                });
//        MySingleton.getMyInstance(getApplicationContext()).addToReqQue(request);
        RequestQueue queue= Volley.newRequestQueue(getApplicationContext());
        queue.add(request);
    }
项目:FrappeSyncAdapter    文件:FrappeToDoApi.java   
public RequestQueue getRequestQueue() {
    // lazy initialize the request queue, the queue instance will be
    // created when it is accessed for the first time
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(mContext);
    }
    return mRequestQueue;
}
项目:Blockly    文件:LuaActivity.java   
/**
 * 用户请求文件列表的网络通信
 */
public void fileListRequest(){
    String userId = sharedPreferences.getString("email","");
    String token  = sharedPreferences.getString("token","");
    RequestQueue requestQueue = MyApplication.getRequestQueue();
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put("userId",userId);
        jsonObject.put("token",token);
        Log.d("fileListRequest_JsonObj",jsonObject.toString());


    }catch (JSONException e){
        e.printStackTrace();
    }

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_filelistrequest, jsonObject, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {

            getListReceive getListReceive = new getListReceive();
            getListReceive.setStatus(response.optString("status"));
            getListReceive.setErrMsg(response.optString("errMsg"));
            getListReceive.setJsonObject(response.optJSONObject("jsonStrArray"));
            Log.d("getFileList_Response",response.toString());

            judge_fileListRequest(getListReceive.getStatus(),getListReceive.getErrMsg(),getListReceive.getJsonObject());

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("fileListRequest_Error",error.toString(),error);
        }
    });
    requestQueue.add(jsonObjectRequest);
}
项目:CoolClock    文件:NetworkService.java   
private RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        mRequestQueue =
                Volley.newRequestQueue(ClockApplication.getContext());
    }
    return mRequestQueue;
}
项目:GeekZone    文件:BaseRequestQueue.java   
/**
 * Creates a normal network request instance of the worker pool and calls
 * {@link com.android.volley.RequestQueue#start()} on it.
 */
public static RequestQueue newNormalRequestQueue(Context context, String hostName) {
    return newRequestQueue(context,
            false,
            new BaseStack(null, BaseSSLSocketFactory.getInstance("TLS"), hostName),
            DEFAULT_NETWORK_THREAD_POOL_SIZE);
}
项目:super-volley    文件:SuperVolley.java   
SuperVolley(RequestQueue requestQueue, okhttp3.HttpUrl baseUrl,
            List<Converter.Factory> converterFactories, List<CallAdapter.Factory> adapterFactories,
            Executor callbackExecutor, boolean validateEagerly) {
    this.baseUrl = baseUrl;
    this.converterFactories = unmodifiableList(converterFactories); // Defensive copy at call site.
    this.adapterFactories = unmodifiableList(adapterFactories); // Defensive copy at call site.
    this.callbackExecutor = callbackExecutor;
    this.validateEagerly = validateEagerly;
    this.requestQueue = requestQueue;
    this.requestQueue.start();
}
项目:chat-sdk-android-push-firebase    文件:VolleyUtils.java   
public static RequestQueue getRequestQueue() {
    if (mRequestQueue != null) {
        return mRequestQueue;
    } else {
        throw new IllegalStateException("RequestQueue not initialized");
    }
}
项目:Codeforces    文件:Volley.java   
/**
 * 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) {
    File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR);

    String userAgent = "volley/0";
    try {
        String packageName = context.getPackageName();
        PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
        userAgent = packageName + "/" + info.versionCode;
    } catch (NameNotFoundException e) {
    }

    if (stack == null) {
        if (Build.VERSION.SDK_INT >= 9) {
            stack = new HurlStack();
        } else {
            // Prior to Gingerbread, HttpUrlConnection was unreliable.
            // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html
            stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent));
        }
    }

    Network network = new BasicNetwork(stack);

    RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network);
    queue.start();

    return queue;
}