How to leverage Glide cache for loading notification icons? Those are IconCompat used in the Person object in the MessagingStyle notifications and Shortcuts. Also, Bubbles require using both of those.
I used Glid as fallowing:
private IconCompat loadIcon(String url) throws ExecutionException, InterruptedException {
RequestOptions requestOptions = new RequestOptions().override(ADAPTIVE_BITMAP_SIZE);
Bitmap bitmap = Glide.with(G.app).asBitmap().apply(requestOptions).load(url).submit().get();
return IconCompat.createWithAdaptiveBitmap(bitmap);
}
I got several questions about this solution
- What should be the size of
ADAPTIVE_BITMAP_SIZE? - When will the bitmap get recycled?
- How to handle errors in loading the bitmap?