mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
register for context menu only if there is sth. to delete
This commit is contained in:
@@ -77,7 +77,7 @@ public class AccountSelectionListFragment extends DialogFragment
|
||||
// hack to make onContextItemSelected() work with DialogFragment,
|
||||
// see https://stackoverflow.com/questions/15929026/oncontextitemselected-does-not-get-called-in-a-dialogfragment
|
||||
MenuItem.OnMenuItemClickListener listener = item -> {
|
||||
onContextItemSelected(item);
|
||||
onContextItemSelected(item, v);
|
||||
return true;
|
||||
};
|
||||
for (int i = 0, n = menu.size(); i < n; i++) {
|
||||
@@ -86,15 +86,11 @@ public class AccountSelectionListFragment extends DialogFragment
|
||||
// /hack
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
private void onContextItemSelected(MenuItem item, View view) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.delete:
|
||||
onDeleteAccount(((AccountSelectionListItem) info.targetView).getAccountId());
|
||||
return true;
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
onDeleteAccount(((AccountSelectionListItem) view).getAccountId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,11 @@ public class AccountSelectionListItem extends LinearLayout {
|
||||
updateUnreadIndicator(unreadCount, isMuted);
|
||||
setText(name, addr);
|
||||
|
||||
fragment.registerForContextMenu(this);
|
||||
if (!selected && accountId != DcContact.DC_CONTACT_ID_ADD_ACCOUNT) {
|
||||
fragment.registerForContextMenu(this);
|
||||
} else {
|
||||
fragment.unregisterForContextMenu(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void unbind(GlideRequests glideRequests) {
|
||||
|
||||
Reference in New Issue
Block a user