|
2 | 2 |
|
3 | 3 |
|
4 | 4 | import android.app.Activity;
|
| 5 | +import android.content.DialogInterface; |
5 | 6 | import android.content.Intent;
|
6 | 7 | import android.os.Build;
|
7 | 8 | import android.os.Bundle;
|
8 | 9 | import android.support.design.widget.Snackbar;
|
9 | 10 | import android.support.v7.app.ActionBar;
|
| 11 | +import android.support.v7.app.AlertDialog; |
10 | 12 | import android.support.v7.app.AppCompatActivity;
|
11 | 13 | import android.support.v7.widget.Toolbar;
|
12 | 14 | import android.util.Log;
|
@@ -291,11 +293,33 @@ public boolean onOptionsItemSelected(MenuItem item)
|
291 | 293 | break;
|
292 | 294 |
|
293 | 295 | case R.id.action_delete:
|
294 |
| - Log.e(TAG, "Deleting card: " + loyaltyCardId); |
| 296 | + AlertDialog.Builder builder = new AlertDialog.Builder(this); |
| 297 | + builder.setTitle(R.string.delete); |
| 298 | + builder.setMessage(R.string.deleteConfirmation); |
| 299 | + builder.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() |
| 300 | + { |
| 301 | + @Override |
| 302 | + public void onClick(DialogInterface dialog, int which) |
| 303 | + { |
| 304 | + Log.e(TAG, "Deleting card: " + loyaltyCardId); |
| 305 | + |
| 306 | + DBHelper db = new DBHelper(LoyaltyCardViewActivity.this); |
| 307 | + db.deleteLoyaltyCard(loyaltyCardId); |
| 308 | + finish(); |
| 309 | + dialog.dismiss(); |
| 310 | + } |
| 311 | + }); |
| 312 | + builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() |
| 313 | + { |
| 314 | + @Override |
| 315 | + public void onClick(DialogInterface dialog, int which) |
| 316 | + { |
| 317 | + dialog.dismiss(); |
| 318 | + } |
| 319 | + }); |
| 320 | + AlertDialog dialog = builder.create(); |
| 321 | + dialog.show(); |
295 | 322 |
|
296 |
| - DBHelper db = new DBHelper(this); |
297 |
| - db.deleteLoyaltyCard(loyaltyCardId); |
298 |
| - finish(); |
299 | 323 | return true;
|
300 | 324 | case R.id.action_edit:
|
301 | 325 | Intent intent = new Intent(getApplicationContext(), LoyaltyCardViewActivity.class);
|
|
0 commit comments