fix contact long click crash
This commit is contained in:
parent
379300bf02
commit
3f8874361b
|
@ -1285,10 +1285,18 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
|
|
||||||
public static class MyListFragment extends SwipeRefreshListFragment {
|
public static class MyListFragment extends SwipeRefreshListFragment {
|
||||||
private AdapterView.OnItemClickListener mOnItemClickListener;
|
private AdapterView.OnItemClickListener mOnItemClickListener;
|
||||||
private int mResContextMenu;
|
private int mResContextMenuConference;
|
||||||
|
private int mResContextMenuContact;
|
||||||
|
|
||||||
public void setContextMenu(final int res) {
|
private boolean itemsFromContacts;
|
||||||
this.mResContextMenu = res;
|
|
||||||
|
public void setContextMenu(final int resConference, final int resContact) {
|
||||||
|
this.mResContextMenuConference = resConference;
|
||||||
|
this.mResContextMenuContact = resContact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemsFromContacts(boolean itemsFromContacts) {
|
||||||
|
this.itemsFromContacts = itemsFromContacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1338,17 +1346,42 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activity.getMenuInflater().inflate(mResContextMenu, menu);
|
|
||||||
final AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
|
int position;
|
||||||
if (mResContextMenu == R.menu.conference_context) {
|
|
||||||
activity.conference_context_id = acmi.position;
|
if (menuInfo instanceof AdapterContextMenuInfo) {
|
||||||
final Bookmark bookmark = (Bookmark) activity.conferences.get(acmi.position);
|
final AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
|
||||||
|
position = acmi.position;
|
||||||
|
} else {
|
||||||
|
final ExpandableListView.ExpandableListContextMenuInfo acmi = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
|
||||||
|
position = (int) acmi.targetView.getTag(R.id.TAG_POSITION);
|
||||||
|
}
|
||||||
|
|
||||||
|
int resContextMenu;
|
||||||
|
|
||||||
|
ListItem item = activity.contacts.get(position);
|
||||||
|
if (itemsFromContacts) {
|
||||||
|
if (item instanceof Bookmark) {
|
||||||
|
resContextMenu = mResContextMenuConference;
|
||||||
|
} else {
|
||||||
|
resContextMenu = mResContextMenuContact;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resContextMenu = mResContextMenuConference;
|
||||||
|
}
|
||||||
|
|
||||||
|
activity.getMenuInflater().inflate(resContextMenu, menu);
|
||||||
|
|
||||||
|
|
||||||
|
if (resContextMenu == R.menu.conference_context) {
|
||||||
|
activity.conference_context_id = position;
|
||||||
|
final Bookmark bookmark = (Bookmark) item;
|
||||||
final Conversation conversation = bookmark.getConversation();
|
final Conversation conversation = bookmark.getConversation();
|
||||||
final MenuItem share = menu.findItem(R.id.context_share_uri);
|
final MenuItem share = menu.findItem(R.id.context_share_uri);
|
||||||
share.setVisible(conversation == null || !conversation.isPrivateAndNonAnonymous());
|
share.setVisible(conversation == null || !conversation.isPrivateAndNonAnonymous());
|
||||||
} else if (mResContextMenu == R.menu.contact_context) {
|
} else if (resContextMenu == R.menu.contact_context) {
|
||||||
activity.contact_context_id = acmi.position;
|
activity.contact_context_id = position;
|
||||||
final Contact contact = (Contact) activity.contacts.get(acmi.position);
|
final Contact contact = (Contact) item;
|
||||||
final MenuItem blockUnblockItem = menu.findItem(R.id.context_contact_block_unblock);
|
final MenuItem blockUnblockItem = menu.findItem(R.id.context_contact_block_unblock);
|
||||||
final MenuItem showContactDetailsItem = menu.findItem(R.id.context_contact_details);
|
final MenuItem showContactDetailsItem = menu.findItem(R.id.context_contact_details);
|
||||||
final MenuItem deleteContactMenuItem = menu.findItem(R.id.context_delete_contact);
|
final MenuItem deleteContactMenuItem = menu.findItem(R.id.context_delete_contact);
|
||||||
|
@ -1463,11 +1496,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
final MyListFragment listFragment = new MyListFragment();
|
final MyListFragment listFragment = new MyListFragment();
|
||||||
if (position == 1) {
|
if (position == 1) {
|
||||||
listFragment.setListAdapter(mConferenceAdapter);
|
listFragment.setListAdapter(mConferenceAdapter);
|
||||||
listFragment.setContextMenu(R.menu.conference_context);
|
listFragment.setContextMenu(R.menu.conference_context, R.menu.contact_context);
|
||||||
|
listFragment.setItemsFromContacts(false);
|
||||||
listFragment.setOnListItemClickListener((arg0, arg1, p, arg3) -> openConversationForBookmark(p));
|
listFragment.setOnListItemClickListener((arg0, arg1, p, arg3) -> openConversationForBookmark(p));
|
||||||
} else {
|
} else {
|
||||||
listFragment.setListAdapter(mContactsAdapter);
|
listFragment.setListAdapter(mContactsAdapter);
|
||||||
listFragment.setContextMenu(R.menu.contact_context);
|
listFragment.setContextMenu(R.menu.conference_context, R.menu.contact_context);
|
||||||
|
listFragment.setItemsFromContacts(true);
|
||||||
listFragment.setOnListItemClickListener((arg0, arg1, p, arg3) -> openConversationForContact(p));
|
listFragment.setOnListItemClickListener((arg0, arg1, p, arg3) -> openConversationForContact(p));
|
||||||
if (QuickConversationsService.isQuicksy()) {
|
if (QuickConversationsService.isQuicksy()) {
|
||||||
listFragment.setOnRefreshListener(StartConversationActivity.this);
|
listFragment.setOnRefreshListener(StartConversationActivity.this);
|
||||||
|
@ -1772,7 +1807,10 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
@Override
|
@Override
|
||||||
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||||
ListItem item = getChildsList(groupPosition).get(childPosition);
|
ListItem item = getChildsList(groupPosition).get(childPosition);
|
||||||
return super.getView(super.getPosition(item), convertView, parent);
|
int position = super.getPosition(item);
|
||||||
|
View view = super.getView(super.getPosition(item), convertView, parent);
|
||||||
|
view.setTag(R.id.TAG_POSITION, position);
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,4 +5,5 @@
|
||||||
<item type="id" name="TAG_FINGERPRINT_STATUS"/>
|
<item type="id" name="TAG_FINGERPRINT_STATUS"/>
|
||||||
<item type="id" name="TAG_AUDIO_PLAYER_VIEW_HOLDER"/>
|
<item type="id" name="TAG_AUDIO_PLAYER_VIEW_HOLDER"/>
|
||||||
<item type="id" name="TAG_DRAGGABLE"/>
|
<item type="id" name="TAG_DRAGGABLE"/>
|
||||||
|
<item type="id" name="TAG_POSITION"/>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue