Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e2656fb authored by Tingting Wang's avatar Tingting Wang
Browse files

Make delete action only triggered by delete button.

BUG 29764785

Change-Id: I4c5f4c93aad081a7267231ce2e56c08bf573c9dc
parent 5e46db32
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter {
        bindSectionHeaderAndDivider(view, position);
        bindName(view, cursor);
        bindPhoto(view, cursor);
        bindDeleteButton(view);
        bindDeleteButton(view, position);
    }

    protected void bindSectionHeaderAndDivider(ContactListItemView view, int position) {
@@ -188,9 +188,9 @@ public class GroupMembersAdapter extends MultiSelectEntryContactListAdapter {
                imageRequest);
    }

    private void bindDeleteButton(final ContactListItemView view) {
    private void bindDeleteButton(final ContactListItemView view, int position) {
        if (mDisplayDeleteButtons) {
            view.getDeleteImageButton();
            view.getDeleteImageButton(getDeleteContactListener(), position);
        } else {
            view.hideDeleteImageButton();
        }
+12 −8
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.contacts.GroupMetaDataLoader;
import com.android.contacts.R;
import com.android.contacts.activities.GroupMembersActivity;
import com.android.contacts.common.list.ContactsSectionIndexer;
import com.android.contacts.common.list.MultiSelectEntryContactListAdapter;
import com.android.contacts.common.logging.ListEvent.ListType;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountType;
@@ -46,7 +47,8 @@ import java.util.List;
import java.util.Set;

/** Displays the members of a group. */
public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupMembersAdapter> {
public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupMembersAdapter>
        implements MultiSelectEntryContactListAdapter.DeleteContactListener {

    private static final String TAG = "GroupMembers";

@@ -329,6 +331,7 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM
        final GroupMembersAdapter adapter = new GroupMembersAdapter(getContext());
        adapter.setSectionHeaderDisplayEnabled(true);
        adapter.setDisplayPhotos(true);
        adapter.setDeleteContactListener(this);
        return adapter;
    }

@@ -356,15 +359,10 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM
            return;
        }
        if (mListener != null) {
            if (getAdapter().getDisplayDeleteButtons()) {
                final long contactId = getAdapter().getContactId(position);
                mListener.onGroupMemberListItemDeleted(position, contactId);
            } else {
            final Uri contactLookupUri = getAdapter().getContactLookupUri(position);
            mListener.onGroupMemberListItemClicked(position, contactLookupUri);
        }
    }
    }

    @Override
    protected boolean onItemLongClick(int position, long id) {
@@ -376,4 +374,10 @@ public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupM
        }
        return super.onItemLongClick(position, id);
    }

    @Override
    public void onContactDeleteClicked(int position) {
        final long contactId = getAdapter().getContactId(position);
        mListener.onGroupMemberListItemDeleted(position, contactId);
    }
}