Search in sources :

Example 1 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project CloudReader by youlookwhat.

the class TreeFragment method initRefreshView.

private void initRefreshView() {
    RefreshHelper.setSwipeRefreshView(bindingView.srlWan);
    bindingView.srlWan.setOnRefreshListener(() -> bindingView.srlWan.postDelayed(this::getTree, 150));
    LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
    bindingView.xrvWan.setLayoutManager(layoutManager);
    mTreeAdapter = new TreeAdapter(activity);
    bindingView.xrvWan.setAdapter(mTreeAdapter);
    HeaderItemTreeBinding oneBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.header_item_tree, null, false);
    bindingView.xrvWan.addHeaderView(oneBinding.getRoot());
    oneBinding.tvPosition.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!mTreeAdapter.isSelect()) {
                GridLayoutManager layoutManager = new GridLayoutManager(activity, 2);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("选择类别");
                mTreeAdapter.setSelect(true);
                mTreeAdapter.notifyDataSetChanged();
                bindingView.xrvWan.addItemDecoration(new SpacesItemDecoration(activity).setNoShowDivider(1, 0).setDrawable(R.drawable.shape_line));
            } else {
                LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("发现页内容订制");
                mTreeAdapter.setSelect(false);
                mTreeAdapter.notifyDataSetChanged();
                if (bindingView.xrvWan.getItemDecorationCount() > 0) {
                    bindingView.xrvWan.removeItemDecorationAt(0);
                }
            }
        }
    });
    bindingView.xrvWan.setOnItemClickListener(new OnItemFilterClickListener() {

        @Override
        public void onSingleClick(View v, int position) {
            if (mTreeAdapter.isSelect()) {
                if (mTreeAdapter.getSelectedPosition() == position) {
                    ToastUtil.showToastLong("当前已经是\"" + mTreeAdapter.getData().get(position).getName() + "\"");
                    return;
                }
                LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
                bindingView.xrvWan.setLayoutManager(layoutManager);
                oneBinding.tvPosition.setText("发现页内容订制");
                mTreeAdapter.setSelect(false);
                mTreeAdapter.notifyDataSetChanged();
                if (bindingView.xrvWan.getItemDecorationCount() > 0) {
                    bindingView.xrvWan.removeItemDecorationAt(0);
                }
                layoutManager.scrollToPositionWithOffset(position + bindingView.xrvWan.getCustomTopItemViewCount(), 0);
                RxBus.getDefault().post(RxCodeConstants.FIND_CUSTOM, position);
            }
        }
    });
}
Also used : HeaderItemTreeBinding(com.example.jingbin.cloudreader.databinding.HeaderItemTreeBinding) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) OnItemFilterClickListener(me.jingbin.library.view.OnItemFilterClickListener) TreeAdapter(com.example.jingbin.cloudreader.adapter.TreeAdapter) SpacesItemDecoration(me.jingbin.library.decoration.SpacesItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View)

Example 2 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project fresco by facebook.

the class DraweeRecyclerViewFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    final RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
    recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            final int imageSize = (right - left) / SPAN_COUNT;
            mResizeOptions = new ResizeOptions(imageSize, imageSize);
        }
    });
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), SPAN_COUNT);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    final SimpleAdapter adapter = new SimpleAdapter(new ArrayList<Uri>());
    recyclerView.setAdapter(adapter);
    final Spinner imageSource = view.findViewById(R.id.spinner_image_source);
    ImageSourceSpinner.INSTANCE.setup(imageSource, sampleUris(), new Function1<List<Uri>, Unit>() {

        @Override
        public Unit invoke(List<Uri> uris) {
            adapter.setData(uris);
            return null;
        }
    });
}
Also used : ImageSourceSpinner(com.facebook.fresco.samples.showcase.misc.ImageSourceSpinner) Spinner(android.widget.Spinner) Unit(kotlin.Unit) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Uri(android.net.Uri) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) RecyclerView(androidx.recyclerview.widget.RecyclerView) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project Carbon by ZieIony.

the class BottomSheetLayout method updateRecycler.

private void updateRecycler() {
    if (menu == null)
        return;
    recycler.setLayoutManager(style == Style.List ? new LinearLayoutManager(getContext()) : new GridLayoutManager(getContext(), 3));
    ArrayList<Serializable> items = new ArrayList<>();
    for (int i = 0; i < menu.size(); i++) {
        if (menu.getItem(i).isVisible())
            items.add(new Item(menu.getItem(i)));
    }
    if (style == Style.List) {
        for (int i = 0; i < recycler.getItemDecorationCount(); i++) recycler.removeItemDecorationAt(0);
        ViewItemDecoration dividerItemDecoration = new ViewItemDecoration(getContext(), R.layout.carbon_menustrip_hseparator_item);
        dividerItemDecoration.setDrawAfter(position -> position < items.size() - 1 && items.get(position) instanceof NavigationView.Item && items.get(position + 1) instanceof NavigationView.Item && ((NavigationView.Item) items.get(position)).getGroupId() != ((NavigationView.Item) items.get(position + 1)).getGroupId());
        recycler.addItemDecoration(dividerItemDecoration);
        ViewItemDecoration paddingItemDecoration = new ViewItemDecoration(getContext(), R.layout.carbon_row_padding);
        paddingItemDecoration.setDrawAfter(position -> position == items.size() - 1);
        recycler.addItemDecoration(paddingItemDecoration);
    }
    RowListAdapter<Serializable> adapter = new RowListAdapter<>();
    adapter.putFactory(Item.class, style == Style.List ? BottomSheetRow::new : BottomSheetCell::new);
    adapter.setItems(items);
    recycler.setAdapter(adapter);
}
Also used : MenuItem(android.view.MenuItem) Serializable(java.io.Serializable) NavigationView(carbon.widget.NavigationView) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ViewItemDecoration(carbon.recycler.ViewItemDecoration) ArrayList(java.util.ArrayList) RowListAdapter(carbon.recycler.RowListAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 4 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project PhotoView by chrisbanes.

the class ActivityTransitionActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transition);
    RecyclerView list = findViewById(R.id.list);
    list.setLayoutManager(new GridLayoutManager(this, 2));
    ImageAdapter imageAdapter = new ImageAdapter(new ImageAdapter.Listener() {

        @Override
        public void onImageClicked(View view) {
            transition(view);
        }
    });
    list.setAdapter(imageAdapter);
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 5 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project OneSignal-Android-SDK by OneSignal.

the class MainActivityViewModel method setupInAppMessagingLayout.

private void setupInAppMessagingLayout() {
    recyclerViewBuilder.setupRecyclerView(inAppMessagingRecyclerView, 4, false, true);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2);
    inAppMessagingRecyclerView.setLayoutManager(gridLayoutManager);
    inAppMessagingRecyclerViewAdapter = new InAppMessageRecyclerViewAdapter(context, InAppMessage.values());
    inAppMessagingRecyclerView.setAdapter(inAppMessagingRecyclerViewAdapter);
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) InAppMessageRecyclerViewAdapter(com.onesignal.sdktest.adapter.InAppMessageRecyclerViewAdapter)

Aggregations

GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)109 RecyclerView (androidx.recyclerview.widget.RecyclerView)57 View (android.view.View)44 TextView (android.widget.TextView)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)14 ImageView (android.widget.ImageView)11 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)11 Toolbar (androidx.appcompat.widget.Toolbar)10 Nullable (androidx.annotation.Nullable)9 SmoothScrollGridLayoutManager (eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)7 ViewGroup (android.view.ViewGroup)6 SuppressLint (android.annotation.SuppressLint)5 Context (android.content.Context)5 NonNull (androidx.annotation.NonNull)5 ArrayList (java.util.ArrayList)5 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)5 List (java.util.List)4 Handler (android.os.Handler)3 FrameLayout (android.widget.FrameLayout)3 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)3