Search in sources :

Example 1 with RecyclerPreloadSizeProvider

use of com.amaze.filemanager.adapters.glide.RecyclerPreloadSizeProvider 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)

Aggregations

IconDataParcelable (com.amaze.filemanager.adapters.data.IconDataParcelable)1 LayoutElementParcelable (com.amaze.filemanager.adapters.data.LayoutElementParcelable)1 RecyclerPreloadModelProvider (com.amaze.filemanager.adapters.glide.RecyclerPreloadModelProvider)1 RecyclerPreloadSizeProvider (com.amaze.filemanager.adapters.glide.RecyclerPreloadSizeProvider)1 ArrayList (java.util.ArrayList)1