use of com.bumptech.glide.util.ViewPreloadSizeProvider in project AmazeFileManager by TeamAmaze.
the class AppsListFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setRetainInstance(true);
MainActivity mainActivity = (MainActivity) getActivity();
mainActivity.getAppbar().setTitle(R.string.apps);
mainActivity.floatingActionButton.getMenuButton().hide();
mainActivity.getAppbar().getBottomBar().setVisibility(View.GONE);
mainActivity.supportInvalidateOptionsMenu();
vl = getListView();
Sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
getSortModes();
ListView vl = getListView();
vl.setDivider(null);
if (utilsProvider.getAppTheme().equals(AppTheme.DARK))
getActivity().getWindow().getDecorView().setBackgroundColor(Utils.getColor(getContext(), R.color.holo_dark_background));
else if (utilsProvider.getAppTheme().equals(AppTheme.BLACK))
getActivity().getWindow().getDecorView().setBackgroundColor(Utils.getColor(getContext(), android.R.color.black));
modelProvider = new AppsAdapterPreloadModel(app);
ViewPreloadSizeProvider<String> sizeProvider = new ViewPreloadSizeProvider<>();
ListPreloader<String> preloader = new ListPreloader<>(GlideApp.with(app), modelProvider, sizeProvider, GlideConstants.MAX_PRELOAD_APPSADAPTER);
adapter = new AppsAdapter(getContext(), (ThemedActivity) getActivity(), utilsProvider, modelProvider, sizeProvider, R.layout.rowlayout, app);
getListView().setOnScrollListener(preloader);
setListAdapter(adapter);
setListShown(false);
setEmptyText(getResources().getString(R.string.no_applications));
getLoaderManager().initLoader(ID_LOADER_APP_LIST, null, this);
if (savedInstanceState != null) {
index = savedInstanceState.getInt(KEY_INDEX);
top = savedInstanceState.getInt(KEY_TOP);
}
}
use of com.bumptech.glide.util.ViewPreloadSizeProvider in project glide by bumptech.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView giphyLogoView = findViewById(R.id.giphy_logo_view);
GlideApp.with(this).load(R.raw.large_giphy_logo).into(giphyLogoView);
RecyclerView gifList = findViewById(R.id.gif_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
gifList.setLayoutManager(layoutManager);
RequestBuilder<Drawable> gifItemRequest = GlideApp.with(this).asDrawable();
ViewPreloadSizeProvider<Api.GifResult> preloadSizeProvider = new ViewPreloadSizeProvider<>();
adapter = new GifAdapter(this, gifItemRequest, preloadSizeProvider);
gifList.setAdapter(adapter);
RecyclerViewPreloader<Api.GifResult> preloader = new RecyclerViewPreloader<>(GlideApp.with(this), adapter, preloadSizeProvider, 4);
gifList.addOnScrollListener(preloader);
gifList.setRecyclerListener(new RecyclerListener() {
@Override
public void onViewRecycled(ViewHolder holder) {
// This is an optimization to reduce the memory usage of RecyclerView's recycled view pool
// and good practice when using Glide with RecyclerView.
GifViewHolder gifViewHolder = (GifViewHolder) holder;
GlideApp.with(MainActivity.this).clear(gifViewHolder.gifView);
}
});
}
Aggregations