Tabnine Logo
DiskLruCache$Value.getFile
Code IndexAdd Tabnine to your IDE (free)

How to use
getFile
method
in
com.bumptech.glide.disklrucache.DiskLruCache$Value

Best Java code snippets using com.bumptech.glide.disklrucache.DiskLruCache$Value.getFile (Showing top 6 results out of 315)

origin: bumptech/glide

@Override
public File get(Key key) {
 String safeKey = safeKeyGenerator.getSafeKey(key);
 if (Log.isLoggable(TAG, Log.VERBOSE)) {
  Log.v(TAG, "Get: Obtained: " + safeKey + " for for Key: " + key);
 }
 File result = null;
 try {
  // It is possible that the there will be a put in between these two gets. If so that shouldn't
  // be a problem because we will always put the same value at the same key so our input streams
  // will still represent the same data.
  final DiskLruCache.Value value = getDiskCache().get(safeKey);
  if (value != null) {
   result = value.getFile(0);
  }
 } catch (IOException e) {
  if (Log.isLoggable(TAG, Log.WARN)) {
   Log.w(TAG, "Unable to get from disk cache", e);
  }
 }
 return result;
}
origin: guolindev/giffun

@Override
public File get(Key key) {
  String safeKey = safeKeyGenerator.getSafeKey(key);
  File result = null;
  try {
    //It is possible that the there will be a put in between these two gets. If so that shouldn't be a problem
    //because we will always put the same value at the same key so our input streams will still represent
    //the same data
    final DiskLruCache.Value value = getDiskCache().get(safeKey);
    if (value != null) {
      result = value.getFile(0);
    }
  } catch (IOException e) {
    if (Log.isLoggable(TAG, Log.WARN)) {
      Log.w(TAG, "Unable to get from disk cache", e);
    }
  }
  return result;
}
origin: amahi/android

private Bitmap getBitmap(DiskLruCache.Value value) {
  Bitmap bitmap = null;
  final File file = value.getFile(BITMAP_INDEX);
  if (file != null) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    FileInputStream fileInputStream = null;
    try {
      fileInputStream = new FileInputStream(file);
      bitmap = BitmapFactory.decodeStream(fileInputStream, null, options);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } finally {
      if (fileInputStream != null) {
        try {
          fileInputStream.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
  return bitmap;
}
origin: mozilla-tw/Rocket

@Override
public File get(Key key) {
 String safeKey = safeKeyGenerator.getSafeKey(key);
 if (Log.isLoggable(TAG, Log.VERBOSE)) {
  Log.v(TAG, "Get: Obtained: " + safeKey + " for for Key: " + key);
 }
 File result = null;
 try {
  // It is possible that the there will be a put in between these two gets. If so that shouldn't
  // be a problem because we will always put the same value at the same key so our input streams
  // will still represent the same data.
  final DiskLruCache.Value value = getDiskCache().get(safeKey);
  if (value != null) {
   result = value.getFile(0);
  }
 } catch (IOException e) {
  if (Log.isLoggable(TAG, Log.WARN)) {
   Log.w(TAG, "Unable to get from disk cache", e);
  }
 }
 return result;
}
origin: REBOOTERS/AndroidAnimationExercise

/**
 * 获取是否有某张原图的缓存
 * 缓存模式必须是:DiskCacheStrategy.SOURCE 才能获取到缓存文件
 */
public static File getGlideCacheFile(Context context, String url) {
  try {
    OriginalKey originalKey = new OriginalKey(url, EmptySignature.obtain());
    SafeKeyGenerator safeKeyGenerator = new SafeKeyGenerator();
    String safeKey = safeKeyGenerator.getSafeKey(originalKey);
    File file = new File(context.getCacheDir(), DiskCache.Factory.DEFAULT_DISK_CACHE_DIR);
    DiskLruCache diskLruCache = DiskLruCache.open(file, 1, 1, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE);
    DiskLruCache.Value value = diskLruCache.get(safeKey);
    if (value != null) {
      return value.getFile(0);
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
}
origin: mozilla-tw/FirefoxLite

@Test public void readingTheSameFileMultipleTimes() throws Exception {
 set("a", "a", "b");
 DiskLruCache.Value value = cache.get("a");
 assertThat(value.getFile(0)).isSameAs(value.getFile(0));
}
com.bumptech.glide.disklrucacheDiskLruCache$ValuegetFile

Popular methods of DiskLruCache$Value

  • <init>
  • getString
    Returns the string value for index.
  • edit
    Returns an editor for this snapshot's entry, or null if either the entry has changed since this snap
  • getLength
    Returns the byte length of the value for index.

Popular in Java

  • Running tasks concurrently on multiple threads
  • getContentResolver (Context)
  • findViewById (Activity)
  • addToBackStack (FragmentTransaction)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JTextField (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now