diff --git a/app/src/main/java/com/limelight/grid/AppGridAdapter.java b/app/src/main/java/com/limelight/grid/AppGridAdapter.java index c7f31ed6..91bf6243 100644 --- a/app/src/main/java/com/limelight/grid/AppGridAdapter.java +++ b/app/src/main/java/com/limelight/grid/AppGridAdapter.java @@ -26,7 +26,7 @@ public class AppGridAdapter extends GenericGridAdapter { private final CachedAppAssetLoader loader; public AppGridAdapter(Activity activity, boolean listMode, boolean small, ComputerDetails computer, String uniqueId) { - super(activity, listMode ? R.layout.simple_row : (small ? R.layout.app_grid_item_small : R.layout.app_grid_item), R.drawable.image_loading); + super(activity, listMode ? R.layout.simple_row : (small ? R.layout.app_grid_item_small : R.layout.app_grid_item)); int dpi = activity.getResources().getDisplayMetrics().densityDpi; int dp; @@ -51,9 +51,7 @@ public class AppGridAdapter extends GenericGridAdapter { this.loader = new CachedAppAssetLoader(computer, scalingDivisor, new NetworkAssetLoader(context, uniqueId), new MemoryAssetLoader(), - new DiskAssetLoader(context.getCacheDir()), - BitmapFactory.decodeResource(activity.getResources(), - R.drawable.image_loading, options)); + new DiskAssetLoader(context.getCacheDir())); } public void cancelQueuedOperations() { @@ -110,4 +108,9 @@ public class AppGridAdapter extends GenericGridAdapter { // No overlay return false; } + + @Override + public boolean shouldShowProgressBar(AppView.AppObject obj) { + return true; + } } diff --git a/app/src/main/java/com/limelight/grid/GenericGridAdapter.java b/app/src/main/java/com/limelight/grid/GenericGridAdapter.java index 19da13c5..7f8826ea 100644 --- a/app/src/main/java/com/limelight/grid/GenericGridAdapter.java +++ b/app/src/main/java/com/limelight/grid/GenericGridAdapter.java @@ -6,6 +6,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; +import android.widget.ProgressBar; import android.widget.TextView; import com.limelight.R; @@ -14,15 +15,13 @@ import java.util.ArrayList; public abstract class GenericGridAdapter extends BaseAdapter { protected final Context context; - protected final int defaultImageRes; protected final int layoutId; protected final ArrayList itemList = new ArrayList<>(); protected final LayoutInflater inflater; - public GenericGridAdapter(Context context, int layoutId, int defaultImageRes) { + public GenericGridAdapter(Context context, int layoutId) { this.context = context; this.layoutId = layoutId; - this.defaultImageRes = defaultImageRes; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @@ -49,6 +48,7 @@ public abstract class GenericGridAdapter extends BaseAdapter { public abstract boolean populateImageView(ImageView imgView, T obj); public abstract boolean populateTextView(TextView txtView, T obj); public abstract boolean populateOverlayView(ImageView overlayView, T obj); + public abstract boolean shouldShowProgressBar(T obj); @Override public View getView(int i, View convertView, ViewGroup viewGroup) { @@ -59,10 +59,19 @@ public abstract class GenericGridAdapter extends BaseAdapter { ImageView imgView = (ImageView) convertView.findViewById(R.id.grid_image); ImageView overlayView = (ImageView) convertView.findViewById(R.id.grid_overlay); TextView txtView = (TextView) convertView.findViewById(R.id.grid_text); + ProgressBar prgView = (ProgressBar) convertView.findViewById(R.id.grid_spinner); + if (prgView != null) { + if (shouldShowProgressBar(itemList.get(i))) { + prgView.setVisibility(View.VISIBLE); + } + else { + prgView.setVisibility(View.INVISIBLE); + } + } if (imgView != null) { if (!populateImageView(imgView, itemList.get(i))) { - imgView.setImageResource(defaultImageRes); + imgView.setImageBitmap(null); } } if (!populateTextView(txtView, itemList.get(i))) { diff --git a/app/src/main/java/com/limelight/grid/PcGridAdapter.java b/app/src/main/java/com/limelight/grid/PcGridAdapter.java index c6b22e41..b753ec0c 100644 --- a/app/src/main/java/com/limelight/grid/PcGridAdapter.java +++ b/app/src/main/java/com/limelight/grid/PcGridAdapter.java @@ -14,7 +14,7 @@ import java.util.Comparator; public class PcGridAdapter extends GenericGridAdapter { public PcGridAdapter(Context context, boolean listMode, boolean small) { - super(context, listMode ? R.layout.simple_row : (small ? R.layout.pc_grid_item_small : R.layout.pc_grid_item), R.drawable.computer); + super(context, listMode ? R.layout.simple_row : (small ? R.layout.pc_grid_item_small : R.layout.pc_grid_item)); } public void addComputer(PcView.ComputerObject computer) { @@ -37,20 +37,20 @@ public class PcGridAdapter extends GenericGridAdapter { @Override public boolean populateImageView(ImageView imgView, PcView.ComputerObject obj) { - if (obj.details.reachability != ComputerDetails.Reachability.OFFLINE) { + if (obj.details.state == ComputerDetails.State.ONLINE) { imgView.setAlpha(1.0f); } else { imgView.setAlpha(0.4f); } - // Return false to use the default drawable - return false; + imgView.setImageResource(R.drawable.computer); + return true; } @Override public boolean populateTextView(TextView txtView, PcView.ComputerObject obj) { - if (obj.details.reachability != ComputerDetails.Reachability.OFFLINE) { + if (obj.details.state == ComputerDetails.State.ONLINE) { txtView.setAlpha(1.0f); } else { @@ -63,13 +63,13 @@ public class PcGridAdapter extends GenericGridAdapter { @Override public boolean populateOverlayView(ImageView overlayView, PcView.ComputerObject obj) { - if (obj.details.reachability == ComputerDetails.Reachability.UNKNOWN) { - // Still refreshing this PC so display the overlay - overlayView.setImageResource(R.drawable.image_loading); - return true; - } - // No overlay return false; } + + @Override + public boolean shouldShowProgressBar(PcView.ComputerObject obj) { + // Still refreshing this PC so display the progress bar + return obj.details.reachability == ComputerDetails.Reachability.UNKNOWN; + } } diff --git a/app/src/main/java/com/limelight/grid/assets/CachedAppAssetLoader.java b/app/src/main/java/com/limelight/grid/assets/CachedAppAssetLoader.java index 8627841d..66f1e093 100644 --- a/app/src/main/java/com/limelight/grid/assets/CachedAppAssetLoader.java +++ b/app/src/main/java/com/limelight/grid/assets/CachedAppAssetLoader.java @@ -53,13 +53,13 @@ public class CachedAppAssetLoader { public CachedAppAssetLoader(ComputerDetails computer, double scalingDivider, NetworkAssetLoader networkLoader, MemoryAssetLoader memoryLoader, - DiskAssetLoader diskLoader, Bitmap placeholderBitmap) { + DiskAssetLoader diskLoader) { this.computer = computer; this.scalingDivider = scalingDivider; this.networkLoader = networkLoader; this.memoryLoader = memoryLoader; this.diskLoader = diskLoader; - this.placeholderBitmap = placeholderBitmap; + this.placeholderBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); } public void cancelBackgroundLoads() { @@ -280,14 +280,14 @@ public class CachedAppAssetLoader { }); } - public void populateImageView(NvApp app, ImageView view) { + public boolean populateImageView(NvApp app, ImageView view) { LoaderTuple tuple = new LoaderTuple(computer, app); // If there's already a task in progress for this view, // cancel it. If the task is already loading the same image, // we return and let that load finish. if (!cancelPendingLoad(tuple, view)) { - return; + return true; } // First, try the memory cache in the current context @@ -296,7 +296,7 @@ public class CachedAppAssetLoader { // Show the bitmap immediately view.setAlpha(1.0f); view.setImageBitmap(bmp); - return; + return true; } // If it's not in memory, create an async task to load it. This task will be attached @@ -308,6 +308,7 @@ public class CachedAppAssetLoader { // Run the task on our foreground executor task.executeOnExecutor(foregroundExecutor, tuple); + return false; } public class LoaderTuple { diff --git a/app/src/main/res/drawable/image_loading.png b/app/src/main/res/drawable/image_loading.png deleted file mode 100644 index e03a5d77..00000000 Binary files a/app/src/main/res/drawable/image_loading.png and /dev/null differ diff --git a/app/src/main/res/layout-land/activity_pc_view.xml b/app/src/main/res/layout-land/activity_pc_view.xml index 523341b9..eb870d39 100644 --- a/app/src/main/res/layout-land/activity_pc_view.xml +++ b/app/src/main/res/layout-land/activity_pc_view.xml @@ -15,18 +15,18 @@ android:layout_centerInParent="true" android:layout_centerVertical="true" android:layout_centerHorizontal="true"> - + android:indeterminate="true"/> - + android:indeterminate="true"/> + + + + - - + android:layout_height="50dp" + android:indeterminate="true"> + - - + android:layout_height="33dp" + android:indeterminate="true"> + IP address of GeForce PC - Searching for PCs… + Searching for PCs with GeForce Experience running… Yes No Lost connection to PC