use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.
the class FragmentEndlessScrolling method createNewGridLayoutManager.
@Override
protected GridLayoutManager createNewGridLayoutManager() {
GridLayoutManager gridLayoutManager = new SmoothScrollGridLayoutManager(getActivity(), mColumnCount);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
// here, you should use them and not Layout integers
switch(mAdapter.getItemViewType(position)) {
case R.layout.recycler_scrollable_expandable_item:
case R.layout.recycler_scrollable_header_item:
case R.layout.recycler_scrollable_footer_item:
case R.layout.recycler_scrollable_layout_item:
case R.layout.recycler_scrollable_uls_item:
case R.layout.progress_item:
return mColumnCount;
default:
return 1;
}
}
});
return gridLayoutManager;
}
use of androidx.recyclerview.widget.GridLayoutManager in project wire-android by wireapp.
the class EmojiBottomSheetDialog method init.
private void init(List<String> recent, Set<String> unsupported) {
populateEmojis(recent, unsupported);
final RecyclerView recyclerView = new RecyclerView(getContext());
final EmojiAdapter adapter = new EmojiAdapter(getContext());
final GridLayoutManager layoutManager = new GridLayoutManager(getContext(), getEmojiLayoutManagerSpanCount(), LinearLayoutManager.HORIZONTAL, false);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return spaces.contains(position) ? getEmojiLayoutManagerSpanCount() : 1;
}
});
LinearLayout ll = new LinearLayout(getContext());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// noinspection deprecation
ll.setBackgroundColor(getContext().getResources().getColor(R.color.background_graphite));
} else {
ll.setBackgroundColor(getContext().getResources().getColor(R.color.background_graphite, getContext().getTheme()));
}
ll.setOrientation(LinearLayout.VERTICAL);
final TabIndicatorLayout til = new TabIndicatorLayout(getContext());
int[] labels = new int[3];
labels[0] = R.string.sketch__emoji_keyboard__size_label__small;
labels[1] = R.string.sketch__emoji_keyboard__size_label__medium;
labels[2] = R.string.sketch__emoji_keyboard__size_label__large;
til.setLabels(labels);
til.setSelected(currentEmojiSize.ordinal());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// noinspection deprecation
til.setTextColor(getContext().getResources().getColorStateList(R.color.wire__text_color_dark_selector));
// noinspection deprecation
til.setPrimaryColor(getContext().getResources().getColor(R.color.text__primary_dark));
} else {
til.setTextColor(getContext().getResources().getColorStateList(R.color.wire__text_color_dark_selector, getContext().getTheme()));
til.setPrimaryColor(getContext().getResources().getColor(R.color.text__primary_dark, getContext().getTheme()));
}
til.setLabelHeight(getContext().getResources().getDimensionPixelSize(R.dimen.sketch__emoji__keyboard__tab_label_size));
til.setCallback(new TabIndicatorLayout.Callback() {
@Override
public void onItemSelected(int pos) {
til.setSelected(pos);
currentEmojiSize = EmojiSize.values()[pos];
adapter.setEmojiSize(currentEmojiSize);
setRecyclerViewPadding(recyclerView);
layoutManager.setSpanCount(getEmojiLayoutManagerSpanCount());
}
});
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getContext().getResources().getDimensionPixelSize(R.dimen.sketch__emoji__keyboard__tab_size));
ll.addView(til, params);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
ll.addView(recyclerView);
setRecyclerViewPadding(recyclerView);
adapter.setOnEmojiClickListener(new EmojiAdapter.OnEmojiClickListener() {
@Override
public void onEmojiClick(String emoji, EmojiSize emojiSize) {
if (listener != null) {
listener.onEmojiSelected(emoji, emojiSize);
}
dismiss();
}
});
adapter.setEmojis(emojis, currentEmojiSize);
setContentView(ll);
}
use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.
the class FragmentOverall method createNewGridLayoutManager.
@Override
protected GridLayoutManager createNewGridLayoutManager() {
mAdapter.setAnimationEntryStep(false);
GridLayoutManager gridLayoutManager = new SmoothScrollGridLayoutManager(getActivity(), mColumnCount);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return mAdapter.getItem(position).getSpanSize(mColumnCount, position);
}
});
return gridLayoutManager;
}
use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.
the class FragmentOverall method onPrepareOptionsMenu.
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
MenuItem gridMenuItem = menu.findItem(R.id.action_list_type);
if (mRecyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
gridMenuItem.setIcon(R.drawable.ic_view_agenda_white_24dp);
gridMenuItem.setTitle(R.string.linear_layout);
} else if (mRecyclerView.getLayoutManager() instanceof GridLayoutManager) {
gridMenuItem.setIcon(R.drawable.ic_dashboard_white_24dp);
gridMenuItem.setTitle(R.string.staggered_layout);
} else {
gridMenuItem.setIcon(R.drawable.ic_view_grid_white_24dp);
gridMenuItem.setTitle(R.string.grid_layout);
}
}
use of androidx.recyclerview.widget.GridLayoutManager in project Android-SpinKit by ybq.
the class StyleFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4);
layoutManager.setOrientation(RecyclerView.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(new RecyclerView.Adapter<Holder>() {
@Override
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
@SuppressLint("InflateParams") View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_style, null);
return new Holder(view);
}
@Override
public void onBindViewHolder(Holder holder, int position) {
holder.bind(position);
}
@Override
public int getItemCount() {
return Style.values().length;
}
});
}
Aggregations