Fix class cast exception when footer view may be showing.
Change-Id: I51ed34293ba3e53e9b11ed440ce434653213e74d
diff --git a/src/com/android/mail/ui/AnimatedAdapter.java b/src/com/android/mail/ui/AnimatedAdapter.java
index 2f33425..a68c15b 100644
--- a/src/com/android/mail/ui/AnimatedAdapter.java
+++ b/src/com/android/mail/ui/AnimatedAdapter.java
@@ -160,12 +160,12 @@
if (isPositionUndoing(position)) {
return TYPE_VIEW_UNDOING;
}
- if (isPositionLeaveBehind(position)) {
- return TYPE_VIEW_LEAVEBEHIND;
- }
if (mShowFooter && position == super.getCount()) {
return TYPE_VIEW_FOOTER;
}
+ if (isPositionLeaveBehind(position)) {
+ return TYPE_VIEW_LEAVEBEHIND;
+ }
return TYPE_VIEW_CONVERSATION;
}
@@ -351,11 +351,13 @@
private boolean isPositionLeaveBehind(int position) {
if (hasLeaveBehinds()) {
- Conversation conv = new Conversation((ConversationCursor) getItem(position));
- return mLeaveBehindItems.containsKey(conv.id) && conv.isMostlyDead();
- } else {
- return false;
+ Object item = getItem(position);
+ if (item instanceof ConversationCursor) {
+ Conversation conv = new Conversation((ConversationCursor) item);
+ return mLeaveBehindItems.containsKey(conv.id) && conv.isMostlyDead();
+ }
}
+ return false;
}
@Override