小编Ste*_*uvr的帖子

networkimageview以离线模式显示图像?杀死申请后重新开放.就像facebook应用程序一样

我提到了android开发者网站,并用singleton类创建了凌空NetworkImageView.但它不会在应用程序强制关闭后维护缓存图像,并再次在离线状态下打开我的应用程序.如何使网络图像视图在脱机模式下从缓存中获取图像.我正在使用LruCache.

注意:我在整个应用程序中使用NetworkImageView.我在某处读到只有当图像URL包含缓存头时才会存储磁盘缓存.我想了解这一点,如果URL中没有标题,那么如何强制凌空存储图像的磁盘缓存?

我的代码:

public class VolleySingletonPattern {

private static VolleySingletonPattern mInstance;
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
private static Context mCtx;

private VolleySingletonPattern(Context context) {
    mCtx = context;
    mRequestQueue = getRequestQueue();

    mImageLoader = new ImageLoader(mRequestQueue, new LruBitmapCache(
            LruBitmapCache.getCacheSize(mCtx)));
}

public static synchronized VolleySingletonPattern getInstance(Context context) {
    if (mInstance == null) {
        mInstance = new VolleySingletonPattern(context);
    }
    return mInstance;
}

public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        // getApplicationContext() is key, it keeps you from leaking the
        // Activity …
Run Code Online (Sandbox Code Playgroud)

android android-volley networkimageview

6
推荐指数
1
解决办法
756
查看次数

标签 统计

android ×1

android-volley ×1

networkimageview ×1