use of androidx.recyclerview.widget.LinearLayoutManager in project Signal-Android by WhisperSystems.
the class CameraContactSelectionFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
this.contactList = view.findViewById(R.id.camera_contacts_list);
this.selectionList = view.findViewById(R.id.camera_contacts_selected_list);
this.toolbar = view.findViewById(R.id.camera_contacts_toolbar);
this.sendButton = view.findViewById(R.id.camera_contacts_send_button);
this.selectionFooterGroup = view.findViewById(R.id.camera_contacts_footer_group);
this.cameraContactsEmpty = view.findViewById(R.id.camera_contacts_empty);
this.inviteButton = view.findViewById(R.id.camera_contacts_invite_button);
this.contactAdapter = new CameraContactAdapter(GlideApp.with(this), this);
this.selectionAdapter = new CameraContactSelectionAdapter();
contactList.setLayoutManager(new LinearLayoutManager(requireContext()));
contactList.setAdapter(contactAdapter);
selectionList.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
selectionList.setAdapter(selectionAdapter);
((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
((AppCompatActivity) requireActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(v -> requireActivity().onBackPressed());
inviteButton.setOnClickListener(v -> onInviteContactsClicked());
initViewModel();
}
use of androidx.recyclerview.widget.LinearLayoutManager in project Signal-Android by WhisperSystems.
the class MediaPreviewActivity method initializeViews.
private void initializeViews() {
mediaPager = findViewById(R.id.media_pager);
mediaPager.setOffscreenPageLimit(1);
mediaPager.setPageTransformer(true, new DepthPageTransformer());
viewPagerListener = new ViewPagerListener();
mediaPager.addOnPageChangeListener(viewPagerListener);
albumRail = findViewById(R.id.media_preview_album_rail);
albumRailAdapter = new MediaRailAdapter(GlideApp.with(this), this, false);
// Or can crash when set to INVISIBLE while animating by FullscreenHelper https://issuetracker.google.com/issues/148720682
albumRail.setItemAnimator(null);
albumRail.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
albumRail.setAdapter(albumRailAdapter);
detailsContainer = findViewById(R.id.media_preview_details_container);
caption = findViewById(R.id.media_preview_caption);
captionContainer = findViewById(R.id.media_preview_caption_container);
playbackControlsContainer = findViewById(R.id.media_preview_playback_controls_container);
View toolbarLayout = findViewById(R.id.toolbar_layout);
anchorMarginsToBottomInsets(detailsContainer);
fullscreenHelper.configureToolbarSpacer(findViewById(R.id.toolbar_cutout_spacer));
fullscreenHelper.showAndHideWithSystemUI(getWindow(), detailsContainer, toolbarLayout);
}
use of androidx.recyclerview.widget.LinearLayoutManager in project greenDAO by greenrobot.
the class MainActivity method setUpViews.
protected void setUpViews() {
RecyclerView recyclerView = findViewById(R.id.recyclerViewNotes);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
notesAdapter = new NotesAdapter(noteClickListener);
recyclerView.setAdapter(notesAdapter);
addNoteButton = findViewById(R.id.buttonAdd);
editText = findViewById(R.id.editTextNote);
RxTextView.editorActions(editText).observeOn(AndroidSchedulers.mainThread()).subscribe(actionId -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
addNote();
}
});
RxTextView.afterTextChangeEvents(editText).observeOn(AndroidSchedulers.mainThread()).subscribe(textViewAfterTextChangeEvent -> {
boolean enable = textViewAfterTextChangeEvent.editable().length() > 0;
addNoteButton.setEnabled(enable);
});
}
use of androidx.recyclerview.widget.LinearLayoutManager in project RecyclerViewSnap by rubensousa.
the class GravitySnapHelper method calculateDistanceToFinalSnap.
@Override
@NonNull
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View targetView) {
if (gravity == Gravity.CENTER) {
// noinspection ConstantConditions
return super.calculateDistanceToFinalSnap(layoutManager, targetView);
}
int[] out = new int[2];
if (!(layoutManager instanceof LinearLayoutManager)) {
return out;
}
LinearLayoutManager lm = (LinearLayoutManager) layoutManager;
if (lm.canScrollHorizontally()) {
if ((isRtl && gravity == Gravity.END) || (!isRtl && gravity == Gravity.START)) {
out[0] = getDistanceToStart(targetView, getHorizontalHelper(lm));
} else {
out[0] = getDistanceToEnd(targetView, getHorizontalHelper(lm));
}
} else if (lm.canScrollVertically()) {
if (gravity == Gravity.TOP) {
out[1] = getDistanceToStart(targetView, getVerticalHelper(lm));
} else {
out[1] = getDistanceToEnd(targetView, getVerticalHelper(lm));
}
}
return out;
}
use of androidx.recyclerview.widget.LinearLayoutManager in project FlexibleAdapter by davideas.
the class FlexibleLayoutManager method findLastVisibleItemPosition.
/**
* Helper method to find the adapter position of the <b>last partially</b> visible view
* [for each span], no matter which Layout is.
*
* @return the adapter position of the <b>last partially</b> visible item or {@code RecyclerView.NO_POSITION}
* if there aren't any visible items.
* @see #findLastCompletelyVisibleItemPosition()
* @since 5.0.0-rc1
*/
@Override
public int findLastVisibleItemPosition() {
RecyclerView.LayoutManager layoutManager = getLayoutManager();
if (layoutManager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager staggeredGLM = (StaggeredGridLayoutManager) layoutManager;
int position = staggeredGLM.findLastVisibleItemPositions(null)[0];
for (int i = 1; i < getSpanCount(); i++) {
int nextPosition = staggeredGLM.findLastVisibleItemPositions(null)[i];
if (nextPosition > position) {
position = nextPosition;
}
}
return position;
} else {
return ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
}
}
Aggregations