Search in sources :

Example 76 with LinearLayoutManager

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();
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 77 with LinearLayoutManager

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);
}
Also used : DepthPageTransformer(org.thoughtcrime.securesms.animation.DepthPageTransformer) MediaRailAdapter(org.thoughtcrime.securesms.mediapreview.MediaRailAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView)

Example 78 with LinearLayoutManager

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);
    });
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 79 with LinearLayoutManager

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;
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) NonNull(androidx.annotation.NonNull)

Example 80 with LinearLayoutManager

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();
    }
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)502 RecyclerView (androidx.recyclerview.widget.RecyclerView)301 View (android.view.View)197 TextView (android.widget.TextView)75 ArrayList (java.util.ArrayList)44 Bundle (android.os.Bundle)43 Nullable (androidx.annotation.Nullable)41 Intent (android.content.Intent)36 ImageView (android.widget.ImageView)34 Toolbar (androidx.appcompat.widget.Toolbar)34 List (java.util.List)33 NonNull (androidx.annotation.NonNull)31 Context (android.content.Context)28 ViewGroup (android.view.ViewGroup)27 AlertDialog (androidx.appcompat.app.AlertDialog)24 Test (org.junit.Test)24 LayoutInflater (android.view.LayoutInflater)23 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)20 MenuItem (android.view.MenuItem)18 DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)17