fix conversation position handling while grouping enabled
This commit is contained in:
parent
018120cfe6
commit
3f43dc6d5f
|
@ -140,8 +140,9 @@ public class ConversationsOverviewFragment extends XmppFragment {
|
|||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
pendingActionHelper.execute();
|
||||
int position = viewHolder.getLayoutPosition();
|
||||
|
||||
try {
|
||||
swipedConversation.push(conversations.get(position));
|
||||
swipedConversation.push(conversationsAdapter.getConversation(position));
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return;
|
||||
}
|
||||
|
@ -346,7 +347,7 @@ public class ConversationsOverviewFragment extends XmppFragment {
|
|||
if (menuInfo == null) return;
|
||||
int pos = ((AdapterView.AdapterContextMenuInfo) menuInfo).position;
|
||||
if (pos < 0) return;
|
||||
Conversation conversation = conversations.get(pos);
|
||||
Conversation conversation = conversationsAdapter.getConversation(pos);
|
||||
if (conversation != null) {
|
||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
menuContactDetails.setVisible(false);
|
||||
|
@ -379,7 +380,11 @@ public class ConversationsOverviewFragment extends XmppFragment {
|
|||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
Conversation conversation = conversations.get(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position);
|
||||
Conversation conversation = conversationsAdapter.getConversation(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position);
|
||||
if (conversation == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ConversationFragment fragment = new ConversationFragment();
|
||||
fragment.setHasOptionsMenu(false);
|
||||
fragment.onAttach(activity);
|
||||
|
|
|
@ -197,6 +197,20 @@ public class ConversationAdapter
|
|||
return groupingEnabled;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Conversation getConversation(int position) {
|
||||
if (groupingEnabled) {
|
||||
Object item = items.get(position);
|
||||
if (item instanceof Conversation) {
|
||||
return (Conversation) item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return conversations.get(position);
|
||||
}
|
||||
}
|
||||
|
||||
public void setGroupingEnabled(boolean groupingEnabled) {
|
||||
if (groupingEnabled != this.groupingEnabled) {
|
||||
this.groupingEnabled = groupingEnabled;
|
||||
|
|
Loading…
Reference in a new issue