From 85da5043b0ec2c35df5e76179ec4410bc46d5a4e Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 8 Jun 2022 09:08:16 +0200 Subject: [PATCH] Fix #144 - Null pointer on BottomMenu --- .../client/entities/app/BottomMenu.java | 24 ++++++++++--------- .../android/ui/drawer/ComposeAdapter.java | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/client/entities/app/BottomMenu.java b/app/src/main/java/app/fedilab/android/client/entities/app/BottomMenu.java index 35695ed1..e1f6d5ba 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/app/BottomMenu.java +++ b/app/src/main/java/app/fedilab/android/client/entities/app/BottomMenu.java @@ -93,17 +93,19 @@ public class BottomMenu implements Serializable { } public static int getPosition(BottomMenu bottomMenu, @IdRes int idRes) { - for (MenuItem menuItem : bottomMenu.bottom_menu) { - if (idRes == R.id.nav_home && menuItem.item_menu_type == ItemMenuType.HOME) { - return menuItem.position; - } else if (idRes == R.id.nav_local && menuItem.item_menu_type == ItemMenuType.LOCAL) { - return menuItem.position; - } else if (idRes == R.id.nav_public && menuItem.item_menu_type == ItemMenuType.PUBLIC) { - return menuItem.position; - } else if (idRes == R.id.nav_notifications && menuItem.item_menu_type == ItemMenuType.NOTIFICATION) { - return menuItem.position; - } else if (idRes == R.id.nav_privates && menuItem.item_menu_type == ItemMenuType.DIRECT) { - return menuItem.position; + if (bottomMenu != null && bottomMenu.bottom_menu != null) { + for (MenuItem menuItem : bottomMenu.bottom_menu) { + if (idRes == R.id.nav_home && menuItem.item_menu_type == ItemMenuType.HOME) { + return menuItem.position; + } else if (idRes == R.id.nav_local && menuItem.item_menu_type == ItemMenuType.LOCAL) { + return menuItem.position; + } else if (idRes == R.id.nav_public && menuItem.item_menu_type == ItemMenuType.PUBLIC) { + return menuItem.position; + } else if (idRes == R.id.nav_notifications && menuItem.item_menu_type == ItemMenuType.NOTIFICATION) { + return menuItem.position; + } else if (idRes == R.id.nav_privates && menuItem.item_menu_type == ItemMenuType.DIRECT) { + return menuItem.position; + } } } return -1; diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java index afbce5a0..5dab3aec 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java @@ -183,7 +183,7 @@ public class ComposeAdapter extends RecyclerView.Adapter 0) { //Retrieves mentioned accounts + OP and adds them at the beginin of the toot final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); Mention inReplyToUser = null;