use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class LayoutElementParcelable method generateBaseFile.
public HybridFileParcelable generateBaseFile() {
HybridFileParcelable baseFile = new HybridFileParcelable(desc, permissions, date, longSize, isDirectory);
baseFile.setMode(mode);
baseFile.setName(title);
return baseFile;
}
use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class DeleteTask method doInBackground.
protected Boolean doInBackground(ArrayList<HybridFileParcelable>... p1) {
files = p1[0];
boolean wasDeleted = true;
if (files.size() == 0)
return true;
if (files.get(0).isOtgFile()) {
for (HybridFileParcelable file : files) {
DocumentFile documentFile = OTGUtil.getDocumentFile(file.getPath(), cd, false);
wasDeleted = documentFile.delete();
}
} else if (files.get(0).isDropBoxFile()) {
CloudStorage cloudStorageDropbox = dataUtils.getAccount(OpenMode.DROPBOX);
for (HybridFileParcelable baseFile : files) {
try {
cloudStorageDropbox.delete(CloudUtil.stripPath(OpenMode.DROPBOX, baseFile.getPath()));
} catch (Exception e) {
e.printStackTrace();
wasDeleted = false;
break;
}
}
} else if (files.get(0).isBoxFile()) {
CloudStorage cloudStorageBox = dataUtils.getAccount(OpenMode.BOX);
for (HybridFileParcelable baseFile : files) {
try {
cloudStorageBox.delete(CloudUtil.stripPath(OpenMode.BOX, baseFile.getPath()));
} catch (Exception e) {
e.printStackTrace();
wasDeleted = false;
break;
}
}
} else if (files.get(0).isGoogleDriveFile()) {
CloudStorage cloudStorageGdrive = dataUtils.getAccount(OpenMode.GDRIVE);
for (HybridFileParcelable baseFile : files) {
try {
cloudStorageGdrive.delete(CloudUtil.stripPath(OpenMode.GDRIVE, baseFile.getPath()));
} catch (Exception e) {
e.printStackTrace();
wasDeleted = false;
break;
}
}
} else if (files.get(0).isOneDriveFile()) {
CloudStorage cloudStorageOnedrive = dataUtils.getAccount(OpenMode.ONEDRIVE);
for (HybridFileParcelable baseFile : files) {
try {
cloudStorageOnedrive.delete(CloudUtil.stripPath(OpenMode.ONEDRIVE, baseFile.getPath()));
} catch (Exception e) {
e.printStackTrace();
wasDeleted = false;
break;
}
}
} else {
for (HybridFileParcelable file : files) {
try {
if (file.delete(cd, rootMode)) {
wasDeleted = true;
} else {
wasDeleted = false;
break;
}
} catch (ShellNotRunningException e) {
e.printStackTrace();
wasDeleted = false;
break;
}
}
}
// delete file from media database
if (!files.get(0).isSmb()) {
try {
for (HybridFileParcelable f : files) {
delete(cd, f.getPath());
}
} catch (Exception e) {
for (HybridFileParcelable f : files) {
FileUtils.scanFile(f.getPath(), cd);
}
}
}
// delete file entry from encrypted database
for (HybridFileParcelable file : files) {
if (file.getName().endsWith(CryptUtil.CRYPT_EXTENSION)) {
CryptHandler handler = new CryptHandler(cd);
handler.clear(file.getPath());
}
}
return wasDeleted;
}
use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class LoadFilesListTask method listVideos.
private ArrayList<LayoutElementParcelable> listVideos() {
ArrayList<LayoutElementParcelable> songs = new ArrayList<>();
final String[] projection = { MediaStore.Images.Media.DATA };
final Cursor cursor = c.getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
if (cursor.getCount() > 0 && cursor.moveToFirst()) {
do {
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
HybridFileParcelable strings = RootHelper.generateBaseFile(new File(path), showHiddenFiles);
if (strings != null) {
LayoutElementParcelable parcelable = createListParcelables(strings);
if (parcelable != null)
songs.add(parcelable);
}
} while (cursor.moveToNext());
}
cursor.close();
return songs;
}
use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class LoadFilesListTask method listRecent.
private ArrayList<LayoutElementParcelable> listRecent() {
UtilsHandler utilsHandler = new UtilsHandler(c);
final LinkedList<String> paths = utilsHandler.getHistoryLinkedList();
ArrayList<LayoutElementParcelable> songs = new ArrayList<>();
for (String f : paths) {
if (!f.equals("/")) {
HybridFileParcelable hybridFileParcelable = RootHelper.generateBaseFile(new File(f), showHiddenFiles);
if (hybridFileParcelable != null) {
hybridFileParcelable.generateMode(ma.getActivity());
if (!hybridFileParcelable.isSmb() && !hybridFileParcelable.isDirectory() && hybridFileParcelable.exists()) {
LayoutElementParcelable parcelable = createListParcelables(hybridFileParcelable);
if (parcelable != null)
songs.add(parcelable);
}
}
}
}
return songs;
}
use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class LoadFilesListTask method listDocs.
private ArrayList<LayoutElementParcelable> listDocs() {
ArrayList<LayoutElementParcelable> songs = new ArrayList<>();
final String[] projection = { MediaStore.Files.FileColumns.DATA };
Cursor cursor = c.getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, null, null, null);
String[] types = new String[] { ".pdf", ".xml", ".html", ".asm", ".text/x-asm", ".def", ".in", ".rc", ".list", ".log", ".pl", ".prop", ".properties", ".rc", ".doc", ".docx", ".msg", ".odt", ".pages", ".rtf", ".txt", ".wpd", ".wps" };
if (cursor.getCount() > 0 && cursor.moveToFirst()) {
do {
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
if (path != null && Arrays.asList(types).contains(path)) {
HybridFileParcelable strings = RootHelper.generateBaseFile(new File(path), showHiddenFiles);
if (strings != null) {
LayoutElementParcelable parcelable = createListParcelables(strings);
if (parcelable != null)
songs.add(parcelable);
}
}
} while (cursor.moveToNext());
}
cursor.close();
Collections.sort(songs, (lhs, rhs) -> -1 * Long.valueOf(lhs.date).compareTo(rhs.date));
if (songs.size() > 20)
for (int i = songs.size() - 1; i > 20; i--) {
songs.remove(i);
}
return songs;
}
Aggregations