|
2 | 2 |
|
3 | 3 | import android.content.Context;
|
4 | 4 | import android.content.DialogInterface;
|
| 5 | +import android.support.design.widget.Snackbar; |
5 | 6 | import android.support.v7.app.AlertDialog;
|
6 | 7 | import android.view.LayoutInflater;
|
7 | 8 | import android.view.View;
|
@@ -88,26 +89,23 @@ public void onClick(View v) {
|
88 | 89 | holder.delete.setOnClickListener(new View.OnClickListener() {
|
89 | 90 | @Override
|
90 | 91 | public void onClick(View v) {
|
91 |
| - |
92 |
| - final AlertDialog dialog = new AlertDialog.Builder(mContext) |
93 |
| - .setTitle(R.string.info_template_delete) |
94 |
| - .setMessage(R.string.info_delete_item_content) |
95 |
| - .setPositiveButton(R.string.dialog_yes, null) |
96 |
| - .setNegativeButton(R.string.dialog_no, null) |
97 |
| - .create(); |
98 |
| - dialog.show(); |
99 |
| - |
100 |
| - dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { |
101 |
| - @Override |
102 |
| - public void onClick(View v) { |
103 |
| - mData.remove(position); |
104 |
| - notifyDataSetChanged(); |
105 |
| - dialog.dismiss(); |
106 |
| - |
107 |
| - ((TemplateEditor) mContext).restoreSelectedView(); |
108 |
| - } |
109 |
| - }); |
110 |
| - |
| 92 | + final FlashCardModel flashCardModel = mData.get(position); |
| 93 | + mData.remove(position); |
| 94 | + notifyDataSetChanged(); |
| 95 | + notifyDataSetChanged(); |
| 96 | + Snackbar.make(v,R.string.snackbar_deleted_message,Snackbar.LENGTH_LONG) |
| 97 | + .setAction(R.string.snackbar_undo, new View.OnClickListener() { |
| 98 | + @Override |
| 99 | + public void onClick(View v) { |
| 100 | + mData.add(position,flashCardModel); |
| 101 | + notifyDataSetChanged(); |
| 102 | + Snackbar.make(v,R.string.snackbar_restored_message,Snackbar.LENGTH_LONG).show(); |
| 103 | + } |
| 104 | + }).show(); |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + ((TemplateEditor) mContext).restoreSelectedView(); |
111 | 109 | }
|
112 | 110 | });
|
113 | 111 |
|
|
0 commit comments