use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.
the class RecyclerAdapter method setItems.
private void setItems(RecyclerView recyclerView, ArrayList<LayoutElementParcelable> arrayList, boolean invalidate) {
if (preloader != null) {
recyclerView.removeOnScrollListener(preloader);
preloader = null;
}
itemsDigested.clear();
offset = 0;
stoppedAnimation = false;
ArrayList<IconDataParcelable> uris = new ArrayList<>(itemsDigested.size());
for (LayoutElementParcelable e : arrayList) {
itemsDigested.add(new ListItem(e));
uris.add(e != null ? e.iconData : null);
}
if (mainFrag.IS_LIST && itemsDigested.size() > 0) {
itemsDigested.add(new ListItem(EMPTY_LAST_ITEM));
uris.add(null);
}
for (int i = 0; i < itemsDigested.size(); i++) {
itemsDigested.get(i).setAnimate(false);
}
if (getBoolean(PREFERENCE_SHOW_HEADERS)) {
createHeaders(invalidate, uris);
}
sizeProvider = new RecyclerPreloadSizeProvider(this);
modelProvider = new RecyclerPreloadModelProvider(mainFrag, uris, getBoolean(PREFERENCE_SHOW_THUMB));
preloader = new RecyclerViewPreloader<>(GlideApp.with(mainFrag), modelProvider, sizeProvider, GlideConstants.MAX_PRELOAD_FILES);
recyclerView.addOnScrollListener(preloader);
}
use of com.amaze.filemanager.adapters.data.LayoutElementParcelable 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.adapters.data.LayoutElementParcelable 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.adapters.data.LayoutElementParcelable 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;
}
use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.
the class LoadFilesListTask method createListParcelables.
private LayoutElementParcelable createListParcelables(HybridFileParcelable baseFile) {
if (!dataUtils.isFileHidden(baseFile.getPath())) {
String size = "";
long longSize = 0;
if (baseFile.isDirectory()) {
ma.folder_count++;
} else {
if (baseFile.getSize() != -1) {
try {
longSize = baseFile.getSize();
size = Formatter.formatFileSize(c, longSize);
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
ma.file_count++;
}
LayoutElementParcelable layoutElement = new LayoutElementParcelable(baseFile.getPath(), baseFile.getPermission(), baseFile.getLink(), size, longSize, baseFile.isDirectory(), false, baseFile.getDate() + "", showThumbs);
layoutElement.setMode(baseFile.getMode());
return layoutElement;
}
return null;
}
Aggregations