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


Java HurlStack類代碼示例

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


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

示例1: getRequestQueue

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

        // Instantiate the cache
        Cache cache = new DiskBasedCache(mContext.getCacheDir(), 1024 * 1024); // 1MB cap
        // Set up the network to use HttpURLConnection as the HTTP client.
        Network network = new BasicNetwork(new HurlStack());
        // Instantiate the RequestQueue with the cache and network.
        mRequestQueue = new RequestQueue(cache, network);
        // Start the queue
        mRequestQueue.start();

        // getApplicationContext() is key, it keeps you from leaking the
        // Activity or BroadcastReceiver if someone passes one in.
        //mRequestQueue = Volley.newRequestQueue(mContext.getApplicationContext());
    }
    return mRequestQueue;
}
 
開發者ID:delizondo,項目名稱:CursoAndroid,代碼行數:19,代碼來源:ApiClient.java

示例2: newVolleyRequestQueueForTest

import com.android.volley.toolbox.HurlStack; //導入依賴的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

示例3: newRequestQueue

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
/**
 * Creates a new Request Queue which caches to the external storage directory
 * @param context
 * @return
 */
private static RequestQueue newRequestQueue(Context context) {
    // define cache folder
    File rootCache = context.getExternalCacheDir();
    if (rootCache == null) {
        Log.w(TAG, "Can't find External Cache Dir, "
                + "switching to application specific cache directory");
        rootCache = context.getCacheDir();
    }

    File cacheDir = new File(rootCache, DEFAULT_CACHE_DIR);
    cacheDir.mkdirs();

    HttpStack stack = new HurlStack();
    Network network = new BasicNetwork(stack);
    DiskBasedCache diskBasedCache = new DiskBasedCache(cacheDir, DEFAULT_DISK_USAGE_BYTES);
    RequestQueue queue = new RequestQueue(diskBasedCache, network);
    queue.start();

    return queue;
}
 
開發者ID:bilbo7833,項目名稱:shutterstock-image-browser,代碼行數:26,代碼來源:VolleySingleton.java

示例4: newRequestQueue

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
private static RequestQueue newRequestQueue() {
        VolleyLog.DEBUG = true;
        RequestQueue requestQueue = new RequestQueue(openCache(), new BasicNetwork(new HurlStack()));
        requestQueue.start();
        CookieManager manager = new CookieManager(new SimpleCookieStore(), CookiePolicy.ACCEPT_ORIGINAL_SERVER);
        CookieHandler.setDefault(manager);

//        String userAgent = "volley/0";
//        try {
//            String packageName = BaseApplication.getBaseApplication().getPackageName();
//            PackageInfo info = BaseApplication.getBaseApplication().getPackageManager().getPackageInfo(packageName, 0);
//            userAgent = packageName + "/" + info.versionCode;
//        } catch (PackageManager.NameNotFoundException e) {}
//        android.net.http.AndroidHttpClient  httpClient = AndroidHttpClient.newInstance(userAgent);
//        HttpStack httpStack = new OwnHttpClientStack(httpClient);
//        RequestQueue requestQueue = Volley.newRequestQueue(BaseApplication.getBaseApplication(),
//                httpStack);


        return requestQueue;
    }
 
開發者ID:lofei117,項目名稱:TuChongAndroid,代碼行數:22,代碼來源:RequestManager.java

示例5: newRequestQueue

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
private static RequestQueue newRequestQueue(Context context) {

        // On HC+ use HurlStack which is based on HttpURLConnection. Otherwise fall back on
        // AndroidHttpClient (based on Apache DefaultHttpClient) which should no longer be used
        // on newer platform versions where HttpURLConnection is simply better.
        Network network = new BasicNetwork(
                UIUtils.hasHoneycomb() ?
                        new HurlStack() :
                        new HttpClientStack(AndroidHttpClient.newInstance(
                                NetUtils.getUserAgent(context))));

        Cache cache = new DiskBasedCache(getDiskCacheDir(context, CACHE_DIR));
        RequestQueue queue = new RequestQueue(cache, network);
        queue.start();
        return queue;
    }
 
開發者ID:BitCypher2014,項目名稱:Wardrobe_app,代碼行數:17,代碼來源:ImageLoader.java

示例6: newRequestQueue

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
private RequestQueue newRequestQueue(Context context) {
    // define cache folder
    File rootCache = context.getExternalCacheDir();
    if (rootCache == null) {
        rootCache = context.getCacheDir();
    }

    File cacheDir = new File(rootCache, DEFAULT_CACHE_DIR);
    cacheDir.mkdirs();

    HttpStack stack = new HurlStack();
    Network network = new BasicNetwork(stack);
    DiskBasedCache diskBasedCache = new DiskBasedCache(cacheDir, DEFAULT_DISK_USAGE_BYTES);
    RequestQueue queue = new RequestQueue(diskBasedCache, network);
    queue.start();

    return queue;
}
 
開發者ID:googlesamples,項目名稱:io2014-codelabs,代碼行數:19,代碼來源:CloudBackendFragment.java

示例7: onCreate

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
@Override
public void onCreate() {
	super.onCreate();

	PREFS = new PreferenceWrapper( this );
	PREFS.listen();

	DISK_CACHE = new DiskBasedCache( getExternalCacheDir(), DISK_CACHE_SIZE );
	MEMORY_CACHE = new MangaMemoryCache();

	// Use the same disk cache for main and background download queues
	REQUEST_QUEUE = new RequestQueue( DISK_CACHE, new BasicNetwork( new HurlStack() ));
	REQUEST_QUEUE.start();

	// Use a custom in-memory LruCache for the loader
	IMAGE_LOADER = new ImageLoader( REQUEST_QUEUE, MEMORY_CACHE );

	// Setup databases
	Library.setDB( LibraryDatabaseHelper.getInstance( this ).getWritableDatabase() );
	Collection.setDB( CollectionDatabaseHelper.getInstance( this ).getWritableDatabase() );

	MangaUpdateReceiver.startUpdateCycle( this );
}
 
開發者ID:Alexander-Prime,項目名稱:MangaJunkie-Android,代碼行數:24,代碼來源:App.java

示例8: onHandleIntent

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
@Override
    protected void onHandleIntent(Intent intent) {
//        System.out.println("SEND DATA INTENT STARTED");
        Connectivity connectivity = new Connectivity(this);

        if (!connectivity.isConnectedAndIsWifiIfOnlyWifiSet()) {
            DataCollectionAlarmReceiver.completeWakefulIntent(intent);
            ConnectivityChangeReceiver.completeWakefulIntent(intent);

            DataCollectionAlarmReceiver.setConnectivityChangeReceiverState(PackageManager.COMPONENT_ENABLED_STATE_ENABLED, this);

//            System.out.println("STOPPED SEND DATA INTENT AND ENABLED CCR - NO NETWORK");
        } else {
            JSONPackager jsonPkgr = new JSONPackager(this);
            HttpPostHandler httpPostHdlr = new HttpPostHandler(this, new HurlStack());

            JSONObject collectedDataJSON = jsonPkgr.createJsonObjectFromStoredData();
            httpPostHdlr.postJSON(collectedDataJSON, intent);
//            System.out.println("SENT POST");
        }
    }
 
開發者ID:TeamWhat,項目名稱:what-stored-in-a-mobile-device-android,代碼行數:22,代碼來源:SendDataIntentService.java

示例9: onCreate

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
@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;
}
 
開發者ID:rakutentech,項目名稱:android-perftracking,代碼行數:38,代碼來源:RuntimeContentProvider.java

示例10: start

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
/**
 * Inicia uma instancia da lib PlainRequest
 * utilizando cache do volley
 *
 * @param app
 * @param sizeCache // tamanho do cache em MB
 */
public void start(Application app, int sizeCache) {
    if(context == null) {
        context = app.getApplicationContext();
        // Cache
        Cache cache = new DiskBasedCache(app.getCacheDir(), (1024 * 1024) * sizeCache);
        Network network = new BasicNetwork(new HurlStack());
        queue = new RequestQueue(cache, network); // Criação do RequestQueue
    }
}
 
開發者ID:giovanimoura,項目名稱:plainrequest,代碼行數:17,代碼來源:PlainRequestQueue.java

示例11: RemoteDataSource

import com.android.volley.toolbox.HurlStack; //導入依賴的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

示例12: HTTPAlbumImageProvider

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
private HTTPAlbumImageProvider(Context context) {
    // Don't use MALPRequestQueue because we do not need to limit the load on the local server
    Network network = new BasicNetwork(new HurlStack());
    // 10MB disk cache
    Cache cache = new DiskBasedCache(context.getCacheDir(), 1024 * 1024 * 10);

    mRequestQueue = new RequestQueue(cache, network);
    mRequestQueue.start();
}
 
開發者ID:gateship-one,項目名稱:malp,代碼行數:10,代碼來源:HTTPAlbumImageProvider.java

示例13: getInstance

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
public synchronized static MALPRequestQueue getInstance(Context context) {
    if ( null == mInstance ) {
        Network network = new BasicNetwork(new HurlStack());
        // 10MB disk cache
        Cache cache = new DiskBasedCache(context.getCacheDir(), 1024 * 1024 * 10);

        mInstance = new MALPRequestQueue(cache,network);
        mInstance.start();
    }
    return mInstance;
}
 
開發者ID:gateship-one,項目名稱:malp,代碼行數:12,代碼來源:MALPRequestQueue.java

示例14: getRequestQueue

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        Cache cache = new DiskBasedCache(mCtx.getCacheDir(), 10 * 1024 * 1024);
        Network network = new BasicNetwork(new HurlStack());
        mRequestQueue = new RequestQueue(cache, network);
        // Don't forget to start the volley request queue
        mRequestQueue.start();
    }
    return mRequestQueue;
}
 
開發者ID:Truiton,項目名稱:VolleyImageLoader,代碼行數:11,代碼來源:CustomVolleyRequestQueue.java

示例15: getRequestQueue

import com.android.volley.toolbox.HurlStack; //導入依賴的package包/類
public RequestQueue getRequestQueue() {
    if (requestQueue == null) {
        Cache cache = new DiskBasedCache(ctx.getCacheDir(), 10 * 1024 * 1024);
        Network network = new BasicNetwork(new HurlStack());
        requestQueue = new RequestQueue(cache, network);
        // Don't forget to start the volley request queue
        requestQueue.start();
    }
    return requestQueue;
}
 
開發者ID:attiqrehman1991,項目名稱:VolleyBecomesEasy,代碼行數:11,代碼來源:CustomVolleyRequestQueue.java


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