Display a placeholder box art bitmap while loading box art

This commit is contained in:
Cameron Gutman
2019-11-05 00:19:58 -08:00
parent b729fba75e
commit 88d6143897
5 changed files with 25 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
package com.limelight.grid;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -76,7 +77,8 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
this.loader = new CachedAppAssetLoader(computer, scalingDivisor,
new NetworkAssetLoader(context, uniqueId),
new MemoryAssetLoader(),
new DiskAssetLoader(context));
new DiskAssetLoader(context),
BitmapFactory.decodeResource(context.getResources(), R.drawable.no_app_image));
// This will trigger the view to reload with the new layout
setLayoutId(getLayoutIdForPreferences(prefs));

View File

@@ -52,15 +52,17 @@ public class CachedAppAssetLoader {
private final MemoryAssetLoader memoryLoader;
private final DiskAssetLoader diskLoader;
private final Bitmap placeholderBitmap;
private final Bitmap noAppImageBitmap;
public CachedAppAssetLoader(ComputerDetails computer, double scalingDivider,
NetworkAssetLoader networkLoader, MemoryAssetLoader memoryLoader,
DiskAssetLoader diskLoader) {
DiskAssetLoader diskLoader, Bitmap noAppImageBitmap) {
this.computer = computer;
this.scalingDivider = scalingDivider;
this.networkLoader = networkLoader;
this.memoryLoader = memoryLoader;
this.diskLoader = diskLoader;
this.noAppImageBitmap = noAppImageBitmap;
this.placeholderBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
}
@@ -188,9 +190,10 @@ public class CachedAppAssetLoader {
prgView.setVisibility(View.VISIBLE);
}
// Set off another loader task on the network executor
// Set off another loader task on the network executor. This time our AsyncDrawable
// will use the app image placeholder bitmap, rather than an empty bitmap.
LoaderTask task = new LoaderTask(imageView, prgView, false);
AsyncDrawable asyncDrawable = new AsyncDrawable(imageView.getResources(), placeholderBitmap, task);
AsyncDrawable asyncDrawable = new AsyncDrawable(imageView.getResources(), noAppImageBitmap, task);
imageView.setVisibility(View.VISIBLE);
imageView.setImageDrawable(asyncDrawable);
task.executeOnExecutor(networkExecutor, tuple);