Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 7ff0ce8

Browse files
committed
Fix NPE bug and clean up logic for setting the title bar
1 parent a2b9060 commit 7ff0ce8

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -460,27 +460,24 @@ public void onListResume(MessageListFragment list) {
460460
currentList = list;
461461

462462
NarrowFilter filter = list.filter;
463-
464463
if (filter == null) {
465-
if (android.os.Build.VERSION.SDK_INT >= 11) {
466-
getActionBar().setTitle("Zulip");
467-
getActionBar().setSubtitle(null);
468-
}
464+
setupTitleBar(getString(R.string.app_name), null);
469465
this.drawerToggle.setDrawerIndicatorEnabled(true);
470466
} else {
471-
String title = list.filter.getTitle();
472-
if (android.os.Build.VERSION.SDK_INT >= 11) {
473-
if (title != null) {
474-
getActionBar().setTitle(title);
475-
}
476-
getActionBar().setSubtitle(list.filter.getSubtitle());
477-
}
467+
setupTitleBar(filter.getTitle(), filter.getSubtitle());
478468
this.drawerToggle.setDrawerIndicatorEnabled(false);
479469
}
480470

481471
this.drawerLayout.closeDrawers();
482472
}
483473

474+
private void setupTitleBar(String title, String subtitle) {
475+
if (android.os.Build.VERSION.SDK_INT >= 11 && getActionBar() != null) {
476+
if (title != null) getActionBar().setTitle(title);
477+
getActionBar().setSubtitle(subtitle);
478+
}
479+
}
480+
484481
public void doNarrow(NarrowFilter filter) {
485482
narrowedList = MessageListFragment.newInstance(filter);
486483
// Push to the back stack if we are not already narrowed

0 commit comments

Comments
 (0)