From 8770575c959126a099f1059c4cafca77c51933c6 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Fri, 7 Apr 2017 14:36:16 +0200 Subject: [PATCH] Fixed NullPointerException --- .../main/java/ch/dissem/apps/abit/MainActivity.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ch/dissem/apps/abit/MainActivity.java b/app/src/main/java/ch/dissem/apps/abit/MainActivity.java index 9a2d9b0..e7aaa9a 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MainActivity.java +++ b/app/src/main/java/ch/dissem/apps/abit/MainActivity.java @@ -379,7 +379,10 @@ public class MainActivity extends AppCompatActivity for (Label label : labels) { addLabelEntry(label); } - drawer.setSelection(drawer.getDrawerItem(selectedLabel)); + IDrawerItem selectedDrawerItem = drawer.getDrawerItem(selectedLabel); + if (selectedDrawerItem != null) { + drawer.setSelection(selectedDrawerItem); + } } }.execute(); } @@ -395,8 +398,10 @@ public class MainActivity extends AppCompatActivity protected void onRestoreInstanceState(Bundle savedInstanceState) { selectedLabel = (Label) savedInstanceState.getSerializable("selectedLabel"); - drawer.setSelection(drawer.getDrawerItem(selectedLabel)); - + IDrawerItem selectedItem = drawer.getDrawerItem(selectedLabel); + if (selectedItem != null) { + drawer.setSelection(selectedItem); + } super.onRestoreInstanceState(savedInstanceState); }