Fixed NullPointerException

This commit is contained in:
Christian Basler 2017-04-07 14:36:16 +02:00
parent 61c9cde2f5
commit 8770575c95
1 changed files with 8 additions and 3 deletions

View File

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