Mgamerz

Untitled

Aug 11th, 2011
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 KB | None | 0 0
  1.             //pops up the dialog
  2.             @Override
  3.     protected Dialog onCreateDialog(int id) {
  4.                 Dialog returndialog = new Dialog(getApplicationContext());
  5.         switch (id) {
  6.         case DATE_DIALOG_ID:
  7.             DatePickerDialog dialog = new DatePickerDialog(this,
  8.                     mDateSetListener, bYear, bMonth, bDay) {
  9.                 @Override
  10.                 public boolean onSearchRequested() {
  11.                     return false;
  12.                 }
  13.  
  14.             };
  15.             dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
  16.                 public void onClick(DialogInterface dialog, int which) {
  17.                     if (which == DialogInterface.BUTTON_NEGATIVE) {
  18.                         Log.e(TAG, "Permission Denied - You aren't allowed to use this app yet [TERMINATED]");
  19.                         System.exit(0);
  20.                     }
  21.                 }
  22.             });
  23.             dialog.setCancelable(false);
  24.             returndialog = dialog;
  25.             break;
  26.         case EXPIRATION_DIALOG_ID:
  27.             final GregorianCalendar now = new GregorianCalendar();
  28.             AlertDialog alertDialog =new AlertDialog(getApplicationContext()) {
  29.                 @Override
  30.                 public boolean onSearchRequested() {
  31.                     return false;
  32.                 }
  33.             };
  34.             Log.w(TAG, "Has this build expired? " + now.after(expiration));
  35.             if (now.after(expiration)) {
  36.                 alertDialog.setTitle("Application Expired");
  37.                 alertDialog
  38.                         .setMessage("This alpha release expired "
  39.                                 + DateFormat.getDateInstance()
  40.                                         .format(expiration.getTime())
  41.  
  42.                                 + ".\nThe application will now close, please check with Mgamerz for more updated alpha releases.");
  43.             } else {
  44.                 alertDialog.setTitle("Notice");
  45.                 alertDialog.setMessage("This alpha release will expire on "
  46.                         + DateFormat.getDateInstance().format(expiration
  47.                                 .getTime()));
  48.             }
  49.             alertDialog.setCancelable(false);
  50.             alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new AlertDialog.OnClickListener() {
  51.                         @Override
  52.                         public void onClick(DialogInterface dialog, int which) {
  53.                             Log.d(TAG, "Expiration OnClick");
  54.                             if (now.after(expiration)) {
  55.                                 System.exit(0);
  56.                                 expirationAlert = true;
  57.                                 dialog.dismiss();
  58.                             } else {
  59.                                 if (!now.after(expiration)) {
  60.                                     expirationAlert = false;
  61.                                 }
  62.                                 dialog.dismiss();
  63.                             }
  64.                         }
  65.  
  66.                     });
  67.             returndialog = alertDialog;
  68.             break;
  69.         }
  70.         return returndialog;
  71.     }
Advertisement
Add Comment
Please, Sign In to add comment