use of com.amaze.filemanager.filesystem.HybridFile in project AmazeFileManager by TeamAmaze.
the class FileUtils method toHybridFileConcurrentRadixTree.
public static ArrayList<HybridFile> toHybridFileConcurrentRadixTree(ConcurrentRadixTree<VoidValue> a) {
ArrayList<HybridFile> b = new ArrayList<>();
for (CharSequence o : a.getKeysStartingWith("")) {
HybridFile hFile = new HybridFile(OpenMode.UNKNOWN, o.toString());
hFile.generateMode(null);
b.add(hFile);
}
return b;
}
use of com.amaze.filemanager.filesystem.HybridFile in project AmazeFileManager by TeamAmaze.
the class MainActivityHelper method mkDir.
public void mkDir(final HybridFile path, final MainFragment ma) {
final Toast toast = Toast.makeText(ma.getActivity(), ma.getString(R.string.creatingfolder), Toast.LENGTH_SHORT);
toast.show();
Operations.mkdir(path, ma.getActivity(), mainActivity.isRootExplorer(), new Operations.ErrorCallBack() {
@Override
public void exists(final HybridFile file) {
ma.getActivity().runOnUiThread(() -> {
if (toast != null)
toast.cancel();
Toast.makeText(mainActivity, mainActivity.getString(R.string.fileexist), Toast.LENGTH_SHORT).show();
if (ma != null && ma.getActivity() != null) {
// retry with dialog prompted again
mkdir(file.getMode(), file.getParent(), ma);
}
});
}
@Override
public void launchSAF(HybridFile file) {
if (toast != null)
toast.cancel();
ma.getActivity().runOnUiThread(() -> {
mainActivity.oppathe = path.getPath();
mainActivity.operation = DataUtils.NEW_FOLDER;
guideDialogForLEXA(mainActivity.oppathe);
});
}
@Override
public void launchSAF(HybridFile file, HybridFile file1) {
}
@Override
public void done(HybridFile hFile, final boolean b) {
ma.getActivity().runOnUiThread(() -> {
if (b) {
ma.updateList();
} else {
Toast.makeText(ma.getActivity(), ma.getString(R.string.operationunsuccesful), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void invalidName(final HybridFile file) {
ma.getActivity().runOnUiThread(() -> {
if (toast != null)
toast.cancel();
Toast.makeText(ma.getActivity(), ma.getString(R.string.invalid_name) + ": " + file.getName(), Toast.LENGTH_LONG).show();
});
}
});
}
use of com.amaze.filemanager.filesystem.HybridFile in project AmazeFileManager by TeamAmaze.
the class MainActivityHelper method mkfile.
/**
* Prompt a dialog to user to input file name
*
* @param openMode
* @param path current path at which file to create
* @param ma {@link MainFragment} current fragment
*/
void mkfile(final OpenMode openMode, final String path, final MainFragment ma) {
mk(R.string.newfile, materialDialog -> {
String a = materialDialog.getInputEditText().getText().toString();
mkFile(new HybridFile(openMode, path + "/" + a), ma);
materialDialog.dismiss();
});
}
use of com.amaze.filemanager.filesystem.HybridFile in project AmazeFileManager by TeamAmaze.
the class MainActivityHelper method mkFile.
public void mkFile(final HybridFile path, final MainFragment ma) {
final Toast toast = Toast.makeText(ma.getActivity(), ma.getString(R.string.creatingfile), Toast.LENGTH_SHORT);
toast.show();
Operations.mkfile(path, ma.getActivity(), mainActivity.isRootExplorer(), new Operations.ErrorCallBack() {
@Override
public void exists(final HybridFile file) {
ma.getActivity().runOnUiThread(() -> {
if (toast != null)
toast.cancel();
Toast.makeText(mainActivity, mainActivity.getString(R.string.fileexist), Toast.LENGTH_SHORT).show();
if (ma != null && ma.getActivity() != null) {
// retry with dialog prompted again
mkfile(file.getMode(), file.getParent(), ma);
}
});
}
@Override
public void launchSAF(HybridFile file) {
ma.getActivity().runOnUiThread(() -> {
if (toast != null)
toast.cancel();
mainActivity.oppathe = path.getPath();
mainActivity.operation = DataUtils.NEW_FILE;
guideDialogForLEXA(mainActivity.oppathe);
});
}
@Override
public void launchSAF(HybridFile file, HybridFile file1) {
}
@Override
public void done(HybridFile hFile, final boolean b) {
ma.getActivity().runOnUiThread(() -> {
if (b) {
ma.updateList();
} else {
Toast.makeText(ma.getActivity(), ma.getString(R.string.operationunsuccesful), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void invalidName(final HybridFile file) {
ma.getActivity().runOnUiThread(() -> {
if (toast != null)
toast.cancel();
Toast.makeText(ma.getActivity(), ma.getString(R.string.invalid_name) + ": " + file.getName(), Toast.LENGTH_LONG).show();
});
}
});
}
use of com.amaze.filemanager.filesystem.HybridFile in project AmazeFileManager by TeamAmaze.
the class FileHandler method handleMessage.
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
MainFragment main = mainFragment.get();
String path = (String) msg.obj;
switch(msg.what) {
case CustomFileObserver.GOBACK:
main.goBack();
break;
case CustomFileObserver.NEW_ITEM:
HybridFile fileCreated = new HybridFile(main.openMode, main.getCurrentPath() + "/" + path);
main.getElementsList().add(fileCreated.generateLayoutElement(useThumbs));
break;
case CustomFileObserver.DELETED_ITEM:
for (int i = 0; i < main.getElementsList().size(); i++) {
File currentFile = new File(main.getElementsList().get(i).desc);
if (currentFile.getName().equals(path)) {
main.getElementsList().remove(i);
break;
}
}
break;
default:
// Pass along other messages from the UI
super.handleMessage(msg);
return;
}
if (listView.getVisibility() == View.VISIBLE) {
if (main.getElementsList().size() == 0) {
// no item left in list, recreate views
main.reloadListElements(true, main.results, !main.IS_LIST);
} else {
// we already have some elements in list view, invalidate the adapter
((RecyclerAdapter) listView.getAdapter()).setItems(listView, main.getElementsList());
}
} else {
// there was no list view, means the directory was empty
main.loadlist(main.getCurrentPath(), true, main.openMode);
}
main.computeScroll();
}
Aggregations