Check for ImageView before casting it
Bug: 33273202
Test: manually verified the bug doesn't happen following steps to
repro in bug
Change-Id: I4a50ff22fbb9235ded8060157f3a7f5cda19f6f2
diff --git a/src/com/android/contacts/activities/ActionBarAdapter.java b/src/com/android/contacts/activities/ActionBarAdapter.java
index 880aa63..c91f608 100644
--- a/src/com/android/contacts/activities/ActionBarAdapter.java
+++ b/src/com/android/contacts/activities/ActionBarAdapter.java
@@ -448,22 +448,24 @@
final ArrayList<View> outViews = new ArrayList<>();
decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
- if (outViews.isEmpty()) {
- return;
- }
- final ImageView overflow = (ImageView) outViews.get(0);
- overflow.setImageResource(R.drawable.ic_more_vert);
- // Update the overflow image color.
- final int iconColor;
- if (mSelectionMode) {
- iconColor = mActivity.getResources().getColor(
- R.color.actionbar_color_grey_solid);
- } else {
- iconColor = mActivity.getResources().getColor(
- R.color.actionbar_text_color);
+ for (View view : outViews) {
+ if (!(view instanceof ImageView)) {
+ continue;
+ }
+ final ImageView overflow = (ImageView) view;
+
+ // Update the overflow image color.
+ final int iconColor;
+ if (mSelectionMode) {
+ iconColor = mActivity.getResources().getColor(
+ R.color.actionbar_color_grey_solid);
+ } else {
+ iconColor = mActivity.getResources().getColor(
+ R.color.actionbar_text_color);
+ }
+ overflow.setImageTintList(ColorStateList.valueOf(iconColor));
}
- overflow.setImageTintList(ColorStateList.valueOf(iconColor));
// We're done, remove the listener.
decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);