public void put(@Nullable String cacheKey, LottieComposition composition) { if (cacheKey == null) { return; } cache.put(cacheKey, composition); }
@Override public void putBitmap(String url, Bitmap bitmap) { cache.put(url, bitmap); } });
/** * Puts an artist image to the cache * * @param artist Artist object used as cache key * @param bm Bitmap to store in cache */ public synchronized void putArtistImage(ArtistModel artist, Bitmap bm) { if (bm != null) { mCache.put(getArtistHash(artist), bm); } }
/** * Puts an album image to the cache * * @param album Album object to use for cache key * @param bm Bitmap to store in cache */ public synchronized void putAlbumBitmap(AlbumModel album, Bitmap bm) { if (bm != null) { mCache.put(getAlbumHash(album), bm); } }
public static void initAdd(Context context, AppInfo appInfo) { init(context); if (sLruCache.evictionCount() == 0) { sLruCache .put(appInfo.packageName, appInfo.applicationInfo.loadIcon(context.getPackageManager())); } }
private static final Bitmap getVideoThumbnail(final ContentResolver cr, final long hashCode, final long id, final int requestWidth, final int requestHeight) throws FileNotFoundException, IOException { // try to get from internal thumbnail cache(in memory), this may be redundant final String key = getKey(hashCode, id); Bitmap result = sThumbnailCache.get(key); if (result == null) { BitmapFactory.Options options = null; int kind = MediaStore.Video.Thumbnails.MICRO_KIND; if ((requestWidth > 96) || (requestHeight > 96) || (requestWidth * requestHeight > 128 * 128)) kind = MediaStore.Video.Thumbnails.MINI_KIND; try { result = MediaStore.Video.Thumbnails.getThumbnail(cr, id, kind, options); } catch (final Exception e) { if (DEBUG) Log.w(TAG, e); } if (result != null) { if (DEBUG) Log.v(TAG, String.format("getVideoThumbnail:id=%d(%d,%d)", id, result.getWidth(), result.getHeight())); // add to internal thumbnail cache(in memory) sThumbnailCache.put(key, result); } else { Log.w(TAG, "failed to get video thumbnail ofr id=" + id); } } return result; }
cacheItem.failedFetch = true; cacheItem.albumArt = null; memoryCache.put(url.toString(), cacheItem);
@NonNull public Model getItem(int position) throws NoValueException { if (position >= getItemCount()) { throw new NoValueException( "ouf of range: getItem(" + position + ") for the relation with " + getItemCount() + " items"); } Model item = cache.get(position); if (item == null) { item = relation.get(position); cache.put(position, item); } return item; }
/** * Simple getter for the model data. * This method will call the PBS to get the trackmodel from the current playlist. * * @param position Index of the track to get. No check for boundaries here. * @return The trackmodel at index position. */ @Override public Object getItem(int position) { try { if (mPlaybackServiceConnection != null) { // Check cache first for a hit TrackModel track = mTrackCache.get(position); if (track == null) { track = mPlaybackServiceConnection.getPBS().getPlaylistSong(position); mTrackCache.put(position, track); } return track; } else { return null; } } catch (RemoteException e) { return null; } }
public static Drawable getDrawable(Context context, AppInfo appInfo) { init(context); Drawable drawable = sLruCache.get(appInfo.packageName); if (drawable == null && appInfo.applicationInfo != null) { if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP_MR1) { drawable = appInfo.applicationInfo.loadUnbadgedIcon(context.getPackageManager()); }else { drawable = appInfo.applicationInfo.loadIcon(context.getPackageManager()); } UserInfo currentUser = Users.getInstance().getCurrentUser(); if(currentUser != null && currentUser.isManagedProfile()){ drawable = context.getPackageManager().getUserBadgedIcon(drawable,currentUser.getUserHandle()); } sLruCache.put(appInfo.packageName, drawable); } return drawable; }
id, result.getWidth(), result.getHeight())); sThumbnailCache.put(key, result);