- /**
- * Starts a the removal of the previewed file.
- *
- * Shows a confirmation dialog. The action continues in {@link #onConfirmation(String)} , {@link #onNeutral(String)} or {@link #onCancel(String)},
- * depending upon the user selection in the dialog.
- */
- private void removeFile() {
- ConfirmationDialogFragment confDialog = ConfirmationDialogFragment.newInstance(
- R.string.confirmation_remove_alert,
- new String[]{getFile().getFileName()},
- R.string.confirmation_remove_remote_and_local,
- R.string.confirmation_remove_local,
- R.string.common_cancel);
- confDialog.setOnConfirmationListener(this);
- confDialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
- }
-
-
- /**
- * Performs the removal of the previewed file, both locally and in the server.
- */
- @Override
- public void onConfirmation(String callerTag) {
- if (mStorageManager.getFileById(getFile().getFileId()) != null) { // check that the file is still there;
- String path = new File(getFile().getStoragePath()).getParent();
- mLastRemoteOperation = new RemoveFileOperation( getFile(), // TODO we need to review the interface with RemoteOperations, and use OCFile IDs instead of OCFile objects as parameters
- true,
- mStorageManager);
- mLastRemoteOperation.execute(mAccount, getSherlockActivity(), this, mHandler, getSherlockActivity());
-
- ((PreviewImageActivity) getActivity()).showLoadingDialog();
-
- triggerMediaScan(path);
- }
- }
-
-
- /**
- * Removes the file from local storage
- */
- @Override
- public void onNeutral(String callerTag) {
- // TODO this code should be made in a secondary thread,
- OCFile file = getFile();
- if (file.isDown()) { // checks it is still there
- File f = new File(file.getStoragePath());
- String path = f.getParent();
- f.delete();
-
- triggerMediaScan(path);
-
- file.setStoragePath(null);
- mStorageManager.saveFile(file);
- finish();
- }
- }
-
- /**
- * User cancelled the removal action.
- */
- @Override
- public void onCancel(String callerTag) {
- // nothing to do here
- }
-
- private void triggerMediaScan(String path){
- MediaScannerConnection.scanFile(
- getActivity().getApplicationContext(),
- new String[]{path},
- null,null);
- }
-
-
- private class BitmapLoader extends AsyncTask<String, Void, Bitmap> {