Don't scroll menu when drawer is open

Bug 30306059

Change-Id: I773d4be232029013556b448b78a8630aabca4695
diff --git a/src/com/android/contacts/ContactsDrawerActivity.java b/src/com/android/contacts/ContactsDrawerActivity.java
index 6ae6a59..d6d03a5 100644
--- a/src/com/android/contacts/ContactsDrawerActivity.java
+++ b/src/com/android/contacts/ContactsDrawerActivity.java
@@ -217,7 +217,7 @@
             clearCheckedMenus();
             mIdMenuMap.get(R.id.nav_find_duplicates).setCheckable(true);
             mIdMenuMap.get(R.id.nav_find_duplicates).setChecked(true);
-            updateScrollPosition(DUPLICATES_POSITION);
+            maybeUpdateScrollPosition(DUPLICATES_POSITION);
         }
 
         if (savedState != null && savedState.containsKey(KEY_NEW_GROUP_ACCOUNT)) {
@@ -226,7 +226,11 @@
         }
     }
 
-    private void updateScrollPosition(int position) {
+    private void maybeUpdateScrollPosition(int position) {
+        if (mDrawer.isDrawerOpen(GravityCompat.START)) {
+            if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Don't scroll menu when drawer open");
+            return;
+        }
         final RecyclerView recyclerView = (RecyclerView) mNavigationView.getChildAt(0);
         final LinearLayoutManager layoutManager =
                 (LinearLayoutManager) recyclerView.getLayoutManager();
@@ -409,7 +413,7 @@
                 && mGroupMenuMap.get(groupMetadata.groupId) != null) {
             mGroupMenuMap.get(groupMetadata.groupId).setCheckable(true);
             mGroupMenuMap.get(groupMetadata.groupId).setChecked(true);
-            updateScrollPosition(mGroupMenuMap.get(groupMetadata.groupId).getOrder());
+            maybeUpdateScrollPosition(mGroupMenuMap.get(groupMetadata.groupId).getOrder());
         }
     }
 
@@ -513,13 +517,13 @@
             if (mIdMenuMap != null && mIdMenuMap.get(R.id.nav_all_contacts) != null) {
                 mIdMenuMap.get(R.id.nav_all_contacts).setCheckable(true);
                 mIdMenuMap.get(R.id.nav_all_contacts).setChecked(true);
-                updateScrollPosition(ALL_CONTACTS_POSITION);
+                maybeUpdateScrollPosition(ALL_CONTACTS_POSITION);
             }
         } else {
             if (mFilterMenuMap != null && mFilterMenuMap.get(filter) != null) {
                 mFilterMenuMap.get(filter).setCheckable(true);
                 mFilterMenuMap.get(filter).setChecked(true);
-                updateScrollPosition(mFilterMenuMap.get(filter).getOrder());
+                maybeUpdateScrollPosition(mFilterMenuMap.get(filter).getOrder());
             }
         }
     }