@Override protected DiskLruCache doInBackground(Void... params) { try { return DiskLruCache.open(mDiskCacheLocation, 0, 1, mDiskCacheMaxSize); } catch (IOException e) { e.printStackTrace(); return null; } }
public DiskCache(Context context, int size) throws IOException { File directory = new File(context.getCacheDir(), DIRECTORY_NAME); mDiskCache = DiskLruCache.open(directory, 1, 1, size); }
private void openDiskLruCache(File diskFolder) throws IOException { this.diskLruCache = DiskLruCache.open( diskFolder, this.appVersion, VALUES_PER_CACHE_ENTRY, this.maxDiskSizeBytes ); }
private void openDiskLruCache(File diskFolder) throws IOException { this.diskLruCache = DiskLruCache.open( diskFolder, this.appVersion, VALUES_PER_CACHE_ENTRY, this.maxDiskSizeBytes ); }
@Override protected DiskLruCache doInBackground(Void... params) { try { return DiskLruCache.open(mDiskCacheLocation, 0, 1, mDiskCacheMaxSize); } catch (IOException e) { e.printStackTrace(); return null; } }
public BasicCaching(File diskDirectory, long maxDiskSize, int memoryEntries){ try{ diskCache = DiskLruCache.open(diskDirectory, 1, 1, maxDiskSize); }catch(IOException exc){ Log.e("SmartCall", "", exc); diskCache = null; } memoryCache = new LruCache<>(memoryEntries); }
public LruDiskCache(IDiskConverter diskConverter, File diskDir, int appVersion, long diskMaxSize) { this.mDiskConverter = Utils.checkNotNull(diskConverter, "diskConverter ==null"); try { mDiskLruCache = DiskLruCache.open(diskDir, appVersion, 1, diskMaxSize); } catch (IOException e) { e.printStackTrace(); } }
public BasicCaching(File diskDirectory, long maxDiskSize, int memoryEntries){ try{ diskCache = DiskLruCache.open(diskDirectory, 1, 1, maxDiskSize); }catch(IOException exc){ Log.e("SmartCall", "", exc); diskCache = null; } memoryCache = new LruCache<>(memoryEntries); }
public BasicCaching(File diskDirectory, long maxDiskSize, int memoryEntries){ try{ diskCache = DiskLruCache.open(diskDirectory, 1, 1, maxDiskSize); }catch(IOException exc){ Log.e("SmartCall", "", exc); diskCache = null; } memoryCache = new LruCache<>(memoryEntries); }
private SimpleCacheProvider(Context context, File dir, long maxSize) throws IOException { diskLruCache = DiskLruCache.open(dir, PackageInfoHelper.getAppVersionCode(context), 1, maxSize); }
public static DiskLoader open(File directory, long maxSize, int threadCount) throws IOException { return new DiskLoader(DiskLruCache.open(directory, APP_VERSION, VALUE_COUNT, maxSize), threadCount); }
/** * Initializes the disk cache. Needs to be called at least once before trying to use the cache * * @param context The context */ static void initializeDiskCache(Context context) { if (diskCache != null) return; File cacheDir = new File(context.getCacheDir(), "album_art"); int versionCode; try { PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); versionCode = info.versionCode; //Initialize the disk cache with a limit of 5 MB storage (fits ~830 images, taking Spotify as reference) diskCache = DiskLruCache.open(cacheDir, versionCode, 1, 1000 * 1000 * 5); } catch (PackageManager.NameNotFoundException e) { throw new AssertionError(e); } catch (IOException e) { Log.e("KDE/Mpris/AlbumArtCache", "Could not open the album art disk cache!", e); } connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); }
mDiskCache = DiskLruCache.open(directory, appVersion, 1, maxSizeDisk);
/** * 初始化 DiskLruCache */ private void initDiskLruCache() { try { File cacheDir = DiskCacheUtil.getDiskCacheDir(mContext, "image_cache"); if (!cacheDir.exists()) { cacheDir.mkdirs(); } int versionCode = DiskCacheUtil.getAppVersionCode(mContext); mDiskLruCache = DiskLruCache.open(cacheDir, versionCode, 1, maxSize); } catch (Exception e) { e.printStackTrace(); } }
public ImageDiskLrucache(Context mContext){ File diskCacheDir = getDidkCacheDir(mContext, "bitmap"); if(!diskCacheDir.exists()){ diskCacheDir.mkdirs(); } //sd卡的可用空间大于本地缓存的大小 if(getUsableSpace(diskCacheDir)>DISK_CACHE_SIZE){ //实例化diskLrucache try { mDiskLruCache =DiskLruCache.open(diskCacheDir,1,1,DISK_CACHE_SIZE); mIsDiskLruCacheCreated =true; } catch (IOException e) { e.printStackTrace(); } }else{ mIsDiskLruCacheCreated =false; } }
public InternalCache() { File directory = new File(AppContext.getInstance().getDir(Constants.CACHE_HOME_DIR, Context.MODE_PRIVATE), Constants.DEFAULT_DISK_FILE_PATH); try { mDiskCache = DiskLruCache.open(directory, Constants.VERSION, 2, Constants.CACHE_SIZE); } catch (IOException e) { LogUtils.e(TAG, e.getMessage()); } }
public DiskCacheManager(Context context, String uniqueName) { try { //先关闭已有的缓存 if (mDiskLruCache != null) { mDiskLruCache.close(); mDiskLruCache = null; } File cacheFile = getCacheFile(context, uniqueName); mDiskLruCache = DiskLruCache.open(cacheFile, MyApplication.getAppVersion(), 1, Constants.CACHE_MAXSIZE); } catch (IOException e) { e.printStackTrace(); } }