use of androidx.recyclerview.widget.LinearLayoutManager in project Tusky by Vavassor.
the class ViewThreadFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_view_thread, container, false);
Context context = getContext();
swipeRefreshLayout = rootView.findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue);
recyclerView = rootView.findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAccessibilityDelegateCompat(new ListStatusAccessibilityDelegate(recyclerView, this, statuses::getPairedItemOrNull));
DividerItemDecoration divider = new DividerItemDecoration(context, layoutManager.getOrientation());
recyclerView.addItemDecoration(divider);
recyclerView.addItemDecoration(new ConversationLineItemDecoration(context));
alwaysShowSensitiveMedia = accountManager.getActiveAccount().getAlwaysShowSensitiveMedia();
alwaysOpenSpoiler = accountManager.getActiveAccount().getAlwaysOpenSpoiler();
reloadFilters();
recyclerView.setAdapter(adapter);
statuses.clear();
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
return rootView;
}
use of androidx.recyclerview.widget.LinearLayoutManager in project banner by youth5201314.
the class MarginDecoration method getItemOffsets.
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
LinearLayoutManager linearLayoutManager = requireLinearLayoutManager(parent);
if (linearLayoutManager.getOrientation() == LinearLayoutManager.VERTICAL) {
outRect.top = mMarginPx;
outRect.bottom = mMarginPx;
} else {
outRect.left = mMarginPx;
outRect.right = mMarginPx;
}
}
use of androidx.recyclerview.widget.LinearLayoutManager in project banner by youth5201314.
the class RecyclerViewBannerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recyclerview_banner);
ButterKnife.bind(this);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(new MyRecyclerViewAdapter(this));
}
use of androidx.recyclerview.widget.LinearLayoutManager in project banner by youth5201314.
the class BannerListFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
text.setText("当前页:" + index);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(new MyRecyclerViewAdapter(getActivity()));
}
use of androidx.recyclerview.widget.LinearLayoutManager 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);
}
Aggregations