use of com.amaze.filemanager.asynchronous.asynctasks.MoveFiles in project AmazeFileManager by TeamAmaze.
the class MainActivity method onActivityResult.
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
if (requestCode == Drawer.image_selector_request_code) {
drawer.onActivityResult(requestCode, responseCode, intent);
} else if (requestCode == 3) {
Uri treeUri;
if (responseCode == Activity.RESULT_OK) {
// Get Uri from Storage Access Framework.
treeUri = intent.getData();
// Persist URI - this is required for verification of writability.
if (treeUri != null)
getPrefs().edit().putString(PreferencesConstants.PREFERENCE_URI, treeUri.toString()).commit();
} else {
/* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false, currentFolder);
||!FileUtil.isWritableNormalOrSaf(currentFolder)*/
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
}
switch(operation) {
case // deletion
DataUtils.DELETE:
new DeleteTask(null, mainActivity).execute((oparrayList));
break;
case // copying
DataUtils.COPY:
// legacy compatibility
if (oparrayList != null && oparrayList.size() != 0) {
oparrayListList = new ArrayList<>();
oparrayListList.add(oparrayList);
oparrayList = null;
oppatheList = new ArrayList<>();
oppatheList.add(oppathe);
oppathe = "";
}
for (int i = 0; i < oparrayListList.size(); i++) {
ArrayList<HybridFileParcelable> sourceList = oparrayListList.get(i);
Intent intent1 = new Intent(con, CopyService.class);
intent1.putExtra(CopyService.TAG_COPY_SOURCES, sourceList);
intent1.putExtra(CopyService.TAG_COPY_TARGET, oppatheList.get(i));
ServiceWatcherUtil.runService(this, intent1);
}
break;
case // moving
DataUtils.MOVE:
// legacy compatibility
if (oparrayList != null && oparrayList.size() != 0) {
oparrayListList = new ArrayList<>();
oparrayListList.add(oparrayList);
oparrayList = null;
oppatheList = new ArrayList<>();
oppatheList.add(oppathe);
oppathe = "";
}
new MoveFiles(oparrayListList, getCurrentMainFragment(), getCurrentMainFragment().getActivity(), OpenMode.FILE).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, oppatheList);
break;
case // mkdir
DataUtils.NEW_FOLDER:
mainActivityHelper.mkDir(RootHelper.generateBaseFile(new File(oppathe), true), getCurrentMainFragment());
break;
case DataUtils.RENAME:
MainFragment ma = getCurrentMainFragment();
mainActivityHelper.rename(ma.openMode, (oppathe), (oppathe1), mainActivity, isRootExplorer());
ma.updateList();
break;
case DataUtils.NEW_FILE:
mainActivityHelper.mkFile(new HybridFile(OpenMode.FILE, oppathe), getCurrentMainFragment());
break;
case DataUtils.EXTRACT:
mainActivityHelper.extractFile(new File(oppathe));
break;
case DataUtils.COMPRESS:
mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
}
operation = -1;
} else if (requestCode == REQUEST_CODE_SAF && responseCode == Activity.RESULT_OK) {
// otg access
getPrefs().edit().putString(KEY_PREF_OTG, intent.getData().toString()).apply();
drawer.closeIfNotLocked();
if (drawer.isLocked())
drawer.onDrawerClosed();
} else if (requestCode == REQUEST_CODE_SAF && responseCode != Activity.RESULT_OK) {
// otg access not provided
drawer.resetPendingPath();
}
}
Aggregations