Avoid crashing when opening an app context menu in list mode

This commit is contained in:
Cameron Gutman 2018-10-05 01:42:19 -07:00
parent d7d8c40565
commit 62e175f069

View File

@ -345,10 +345,15 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Only add an option to create shortcut if box art is loaded // 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); ImageView appImageView = info.targetView.findViewById(R.id.grid_image);
BitmapDrawable drawable = (BitmapDrawable)appImageView.getDrawable(); if (appImageView != null) {
if (drawable != null && drawable.getBitmap() != null) { // We have a grid ImageView, so we must be in grid-mode
menu.add(Menu.NONE, CREATE_SHORTCUT_ID, 4, getResources().getString(R.string.applist_menu_scut)); 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));
}
} }
} }
} }