com.bumptech.glide.util.ViewPreloadSizeProvider Java Examples

The following examples show how to use com.bumptech.glide.util.ViewPreloadSizeProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FamiliarRecyclerView.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
@Override
public void setAdapter(Adapter adapter) {

    if (adapter instanceof BaseQuickAdapter) {
        mReqAdapter = (BaseQuickAdapter) adapter;
        removeOnScrollListener(mOnScrollListener);
        addOnScrollListener(mOnScrollListener);
    }

    if (adapter instanceof ListPreloaderQuickAdapter) {
        ListPreloaderQuickAdapter tempAdapter = (ListPreloaderQuickAdapter)adapter;
        RecyclerViewPreloader preloader =new RecyclerViewPreloader(Glide.with(getContext()), tempAdapter, new ViewPreloadSizeProvider(), tempAdapter.getMaxPreload());
        addOnScrollListener(preloader);
    }

    super.setAdapter(adapter);

    if (needInitAddItemDescration && null != mFamiliarDefaultItemDecoration) {
        needInitAddItemDescration = false;
        super.addItemDecoration(mFamiliarDefaultItemDecoration);
    }

}
 
Example #2
Source File: EntryListView.java    From Aegis with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_entry_list_view, container, false);
    _progressBar = view.findViewById(R.id.progressBar);

    // set up the recycler view
    _recyclerView = view.findViewById(R.id.rvKeyProfiles);
    _recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            _listener.onScroll(dx, dy);
        }
    });

    // set up icon preloading
    _preloadSizeProvider = new ViewPreloadSizeProvider<>();
    IconPreloadProvider modelProvider = new IconPreloadProvider();
    RecyclerViewPreloader<VaultEntry> preloader = new RecyclerViewPreloader<>(Glide.with(this), modelProvider, _preloadSizeProvider, 10);
    _recyclerView.addOnScrollListener(preloader);

    LinearLayoutManager layoutManager = new LinearLayoutManager(view.getContext());
    _recyclerView.setLayoutManager(layoutManager);
    _touchCallback = new SimpleItemTouchHelperCallback(_adapter);
    ItemTouchHelper touchHelper = new ItemTouchHelper(_touchCallback);
    touchHelper.attachToRecyclerView(_recyclerView);
    _recyclerView.setAdapter(_adapter);

    int resId = R.anim.layout_animation_fall_down;
    LayoutAnimationController animation = AnimationUtils.loadLayoutAnimation(getContext(), resId);
    _recyclerView.setLayoutAnimation(animation);

    _refresher = new UiRefresher(new UiRefresher.Listener() {
        @Override
        public void onRefresh() {
            refresh(false);
        }

        @Override
        public long getMillisTillNextRefresh() {
            return TotpInfo.getMillisTillNextRotation(_adapter.getMostFrequentPeriod());
        }
    });

    _emptyStateView = view.findViewById(R.id.vEmptyList);

    return view;
}