Search in sources :

Example 51 with GridLayoutManager

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);
}
Also used : QuickMultipleEntity(com.chad.baserecyclerviewadapterhelper.entity.QuickMultipleEntity) GridSpanSizeLookup(com.chad.library.adapter.base.listener.GridSpanSizeLookup) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) MultipleItemQuickAdapter(com.chad.baserecyclerviewadapterhelper.adapter.multi.MultipleItemQuickAdapter)

Example 52 with GridLayoutManager

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();
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) NodeSectionAdapter(com.chad.baserecyclerviewadapterhelper.adapter.node.section.NodeSectionAdapter) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 53 with GridLayoutManager

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);
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager)

Example 54 with GridLayoutManager

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;
}
Also used : Context(android.content.Context) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SwipeDismissalDelegate(com.android.settings.homepage.contextualcards.slices.SwipeDismissalDelegate) View(android.view.View)

Example 55 with GridLayoutManager

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;
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Nullable(androidx.annotation.Nullable)

Aggregations

GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)122 RecyclerView (androidx.recyclerview.widget.RecyclerView)63 View (android.view.View)45 TextView (android.widget.TextView)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)16 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 ImageView (android.widget.ImageView)12 Nullable (androidx.annotation.Nullable)11 Toolbar (androidx.appcompat.widget.Toolbar)10 ViewGroup (android.view.ViewGroup)7 SmoothScrollGridLayoutManager (eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)7 SuppressLint (android.annotation.SuppressLint)6 Context (android.content.Context)6 ArrayList (java.util.ArrayList)6 NonNull (androidx.annotation.NonNull)5 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)5 List (java.util.List)5 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)5 Drawable (android.graphics.drawable.Drawable)4 Handler (android.os.Handler)3