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);
}
}
});
}
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;
}
});
}
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);
}
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);
}
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);
}
Aggregations