LruCache get - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for LruCache get method.

This code example shows how to use the following methods:get, put, remove
	} 
 
	public Bitmap getBitmap(long key) {
		Bitmap bm = getFolderBitmap(key);
		if (bm != null) return bm;
		return mContentCache.get(key);
	} 
	 
	public void clearAll() { 
		clearContent(); 
		clearFolder(); 
	} 
	 
	public void clearContent() { 
		mContentCache.evictAll();
	} 
	 
	public void clearFolder() { 
		mFolderCache.evictAll();
	} 

7
CodeRank
This code example shows how to use the following methods:get
     * If only wants values that are not expired, use {@link #get(Object)} instead. 
     * 
     * @param key the key to look up 
     */ 
    public CachedValue<V> getCachedValue(K key) {
        return mCache.get(key);
    } 
 
    /** 
     * Returns the value for the given key, or null if no value exists. 
     * <p> 
     * When using this method, it is not possible to determine whether the value is expired or not. 
     * Use {@link #getCachedValue(Object)} to achieve that instead. However, if using 
     * {@link #getCachedValue(Object)} to determine if an item is expired, one should use the item 
     * within the {@link CachedValue} and not call {@link #getPossiblyExpired(Object)} to get the 
     * value afterwards, since that is not guaranteed to return the same value or that the newly 
     * returned value is in the same state. 
     * 
     * @param key the key to look up 
     */ 
6
CodeRank
This code example shows how to use the following methods:get, put
        mPadding      = context.getResources().getDimensionPixelOffset(R.dimen.marker_padding  );
    } 
 
    public Bitmap get(String color, String route) {
        String key = color+"_"+route;
        Bitmap bitmap = mCache.get(key);
        if (bitmap != null) {
            return bitmap;
        } 
        bitmap = render(Color.parseColor(color), route);
        mCache.put(key, bitmap);
        return bitmap;
    } 
 
    private Bitmap render(int color, String text) {
        TextPaint textPaint = new TextPaint();
        textPaint.setColor(Color.WHITE);
        textPaint.setStyle(Paint.Style.FILL);
        textPaint.setAntiAlias(true);
        textPaint.setTextSize(mTextSize);
5
CodeRank
This code example shows how to use the following methods:get, put
 
	} 
 
	public void addBitmapToMemoryCache(String key, Bitmap bitmap) { 
		if (getBitmapFromMemCache(key) == null) { 
			mMemoryCache.put(key, bitmap); 
		} 
	} 
 
	public Bitmap getBitmapFromMemCache(String key) { 
		return (Bitmap) mMemoryCache.get(key); 
	} 
 
	public Bitmap decodeSampledBitmapFromUri(String path, int reqWidth, 
			int reqHeight) { 
		Bitmap bm = null; 
 
		// First decode with inJustDecodeBounds=true to check dimensions 
		final BitmapFactory.Options options = new BitmapFactory.Options(); 
		options.inJustDecodeBounds = true; 
4
CodeRank
This code example shows how to use the following methods:get, put
	 * @param imageUrl URL of bitmap 
	 * @return Loaded bitmap, or <code>null</code> 
	 */ 
	public Bitmap getImage(String imageUrl) {
		// Bitmap cached in memory? 
		Bitmap cachedBitmap = memoryCache.get(imageUrl);
		if (cachedBitmap != null) {
			return cachedBitmap;
		} 
		 
		// In file cache? 
		InputStream cachedImage = fileCache.getStream(imageUrl);
		if (cachedImage != null) {
			Bitmap bitmap = BitmapFactory.decodeStream(cachedImage);
			if (bitmap != null) {
				memoryCache.put(imageUrl, bitmap);
			} 
			try { 
				cachedImage.close();
			} catch (IOException e) {

4
CodeRank
This code example shows how to use the following methods:get, put
        bitmapInsertAllCache.execute();
    } 
 
    public void addBitmapToMemoryCache(String key){
        if (getBitmapFromMemCache(key) == null)
            mMemoryCashe.put(key, BitmapFactory.decodeFile(key));
    } 
 
    public Bitmap getBitmapFromMemCache(String key){
        return mMemoryCashe.get(key);
    } 
 
    public void clearBitmapToMemoryCache(String key){
        if (getBitmapFromMemCache(key) != null)
            mMemoryCashe.remove(key);
    } 
 
    @Override 
    public int getCount() { 
        return listNamePhoto.size();
4
CodeRank
This code example shows how to use the following methods:get
	} 
	 
	public BitmapDrawable getBitmapFromMemCache(String data) {
		BitmapDrawable memValue = null;
		if (mMemoryCache != null) {
			memValue = mMemoryCache.get(data);
			AppLogger.d("Memory cache hit: " + data);
		} 
		return memValue;
	} 
	 
	public Bitmap getBitmapFromDiskCache(String data) {
		final String key = hashKeyForDisk(data);
		Bitmap bitmap = null;
		if (mCacheParams.diskCacheDir != null && mCacheParams.diskCacheDir.exists()) {
			final String path = mCacheParams.diskCacheDir.getPath() + File.separator + key;
			bitmap = ImageResizer.decodeSampledBitmapFromFile(path, Integer.MAX_VALUE, Integer.MAX_VALUE, this);
		} 
		return bitmap;
	} 
4
CodeRank
This code example shows how to use the following methods:get, put
    public void add(final String data, final Bitmap bitmap) {
        if (data == null || bitmap == null) {
            return; 
        } 
        if (get(data) == null) {
            mLruCache.put(data, bitmap);
        } 
    } 
 
    public final Bitmap get(final String data) {
        if (data == null) {
            return null; 
        } 
        if (mLruCache != null) {
            final Bitmap mBitmap = mLruCache.get(data);
            if (mBitmap != null) {
                return mBitmap;
            } 
        } 
        return null; 
4
CodeRank
This code example shows how to use the following methods:get, put
 
	/** 
	 * Load the {@link Typeface} and apply to a {@link Spannable}. 
	 */ 
	public TypefaceSpan(Context context, String typefaceName) {
		mTypeface = sTypefaceCache.get(typefaceName);
 
		if (mTypeface == null) {
			mTypeface = Typeface.createFromAsset(context
					.getApplicationContext().getAssets(), String.format(
					"%s.ttf", typefaceName));
 
			// Cache the loaded Typeface 
			sTypefaceCache.put(typefaceName, mTypeface);
		} 
	} 
 
	@Override 
	public void updateMeasureState(TextPaint p) {
		p.setTypeface(mTypeface);
5
CodeRank
This code example shows how to use the following methods:get, put
	} 
	 
	public void addBitmapToMemoryCache(String key, Bitmap bitmap) {
		if(key!=null){
		    if (getBitmapFromMemCache(key) == null&&key.contains("/")&&bitmap!=null) {
		    	memoryCache.put(key, bitmap);
		    } 
	    } 
	} 
 
	public Bitmap getBitmapFromMemCache(String key) {
		Bitmap bitmapCache=null;
		if(key!=null)
			if(key.contains("/")){
				Log.d("Obtain from cache", key);
				bitmapCache= memoryCache.get(key);
				} 
		return bitmapCache;
	} 
	 
	public static CachingImage getCachingImage(){ 
5
CodeRank

Related LruCache get Questions & Answers:

Other LruCache get Examples

29:		@Override
30:		public Bitmap getBitmap(String url) {
31:			return get(url);
32:		}
33:

Read More

get Method Overview
Returns the value for key if it exists in the cache or can be created by #create.
See Code Examples for other Android LruCache Methods: