Fix #144 - Null pointer on BottomMenu

This commit is contained in:
Thomas 2022-06-08 09:08:16 +02:00
parent 87eba3db2f
commit 85da5043b0
2 changed files with 14 additions and 12 deletions

View file

@ -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;

View file

@ -183,7 +183,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
*/
private void manageMentions(Context context, Status statusDraft, ComposeViewHolder holder) {
if (statusDraft.mentions != null && (statusDraft.text == null || statusDraft.text.length() == 0)) {
if (statusDraft.mentions != null && (statusDraft.text == null || statusDraft.text.length() == 0) && statusDraft.mentions.size() > 0) {
//Retrieves mentioned accounts + OP and adds them at the beginin of the toot
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
Mention inReplyToUser = null;