当前位置: 首页>>代码示例>>Java>>正文


Java DiskLruCache.get方法代码示例

本文整理汇总了Java中com.jakewharton.disklrucache.DiskLruCache.get方法的典型用法代码示例。如果您正苦于以下问题:Java DiskLruCache.get方法的具体用法?Java DiskLruCache.get怎么用?Java DiskLruCache.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jakewharton.disklrucache.DiskLruCache的用法示例。


在下文中一共展示了DiskLruCache.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exist

import com.jakewharton.disklrucache.DiskLruCache; //导入方法依赖的package包/类
static int exist(String name) {

        DiskLruCache diskLruCache = getDiskLruCache();
        if (diskLruCache == null) {
            return -1;
        }
        try {
            DiskLruCache.Snapshot snapshot = diskLruCache.get(name);
            if (snapshot == null) {
                return -1;
            }
            InputStream stream = snapshot.getInputStream(1);
            boolean hasBitmap = readBoolean(stream);
            return hasBitmap ? 1 : 0;
        } catch (IOException e) {
            e.printStackTrace();
        }

        return -1;
    }
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:21,代码来源:BitmapWrapper.java

示例2: readFromCache

import com.jakewharton.disklrucache.DiskLruCache; //导入方法依赖的package包/类
@Override
public DrawableSizeHolder readFromCache(String key, DiskLruCache cache) {
    if (cache != null) {

        try {
            DiskLruCache.Snapshot snapshot = cache.get(key);

            if (snapshot == null) {
                return null;
            }

            InputStream inputStream = snapshot.getInputStream(0);

            DrawableSizeHolder drawableSizeHolder = DrawableSizeHolder.read(inputStream, key);

            inputStream.close();

            return drawableSizeHolder;
        } catch (IOException e) {
            Debug.e(e);
        }
    }
    return null;
}
 
开发者ID:zzhoujay,项目名称:RichText,代码行数:25,代码来源:CacheIOHelper.java

示例3: save

import com.jakewharton.disklrucache.DiskLruCache; //导入方法依赖的package包/类
void save() {

        DiskLruCache diskLruCache = getDiskLruCache();

        if (diskLruCache != null) {
            try {
                DiskLruCache.Snapshot snapshot = diskLruCache.get(name);
                if (snapshot == null) {
                    DiskLruCache.Editor edit = diskLruCache.edit(name);
    
                    // write size
                    OutputStream sizeOutputStream = edit.newOutputStream(0);
                    sizeCacheHolder.save(sizeOutputStream);
    
                    // write bitmap
                    OutputStream bitmapOutputStream = edit.newOutputStream(1);
                    writeBoolean(bitmapOutputStream, bitmap != null);
                    if (bitmap != null) {
                        bitmap.compress(Bitmap.CompressFormat.PNG, 100, bitmapOutputStream);
                    }
                    bitmapOutputStream.flush();
                    bitmapOutputStream.close();
                    // write bitmap
    
                    edit.commit();
                }
            } catch (IOException e) {
                Debug.e(e);
            }
        }

    }
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:33,代码来源:BitmapWrapper.java

示例4: hasCacheInDisk

import com.jakewharton.disklrucache.DiskLruCache; //导入方法依赖的package包/类
public static boolean hasCacheInDisk(DiskLruCache diskLruCache, String key) {

        if (diskLruCache != null && !diskLruCache.isClosed() && !TextUtils.isEmpty(key)) {
            try {
                DiskLruCache.Snapshot snapshot = diskLruCache.get(key);
                if (snapshot != null) {
                    return true;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return false;
        }
        return false;
    }
 
开发者ID:zhanjiashu,项目名称:ZhihuDialyM,代码行数:16,代码来源:ZHStorageUtils.java

示例5: hasCache

import com.jakewharton.disklrucache.DiskLruCache; //导入方法依赖的package包/类
@Override
public boolean hasCache(String key, DiskLruCache cache) {
    if (cache != null) {
        try {
            DiskLruCache.Snapshot snapshot = cache.get(key);
            return snapshot != null;
        } catch (IOException e) {
            Debug.e(e);
        }
    }
    return false;
}
 
开发者ID:zzhoujay,项目名称:RichText,代码行数:13,代码来源:CacheIOHelper.java

示例6: read

import com.jakewharton.disklrucache.DiskLruCache; //导入方法依赖的package包/类
static BitmapWrapper read(String name, boolean readBitmap) {

        DiskLruCache diskLruCache = getDiskLruCache();

        if (diskLruCache != null) {

            try {
                DiskLruCache.Snapshot snapshot = diskLruCache.get(name);

                if (snapshot == null) {
                    return null;
                }

                InputStream sizeInputStream = snapshot.getInputStream(0);
                SizeCacheHolder sizeCacheHolder = SizeCacheHolder.read(sizeInputStream, name);
                if (sizeCacheHolder == null) {
                    return null;
                }

                Bitmap bitmap = null;
                if (readBitmap) {

                    InputStream bitmapInputStream = snapshot.getInputStream(1);
                    boolean hasBitmap = readBoolean(bitmapInputStream);
                    if (hasBitmap) {
                        bitmap = decodeBitmap(bitmapInputStream, null);
                    }

                    bitmapInputStream.close();
                }

                return new BitmapWrapper(name, bitmap, sizeCacheHolder);

            } catch (IOException e) {
                Debug.e(e);
            }

        }

        return null;

    }
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:43,代码来源:BitmapWrapper.java


注:本文中的com.jakewharton.disklrucache.DiskLruCache.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。