Skip to content
Browse files

DeckAdapter: getView(): If no conversation is available (anymore) for…

… the requested position, return an empty TextView. Fixes #56.
  • Loading branch information...
1 parent 50a6047 commit 1e5f0160126f50f45d7b8bcf1769ad310c588b96 @pocmo committed Apr 15, 2011
Showing with 11 additions and 0 deletions.
  1. +11 −0 application/src/org/yaaic/adapter/DeckAdapter.java
View
11 application/src/org/yaaic/adapter/DeckAdapter.java
@@ -32,6 +32,7 @@
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ListView;
+import android.widget.TextView;
/**
* The adapter for the "DeckView"
@@ -187,6 +188,15 @@ public boolean isSwitched()
public View getView(int position, View convertView, ViewGroup parent)
{
Conversation conversation = getItem(position);
+
+ // Market stack traces prove that sometimes we get a null converstion
+ // because the collection changed while a view is requested for an
+ // item that does not exist anymore... so we just need to reply with
+ // some kind of view here.
+ if (conversation == null) {
+ return new TextView(parent.getContext());
+ }
+
return renderConversation(conversation, parent);
}
@@ -203,6 +213,7 @@ public MessageListView renderConversation(Conversation conversation, ViewGroup p
list.setOnItemClickListener(MessageClickListener.getInstance());
MessageListAdapter adapter = conversation.getMessageListAdapter();
+
if (adapter == null) {
adapter = new MessageListAdapter(conversation, parent.getContext());
conversation.setMessageListAdapter(adapter);

0 comments on commit 1e5f016

Please sign in to comment.
Something went wrong with that request. Please try again.