use of com.hippo.widget.recyclerview.AutoGridLayoutManager in project EhViewer by seven332.
the class GalleryPreviewsScene method onCreateView3.
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ContentLayout contentLayout = (ContentLayout) inflater.inflate(R.layout.scene_gallery_previews, container, false);
contentLayout.hideFastScroll();
mRecyclerView = contentLayout.getRecyclerView();
Context context = getContext2();
Assert.assertNotNull(context);
Resources resources = context.getResources();
mAdapter = new GalleryPreviewAdapter();
mRecyclerView.setAdapter(mAdapter);
int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId());
AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth);
layoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setClipToPadding(false);
mRecyclerView.setOnItemClickListener(this);
int padding = LayoutUtils.dp2pix(context, 4);
MarginItemDecoration decoration = new MarginItemDecoration(padding, padding, padding, padding, padding);
mRecyclerView.addItemDecoration(decoration);
decoration.applyPaddings(mRecyclerView);
mHelper = new GalleryPreviewHelper();
contentLayout.setHelper(mHelper);
// Only refresh for the first time
if (!mHasFirstRefresh) {
mHasFirstRefresh = true;
mHelper.firstRefresh();
}
return contentLayout;
}
Aggregations