From 62e175f069eb1e9f574b1dc4554bcdf6eb03dc75 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 5 Oct 2018 01:42:19 -0700 Subject: [PATCH] Avoid crashing when opening an app context menu in list mode --- app/src/main/java/com/limelight/AppView.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/limelight/AppView.java b/app/src/main/java/com/limelight/AppView.java index 5ad7c82e..2c923c48 100644 --- a/app/src/main/java/com/limelight/AppView.java +++ b/app/src/main/java/com/limelight/AppView.java @@ -345,10 +345,15 @@ public class AppView extends Activity implements AdapterFragmentCallbacks { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // Only add an option to create shortcut if box art is loaded + // and when we're in grid-mode (not list-mode). ImageView appImageView = info.targetView.findViewById(R.id.grid_image); - BitmapDrawable drawable = (BitmapDrawable)appImageView.getDrawable(); - if (drawable != null && drawable.getBitmap() != null) { - menu.add(Menu.NONE, CREATE_SHORTCUT_ID, 4, getResources().getString(R.string.applist_menu_scut)); + if (appImageView != null) { + // We have a grid ImageView, so we must be in grid-mode + BitmapDrawable drawable = (BitmapDrawable)appImageView.getDrawable(); + if (drawable != null && drawable.getBitmap() != null) { + // We have a bitmap loaded too + menu.add(Menu.NONE, CREATE_SHORTCUT_ID, 4, getResources().getString(R.string.applist_menu_scut)); + } } } }