From bfde7d583902a4fe4bbecafef291720a9dfb5554 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sun, 12 Oct 2014 21:27:48 -0400 Subject: [PATCH] Fix NPE trying to open a book --- .../activity/viewer/ExpListNavDrawerFragment.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/ExpListNavDrawerFragment.java b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/ExpListNavDrawerFragment.java index c8e8e8e..9bc3419 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/ExpListNavDrawerFragment.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/ExpListNavDrawerFragment.java @@ -70,9 +70,9 @@ public class ExpListNavDrawerFragment extends NavDrawerFragment { // I really don't like how we build the chapters, but I'm not adding Guava just for Range. // RXJava does get ridiculous with the angle brackets, you have me there. But Intellij // folds nicely. - Map> chapterMap = new HashMap>(); + Map> chapterMap; if (mainBook != null) { - vUtil.getBooks(mainBook).map(new Func1>>() { + chapterMap = vUtil.getBooks(mainBook).map(new Func1>>() { @Override public Map> call(BibleBook bibleBook) { // These lines are important @@ -103,13 +103,13 @@ public class ExpListNavDrawerFragment extends NavDrawerFragment { }) .toBlocking() .first(); + + ExpListNavAdapter adapter = + new ExpListNavAdapter(bibleBooks, chapterMap); + + mActualListView.setAdapter(adapter); } - ExpListNavAdapter adapter = - new ExpListNavAdapter(bibleBooks, chapterMap); - - mActualListView.setAdapter(adapter); - mActualListView.setItemChecked(mCurrentSelectedPosition, true); return mActualListView; }