From 033a959e0058685a8f0c1c786bf157f3c2697de8 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Wed, 14 Feb 2018 21:50:18 -0400 Subject: [PATCH] - Added option to delete contacts --- .../views/ContactViewHolder.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/views/ContactViewHolder.java b/app/src/main/java/cy/agorise/crystalwallet/views/ContactViewHolder.java index 80c556d..a7cc1b7 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/views/ContactViewHolder.java +++ b/app/src/main/java/cy/agorise/crystalwallet/views/ContactViewHolder.java @@ -1,8 +1,10 @@ package cy.agorise.crystalwallet.views; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.provider.ContactsContract; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.ImageView; @@ -10,6 +12,7 @@ import android.widget.TextView; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.activities.CreateContactActivity; +import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.models.Contact; /** @@ -67,7 +70,22 @@ public class ContactViewHolder extends RecyclerView.ViewHolder { this.ivDeleteContact.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - // + //delete the contact + new AlertDialog.Builder(context) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage("Are you sure you want to delete this contact?") + .setPositiveButton("Yes", new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + CrystalDatabase.getAppDatabase(context).contactDao().deleteContacts(contact); + } + + }) + .setNegativeButton("No", null) + .show(); + + } }); }