當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestQueue類代碼示例

本文整理匯總了Java中com.android.volley.RequestQueue的典型用法代碼示例。如果您正苦於以下問題:Java RequestQueue類的具體用法?Java RequestQueue怎麽用?Java RequestQueue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RequestQueue類屬於com.android.volley包,在下文中一共展示了RequestQueue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: volleySyncRequest

import com.android.volley.RequestQueue; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:IelloDevTeam,項目名稱:IelloAndroidApp,代碼行數:25,代碼來源:HelperRete.java

示例2: getData

import com.android.volley.RequestQueue; //導入依賴的package包/類
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);
    }
 
開發者ID:anuragsai97,項目名稱:Library-Token-Automation,代碼行數:22,代碼來源:Submit.java

示例3: volleySyncRequest

import com.android.volley.RequestQueue; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:IelloDevTeam,項目名稱:IelloAndroidAdminApp,代碼行數:25,代碼來源:HelperRete.java

示例4: loadSearchSuggestions

import com.android.volley.RequestQueue; //導入依賴的package包/類
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);
}
 
開發者ID:chashmeetsingh,項目名稱:TrackIt-Android,代碼行數:39,代碼來源:SearchActivity.java

示例5: getRequestQueue

import com.android.volley.RequestQueue; //導入依賴的package包/類
public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(getApplicationContext());
    }

    return mRequestQueue;
}
 
開發者ID:huluhive,項目名稱:android-volley-file-upload,代碼行數:8,代碼來源:MyApplication.java

示例6: newVolleyRequestQueueForTest

import com.android.volley.RequestQueue; //導入依賴的package包/類
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;
}
 
開發者ID:Q115,項目名稱:Goalie_Android,代碼行數:10,代碼來源:BaseTest.java

示例7: publicMethods

import com.android.volley.RequestQueue; //導入依賴的package包/類
@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));
}
 
開發者ID:Ace201m,項目名稱:Codeforces,代碼行數:26,代碼來源:ImageLoaderTest.java

示例8: newRequestQueue

import com.android.volley.RequestQueue; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:36,代碼來源:Volley.java

示例9: getInternalQueue

import com.android.volley.RequestQueue; //導入依賴的package包/類
private static RequestQueue getInternalQueue(Context context) {
  if (internalQueue == null) {
    synchronized (Factory.class) {
      if (internalQueue == null) {
        internalQueue = Volley.newRequestQueue(context);
      }
    }
  }
  return internalQueue;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:VolleyUrlLoader.java

示例10: newOkHttpRequestQueue

import com.android.volley.RequestQueue; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:12,代碼來源:BaseRequestQueue.java

示例11: getRequestQueue

import com.android.volley.RequestQueue; //導入依賴的package包/類
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;
}
 
開發者ID:MarioDeAraujoCarvalho,項目名稱:FlyHttp,代碼行數:9,代碼來源:VolleyControllerSingleton.java

示例12: getRequestQueue

import com.android.volley.RequestQueue; //導入依賴的package包/類
public RequestQueue getRequestQueue()
{
    if(requestQueue==null)
    {
        requestQueue= Volley.newRequestQueue(mContext);

    }
    return requestQueue;
}
 
開發者ID:goutham-kalikrishna,項目名稱:ShotsNewsApp,代碼行數:10,代碼來源:MySingleton.java

示例13: RemoteDataSource

import com.android.volley.RequestQueue; //導入依賴的package包/類
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();
    }
 
開發者ID:googlecodelabs,項目名稱:security-config,代碼行數:9,代碼來源:RemoteDataSource.java

示例14: getImage

import com.android.volley.RequestQueue; //導入依賴的package包/類
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);
    }
 
開發者ID:goutham-kalikrishna,項目名稱:ShotsNewsApp,代碼行數:31,代碼來源:TestLoginActivity.java

示例15: cancelPendingRequests

import com.android.volley.RequestQueue; //導入依賴的package包/類
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);
            }
        });
    }
}
 
開發者ID:farukydnn,項目名稱:WeatherPlus,代碼行數:11,代碼來源:AppController.java


注:本文中的com.android.volley.RequestQueue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。