Search in sources :

Example 6 with LayoutElementParcelable

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);
}
Also used : RecyclerPreloadModelProvider(com.amaze.filemanager.adapters.glide.RecyclerPreloadModelProvider) IconDataParcelable(com.amaze.filemanager.adapters.data.IconDataParcelable) ArrayList(java.util.ArrayList) RecyclerPreloadSizeProvider(com.amaze.filemanager.adapters.glide.RecyclerPreloadSizeProvider) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable)

Example 7 with LayoutElementParcelable

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;
}
Also used : HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) ArrayList(java.util.ArrayList) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) Cursor(android.database.Cursor) HybridFile(com.amaze.filemanager.filesystem.HybridFile) File(java.io.File) SmbFile(jcifs.smb.SmbFile)

Example 8 with LayoutElementParcelable

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;
}
Also used : HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) ArrayList(java.util.ArrayList) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) HybridFile(com.amaze.filemanager.filesystem.HybridFile) File(java.io.File) SmbFile(jcifs.smb.SmbFile) UtilsHandler(com.amaze.filemanager.database.UtilsHandler)

Example 9 with LayoutElementParcelable

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;
}
Also used : HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) ArrayList(java.util.ArrayList) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) Cursor(android.database.Cursor) HybridFile(com.amaze.filemanager.filesystem.HybridFile) File(java.io.File) SmbFile(jcifs.smb.SmbFile)

Example 10 with LayoutElementParcelable

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;
}
Also used : LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable)

Aggregations

LayoutElementParcelable (com.amaze.filemanager.adapters.data.LayoutElementParcelable)18 File (java.io.File)11 ArrayList (java.util.ArrayList)11 SmbFile (jcifs.smb.SmbFile)11 HybridFile (com.amaze.filemanager.filesystem.HybridFile)10 HybridFileParcelable (com.amaze.filemanager.filesystem.HybridFileParcelable)10 Cursor (android.database.Cursor)6 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Intent (android.content.Intent)2 SharedPreferences (android.content.SharedPreferences)2 View (android.view.View)2 SmbException (jcifs.smb.SmbException)2 Context (android.content.Context)1 Color (android.graphics.Color)1 Typeface (android.graphics.Typeface)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 FingerprintManager (android.hardware.fingerprint.FingerprintManager)1 Uri (android.net.Uri)1 AsyncTask (android.os.AsyncTask)1 Build (android.os.Build)1