Check if menu item is null before adding assistant new badge
It crashes because there's no assistant in AOSP Contacts.
Bug: 32915307
Test: manual - verified that there's no crash in opening AOSP Contacts
and that the new badge works well on GoogleContacts.
Change-Id: I3cc14da0c9e50fe0b2f4840645ded8c2563fbc65
diff --git a/src/com/android/contacts/ContactsDrawerActivity.java b/src/com/android/contacts/ContactsDrawerActivity.java
index e348a20..79d0fe2 100644
--- a/src/com/android/contacts/ContactsDrawerActivity.java
+++ b/src/com/android/contacts/ContactsDrawerActivity.java
@@ -265,8 +265,12 @@
if (mNavigationView == null) {
return;
}
- final LinearLayout newBadgeFrame = (LinearLayout) MenuItemCompat.getActionView(
- mNavigationView.getMenu().findItem(R.id.nav_assistant));
+ final MenuItem assistantMenu = mNavigationView.getMenu().findItem(R.id.nav_assistant);
+ if (assistantMenu == null) {
+ return;
+ }
+ final LinearLayout newBadgeFrame =
+ (LinearLayout) MenuItemCompat.getActionView(assistantMenu);
final boolean showWelcomeBadge = !SharedPreferenceUtil.isWelcomeCardDismissed(this);
if (showWelcomeBadge && newBadgeFrame.getChildCount() == 0) {
if (mAssistantNewBadge == null) {