예제 #1
0
  public void startAction(
      int action, int title, ProgressListener listener, boolean waitOnStop, boolean showDialog) {
    ArrayList<Path> ids = mSelectionManager.getSelected(false);
    stopTaskAndDismissDialog();

    Activity activity = (Activity) mActivity;
    mDialog = createProgressDialog(activity, title, ids.size());
    if (showDialog) {
      mDialog.show();
    }
    MediaOperation operation = new MediaOperation(action, ids, listener);
    mTask = mActivity.getThreadPool().submit(operation, null);
    mWaitOnStop = waitOnStop;
  }
예제 #2
0
  public void onMenuClicked(MenuItem menuItem, String confirmMsg, final ProgressListener listener) {
    final int action = menuItem.getItemId();

    if (confirmMsg != null) {
      if (listener != null) listener.onConfirmDialogShown();
      ConfirmDialogListener cdl = new ConfirmDialogListener(action, listener);
      new AlertDialog.Builder(mActivity.getAndroidContext())
          .setMessage(confirmMsg)
          .setOnCancelListener(cdl)
          .setPositiveButton(R.string.ok, cdl)
          .setNegativeButton(R.string.cancel, cdl)
          .create()
          .show();
    } else {
      onMenuClicked(action, listener);
    }
  }
예제 #3
0
 public MenuExecutor(GalleryActivity activity, SelectionManager selectionManager) {
   mActivity = Utils.checkNotNull(activity);
   mSelectionManager = Utils.checkNotNull(selectionManager);
   mHandler =
       new SynchronizedHandler(mActivity.getGLRoot()) {
         @Override
         public void handleMessage(Message message) {
           switch (message.what) {
             case MSG_TASK_COMPLETE:
               {
                 stopTaskAndDismissDialog();
                 if (message.obj != null) {
                   ProgressListener listener = (ProgressListener) message.obj;
                   listener.onProgressComplete(message.arg1);
                 }
                 mSelectionManager.leaveSelectionMode();
                 break;
               }
             case MSG_TASK_UPDATE:
               {
                 if (mDialog != null) mDialog.setProgress(message.arg1);
                 if (message.obj != null) {
                   ProgressListener listener = (ProgressListener) message.obj;
                   listener.onProgressUpdate(message.arg1);
                 }
                 break;
               }
             case MSG_DO_SHARE:
               {
                 ((Activity) mActivity).startActivity((Intent) message.obj);
                 break;
               }
           }
         }
       };
 }
예제 #4
0
 public AlbumView(GalleryActivity activity, SlotView.Spec spec, int cacheThumbSize) {
   super(activity.getAndroidContext());
   mCacheThumbSize = cacheThumbSize;
   setSlotSpec(spec);
   mActivity = activity;
 }
예제 #5
0
 private Intent getIntentBySingleSelectedPath(String action) {
   DataManager manager = mActivity.getDataManager();
   Path path = getSingleSelectedPath();
   String mimeType = getMimeType(manager.getMediaType(path));
   return new Intent(action).setDataAndType(manager.getContentUri(path), mimeType);
 }