当前位置: 首页>>代码示例>>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;未经允许,请勿转载。