Example #1
0
 public void SetAlertDialog(DialogInterface arg0, boolean show) {
   if (show) {
     try {
       Field mField = arg0.getClass().getSuperclass().getDeclaredField("mShowing");
       mField.setAccessible(true);
       mField.set(arg0, true);
     } catch (NoSuchFieldException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IllegalArgumentException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   } else {
     try {
       Field mField = arg0.getClass().getSuperclass().getDeclaredField("mShowing");
       mField.setAccessible(true);
       mField.set(arg0, false);
     } catch (NoSuchFieldException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IllegalArgumentException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }
Example #2
0
 /**
  * dialog消失的方法
  *
  * @param dialog
  */
 private void destoryDialog(DialogInterface dialog) {
   try {
     Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
     field.setAccessible(true);
     field.set(dialog, true);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 @Override
 public void onDismiss(DialogInterface arg0) {
   if (arg0.getClass().equals(RenameDialog.class)) {
     RenameDialog<DBPathEntry> rd = (RenameDialog<DBPathEntry>) arg0;
     if (rd.GetResultText().length() > 0) {
       File fNewPath = new File(MakeFilePath(rd.GetResultText()));
       if (!fNewPath.exists()) {
         File fSrc = rd.GetData().GetFile();
         if (fSrc.renameTo(fNewPath)) {
           Toast.makeText(this, "DB renamed", Toast.LENGTH_LONG).show();
         } else {
           Toast.makeText(this, "Failed to rename DB", Toast.LENGTH_LONG).show();
         }
       } else {
         Toast.makeText(this, "There is already a DB at " + fNewPath.getPath(), Toast.LENGTH_LONG)
             .show();
       }
     }
     FirstTimeSetup(); // refresh the list
   }
 }
Example #4
0
        @Override
        public void onClick(DialogInterface dialog, int which) {
          try {
            if (dialog.getClass() != DateTimePickerDialog.class) {
              return;
            }
            switch (which) {
              case DialogInterface.BUTTON_POSITIVE:
                DateTimePickerDialog reminderDl = (DateTimePickerDialog) dialog;

                Date date = reminderDl.getDate();
                txt_date.setText(Helper.dateToString(date, Helper.NORMAL_DAY_OF_WEEK_FORMAT));

                break;
              case DialogInterface.BUTTON_NEGATIVE:
                txt_date.setText("Set Date time please!");
                break;
              default:
                break;
            }
          } catch (Exception ex) {
            Log.e("MainActivity", ex.getMessage());
          }
        }