use of androidx.recyclerview.widget.GridLayoutManager in project BaseRecyclerViewAdapterHelper by CymChad.
the class MultiItemQuickUseActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multiple_item_use);
setTitle("BaseMultiItemQuickAdapter");
setBackBtn();
RecyclerView mRecyclerView = findViewById(R.id.rv_list);
final List<QuickMultipleEntity> data = DataServer.getMultipleItemData();
final MultipleItemQuickAdapter multipleItemAdapter = new MultipleItemQuickAdapter(data);
final GridLayoutManager manager = new GridLayoutManager(this, 4);
mRecyclerView.setLayoutManager(manager);
multipleItemAdapter.setGridSpanSizeLookup(new GridSpanSizeLookup() {
@Override
public int getSpanSize(GridLayoutManager gridLayoutManager, int viewType, int position) {
return data.get(position).getSpanSize();
}
});
mRecyclerView.setAdapter(multipleItemAdapter);
}
use of androidx.recyclerview.widget.GridLayoutManager in project BaseRecyclerViewAdapterHelper by CymChad.
the class NodeSectionUseActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_node_section);
setBackBtn();
setTitle("Node Use (Section)");
mRecyclerView = findViewById(R.id.rv_list);
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
// mRecyclerView.addItemDecoration(new GridSectionAverageGapItemDecoration(10, 10, 20, 15));
final NodeSectionAdapter nodeAdapter = new NodeSectionAdapter();
// 顶部header
View view = getLayoutInflater().inflate(R.layout.head_view, mRecyclerView, false);
view.findViewById(R.id.iv).setVisibility(View.GONE);
nodeAdapter.addHeaderView(view);
mRecyclerView.setAdapter(nodeAdapter);
nodeAdapter.setList(getEntity());
mRecyclerView.scheduleLayoutAnimation();
}
use of androidx.recyclerview.widget.GridLayoutManager in project UltimateRecyclerView by cymcsg.
the class catelogGrid method renderviewlayout.
protected void renderviewlayout(View view) throws Exception {
listview_layout = (UltimateRecyclerView) view.findViewById(getUltimate_recycler_viewResId());
listview_layout.setHasFixedSize(true);
listview_layout.setSaveEnabled(true);
if (mLayoutManager == null) {
mLayoutManager = new GridLayoutManager(view.getContext(), getColumn(), LinearLayoutManager.VERTICAL, false);
}
listview_layout.setLayoutManager(mLayoutManager);
getProgressbar(view);
listview_layout.setAdapter(madapter = getAdatperWithdata());
setUltimateRecyclerViewExtra(listview_layout, madapter);
}
use of androidx.recyclerview.widget.GridLayoutManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ContextualCardsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final Context context = getContext();
final View rootView = inflater.inflate(R.layout.settings_homepage, container, false);
mCardsContainer = rootView.findViewById(R.id.card_container);
mLayoutManager = new GridLayoutManager(getActivity(), SPAN_COUNT, GridLayoutManager.VERTICAL, false);
mCardsContainer.setLayoutManager(mLayoutManager);
mContextualCardsAdapter = new ContextualCardsAdapter(context, this, /* lifecycleOwner */
mContextualCardManager);
mCardsContainer.setAdapter(mContextualCardsAdapter);
mContextualCardManager.setListener(mContextualCardsAdapter);
mCardsContainer.setListener(this);
mItemTouchHelper = new ItemTouchHelper(new SwipeDismissalDelegate(mContextualCardsAdapter));
mItemTouchHelper.attachToRecyclerView(mCardsContainer);
return rootView;
}
use of androidx.recyclerview.widget.GridLayoutManager in project SeriesGuide by UweTrottmann.
the class MoviesNowFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_now, container, false);
unbinder = ButterKnife.bind(this, view);
swipeRefreshLayout.setSwipeableChildren(R.id.scrollViewNow, R.id.recyclerViewNow);
swipeRefreshLayout.setOnRefreshListener(this::refreshStream);
swipeRefreshLayout.setProgressViewOffset(false, getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_start_margin), getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_end_margin));
emptyView.setText(R.string.now_movies_empty);
showError(null);
snackbarButton.setText(R.string.refresh);
snackbarButton.setOnClickListener(v -> refreshStream());
// recycler view layout manager
final int spanCount = getResources().getInteger(R.integer.grid_column_count);
final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), spanCount);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (adapter == null) {
return 1;
}
if (position >= adapter.getItemCount()) {
return 1;
}
// make headers and more links span all columns
int type = adapter.getItem(position).type;
return (type == NowAdapter.ItemType.HEADER || type == NowAdapter.ItemType.MORE_LINK) ? spanCount : 1;
}
});
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
new ViewModelProvider(requireActivity()).get(MoviesActivityViewModel.class).getScrollTabToTopLiveData().observe(getViewLifecycleOwner(), event -> {
if (event != null && event.getTabPosition() == MoviesActivity.TAB_POSITION_NOW) {
recyclerView.smoothScrollToPosition(0);
}
});
return view;
}
Aggregations