DefaultBrazeImageLoader

class DefaultBrazeImageLoader(context: Context) : IBrazeImageLoader

Default IBrazeImageLoader implementation that uses an in-memory LRU cache backed by a disk LRU cache for bitmap storage.

Constructors

Link copied to clipboard
constructor(context: Context)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
private lateinit var diskLruCache: ERROR CLASS: Symbol not found for BitmapDiskLruCacheWrapper
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val memoryCache: LruCache<String, Bitmap>

Functions

Link copied to clipboard
fun downloadBitmapFromUrl(context: Context, imageUri: Uri, viewBounds: BrazeViewBounds? = BrazeViewBounds.NO_BOUNDS): BitmapAndHeaders
Link copied to clipboard
fun getBitmapFromCache(key: String): Bitmap?

Tries to get a bitmap first from memory cache, then from disk.

Link copied to clipboard
fun getBitmapFromDiskCache(key: String): Bitmap?
Link copied to clipboard
fun getBitmapFromMemCache(key: String): Bitmap?
Link copied to clipboard
fun getBitmapFromUrl(context: Context, imageUrl: String, viewBounds: BrazeViewBounds?): Bitmap?
Link copied to clipboard
open override fun getInAppMessageBitmapFromUrl(context: Context, inAppMessage: IInAppMessage, imageUrl: String, viewBounds: BrazeViewBounds?): Bitmap?

Attempts to retrieve the bitmap representing the imageUrl's image from the imageLoader's caches. If no such bitmap is cached, the bitmap will be retrieved directly from the URL and the bitmap will be cached.

Link copied to clipboard
open override fun getPushBitmapFromUrl(context: Context, extras: Bundle?, imageUrl: String, viewBounds: BrazeViewBounds?): Bitmap?

Attempts to retrieve the bitmap representing the imageUrl's image from the imageLoader's caches. If no such bitmap is cached, the bitmap will be retrieved directly from the URL and the bitmap will be cached.

Link copied to clipboard
private fun initDiskCacheTask(context: Context)
Link copied to clipboard
fun putBitmapIntoCache(key: String, bitmap: Bitmap, skipDiskCache: Boolean)
Link copied to clipboard
private fun putBitmapIntoMemCache(key: String, bitmap: Bitmap): Bitmap?
Link copied to clipboard
open override fun renderUrlIntoCardView(context: Context, card: Card, imageUrl: String, imageView: ImageView, viewBounds: BrazeViewBounds?)

Renders the image for a Content Card at the imageUrl into the ImageView. If the image's bitmap is not already cached, the bitmap should be retrieved directly from the URL and the bitmap will be cached.

Link copied to clipboard
open override fun renderUrlIntoInAppMessageView(context: Context, inAppMessage: IInAppMessage, imageUrl: String, imageView: ImageView, viewBounds: BrazeViewBounds?)

Renders the image for an IInAppMessage at the imageUrl into the ImageView. If the image's bitmap is not already cached, the bitmap should be retrieved directly from the URL and the bitmap will be cached.

Link copied to clipboard
private fun renderUrlIntoView(context: Context, imageUrl: String, imageView: ImageView, viewBounds: BrazeViewBounds?)
Link copied to clipboard
internal fun renderUrlIntoViewTask(context: Context, imageView: ImageView, viewBounds: BrazeViewBounds?, imageUrl: String)
Link copied to clipboard
open override fun setOffline(isOffline: Boolean)

Set this image loader offline. In offline mode, the image loader should only load locally cached images.

Link copied to clipboard
fun shouldSkipCaching(imageUri: Uri, headers: Map<String, List<String>>?): Boolean

Determines whether an image should be cached based on the image uri and headers.

Link copied to clipboard
open override fun shutdown()

Shuts down the image loader. This should be called when the object is going away to give the loader a chance to clean up any resources it may be holding. No-op by default.