类android.net.http.HttpResponseCache源码实例Demo

下面列出了怎么用android.net.http.HttpResponseCache的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: DoraemonKit   文件: UrlConnectionDownloader.java
static Object install(Context context) throws IOException {
  File cacheDir = Utils.createDefaultCacheDir(context);
  HttpResponseCache cache = HttpResponseCache.getInstalled();
  if (cache == null) {
    long maxSize = Utils.calculateDiskCacheSize(cacheDir);
    cache = HttpResponseCache.install(cacheDir, maxSize);
  }
  return cache;
}
 
源代码2 项目: DoraemonKit   文件: UrlConnectionDownloader.java
static Object install(Context context) throws IOException {
  File cacheDir = Utils.createDefaultCacheDir(context);
  HttpResponseCache cache = HttpResponseCache.getInstalled();
  if (cache == null) {
    long maxSize = Utils.calculateDiskCacheSize(cacheDir);
    cache = HttpResponseCache.install(cacheDir, maxSize);
  }
  return cache;
}
 
源代码3 项目: VideoOS-Android-SDK   文件: VenvySvgaImageView.java
public VenvySvgaImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    svgaParser = initSVGAParse();
    if (!isInstallCache) {
        isInstallCache = true;
        File cacheDir = new File(SVGAParser.getCacheDirectory(context, true), "venvy/svga/");
        try {
            HttpResponseCache.install(cacheDir, 1024 * 1024 * 128);
        } catch (IOException e) {
        }
    }
}
 
源代码4 项目: VideoOS-Android-SDK   文件: VenvySvgaImageView.java
@TargetApi(21)
public VenvySvgaImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
                          int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    svgaParser = initSVGAParse();
    if (!isInstallCache) {
        isInstallCache = true;
        File cacheDir = new File(SVGAParser.getCacheDirectory(context, true), "venvy/svga/");
        try {
            HttpResponseCache.install(cacheDir, 1024 * 1024 * 128);
        } catch (IOException e) {
        }
    }
}
 
源代码5 项目: YalpStore   文件: YalpStoreApplication.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void initHttpCache() {
    try {
        if (null != HttpResponseCache.getInstalled()) {
            HttpResponseCache.getInstalled().delete();
        }
        HttpResponseCache.install(new File(getCacheDir(), "http"), 5 * 1024 * 1024);
    } catch (IOException e) {
        Log.e(getClass().getSimpleName(), "Could not register cache " + e.getMessage());
    }
}
 
源代码6 项目: pandroid   文件: NetworkUtils.java
/**
 * Enable caching for http request : must use HttpUrlConnection !
 * see : <a href="http://developer.android.com/reference/android/net/http/HttpResponseCache.html">HttpResponseCache</a>
 *
 * @param context
 */
public static void enableHttpCaching(Context context) {
    long httpCacheSize = 10 * 1024 * 1024; // 10 MiB
    try {
        File httpCacheDir = new File(context.getCacheDir(), "http");
        HttpResponseCache.install(httpCacheDir, httpCacheSize);
    } catch (IOException e) {
        Log.i("", "HTTP response cache failed:" + e);
    }
}
 
源代码7 项目: lighthttp   文件: CacheUtil.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private static HttpResponseCache installHttpResponseCache(final File cacheDir)
        throws IOException {
    HttpResponseCache cache = HttpResponseCache.getInstalled();
    if (cache == null) {
        final long maxSize = calculateDiskCacheSize(cacheDir);
        cache = HttpResponseCache.install(cacheDir, maxSize);
    }
    return cache;
}
 
源代码8 项目: Qshp   文件: PostContentActivity.java
@Override
public void onStop() {
    super.onStop();
    mAdapter.changeCursor(null);
    HttpResponseCache cache = HttpResponseCache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
 
/**
 * Installs a cache for fetched URLs
 */
private void installCache() {
  HttpResponseCache cache = HttpResponseCache.getInstalled();
  if (cache == null) {
    try {
      File httpCacheDir = new File(getApplicationContext().getCacheDir(), "http");
      HttpResponseCache.install(httpCacheDir, CACHE_SIZE);
    } catch (IOException e) {
      Log.w(TAG, "HTTP response cache installation failed:", e);
    }
  }
}
 
源代码10 项目: PkRSS   文件: DefaultDownloader.java
public DefaultDownloader(Context context)  {
	cacheDir = new File(context.getCacheDir(), "http");
	try {
		HttpResponseCache.install(cacheDir, cacheSize);
	}
	catch (IOException e) {
		Log.i(TAG, "HTTP response cache installation failed:" + e);
	}
}
 
源代码11 项目: DoraemonKit   文件: UrlConnectionDownloader.java
static void close(Object cache) {
  try {
    ((HttpResponseCache) cache).close();
  } catch (IOException ignored) {
  }
}
 
源代码12 项目: DoraemonKit   文件: UrlConnectionDownloader.java
static void close(Object cache) {
  try {
    ((HttpResponseCache) cache).close();
  } catch (IOException ignored) {
  }
}
 
 类所在包
 同包方法