use of androidx.recyclerview.widget.GridLayoutManager in project AntennaPod by AntennaPod.
the class VariableSpeedDialog method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = View.inflate(getContext(), R.layout.speed_select_dialog, null);
speedSeekBar = root.findViewById(R.id.speed_seek_bar);
speedSeekBar.setProgressChangedListener(multiplier -> {
if (controller != null) {
controller.setPlaybackSpeed(multiplier);
}
});
RecyclerView selectedSpeedsGrid = root.findViewById(R.id.selected_speeds_grid);
selectedSpeedsGrid.setLayoutManager(new GridLayoutManager(getContext(), 3));
selectedSpeedsGrid.addItemDecoration(new ItemOffsetDecoration(getContext(), 4));
adapter = new SpeedSelectionAdapter();
adapter.setHasStableIds(true);
selectedSpeedsGrid.setAdapter(adapter);
addCurrentSpeedChip = root.findViewById(R.id.add_current_speed_chip);
addCurrentSpeedChip.setCloseIconVisible(true);
addCurrentSpeedChip.setCloseIconResource(R.drawable.ic_add);
addCurrentSpeedChip.setOnCloseIconClickListener(v -> addCurrentSpeed());
addCurrentSpeedChip.setOnClickListener(v -> addCurrentSpeed());
return root;
}
use of androidx.recyclerview.widget.GridLayoutManager in project MyJapanese by 54wall.
the class GojuonMemoryFragment method setRecyclerView.
@Override
public void setRecyclerView(int type) {
switch(type) {
case Constants.GOJUON_CHENGYU:
RecyclerView.LayoutManager layoutManager2 = new GridLayoutManager(getContext(), Constants.COLUMN_CHENGYU);
mRecyclerView.setLayoutManager(layoutManager2);
break;
case Constants.GOJUON_MEMORY:
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(linearLayoutManager);
break;
default:
break;
}
}
use of androidx.recyclerview.widget.GridLayoutManager in project wire-android by wireapp.
the class EmojiKeyboardLayout method init.
private void init() {
currentEmojiSize = EmojiSize.MEDIUM;
categoryPositions = new int[CATEGORY_COUNT];
emojiAdapter = new EmojiAdapter(getContext());
layoutManager = new GridLayoutManager(getContext(), SPAN_COUNT, LinearLayoutManager.HORIZONTAL, false);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return spaces.contains(position) ? SPAN_COUNT : 1;
}
});
layoutManager.setSpanCount(SPAN_COUNT);
recyclerView.addOnScrollListener(new EmojiScrollListener());
tapIndicatorLayout.setShowDivider(false);
tapIndicatorLayout.setGlyphLabels(Emojis.EMOJI_KEYBOARD_TAB_LABELS);
tapIndicatorLayout.setTextColor(ContextCompat.getColorStateList(getContext(), R.color.wire__text_color_dark_selector));
tapIndicatorLayout.setPrimaryColor(ContextCompat.getColor(getContext(), R.color.text__primary_dark));
tapIndicatorLayout.setLabelHeight(getContext().getResources().getDimensionPixelSize(R.dimen.sketch__emoji__keyboard__tab_label_size));
tapIndicatorLayout.setCallback(new TabIndicatorLayout.Callback() {
@Override
public void onItemSelected(int pos) {
if (ViewCompat.getLayoutDirection(EmojiKeyboardLayout.this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
// Revert tab position for RTL layout
pos = (TAB_COUNT - 1) - pos;
}
if (pos == TAB_COUNT - 1) {
Threading.Background().execute(new Runnable() {
@Override
public void run() {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DEL);
}
});
} else {
tapIndicatorLayout.setSelected(pos);
layoutManager.scrollToPositionWithOffset(getCategoryByTabPosition(pos), 0);
}
}
});
recyclerView.setAdapter(emojiAdapter);
recyclerView.setLayoutManager(layoutManager);
setRecyclerViewPadding(recyclerView);
emojiAdapter.setOnEmojiClickListener(new EmojiAdapter.OnEmojiClickListener() {
@Override
public void onEmojiClick(String emoji, EmojiSize emojiSize) {
if (callback != null) {
callback.onEmojiSelected(emoji);
}
}
});
}
use of androidx.recyclerview.widget.GridLayoutManager in project wire-android by wireapp.
the class CursorImagesLayout method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
recyclerView = ViewUtils.getView(this, R.id.rv__cursor_images);
recyclerView.setHasFixedSize(true);
recyclerView.setDrawingCacheEnabled(true);
recyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
GridLayoutManager layout = new GridLayoutManager(getContext(), IMAGE_ROWS, GridLayoutManager.HORIZONTAL, false);
layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return (cursorImagesAdapter.getItemViewType(position) == CursorImagesAdapter.VIEW_TYPE_CAMERA) ? IMAGE_ROWS : 1;
}
});
recyclerView.setLayoutManager(layout);
int dividerSpacing = getContext().getResources().getDimensionPixelSize(R.dimen.extended_container__camera__gallery_grid__divider__spacing);
recyclerView.addItemDecoration(new CursorImagesItemDecoration(dividerSpacing));
buttonNavToCamera = ViewUtils.getView(this, R.id.gtv__cursor_image__nav_camera_back);
buttonOpenGallery = ViewUtils.getView(this, R.id.gtv__cursor_image__nav_open_gallery);
buttonNavToCamera.setVisibility(View.GONE);
buttonNavToCamera.setOnClickListener(this);
buttonOpenGallery.setOnClickListener(this);
}
use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.
the class FragmentExpandableMultiLevel 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_layout_item:
case R.layout.recycler_scrollable_uls_item:
case R.layout.recycler_header_item:
case R.layout.recycler_expandable_header_item:
case R.layout.recycler_expandable_item:
return mColumnCount;
default:
return 1;
}
}
});
return gridLayoutManager;
}
Aggregations