Search in sources :

Example 61 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project epoxy by airbnb.

the class ModelClickListenerTest method mockModelForClicking.

private View mockModelForClicking(EpoxyModel model) {
    View mockedView = mock(View.class);
    RecyclerView recyclerMock = mock(RecyclerView.class);
    EpoxyViewHolder holderMock = mock(EpoxyViewHolder.class);
    when(holderMock.getAdapterPosition()).thenReturn(1);
    doReturn(recyclerMock).when(mockedView).getParent();
    doReturn(holderMock).when(recyclerMock).findContainingViewHolder(mockedView);
    doReturn(model).when(holderMock).getModel();
    when(mockedView.getParent()).thenReturn(recyclerMock);
    when(recyclerMock.findContainingViewHolder(mockedView)).thenReturn(holderMock);
    when(holderMock.getAdapterPosition()).thenReturn(1);
    when(holderMock.getModel()).thenReturn(model);
    View parentView = mock(View.class);
    when(holderMock.objectToBind()).thenReturn(parentView);
    doReturn(parentView).when(holderMock).objectToBind();
    return mockedView;
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 62 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project epoxy by airbnb.

the class ModelClickListenerTest method mockCompoundButtonForClicking.

private CompoundButton mockCompoundButtonForClicking(EpoxyModel model) {
    CompoundButton mockedView = mock(CompoundButton.class);
    RecyclerView recyclerMock = mock(RecyclerView.class);
    EpoxyViewHolder holderMock = mock(EpoxyViewHolder.class);
    when(holderMock.getAdapterPosition()).thenReturn(1);
    doReturn(recyclerMock).when(mockedView).getParent();
    doReturn(holderMock).when(recyclerMock).findContainingViewHolder(mockedView);
    doReturn(model).when(holderMock).getModel();
    when(mockedView.getParent()).thenReturn(recyclerMock);
    when(recyclerMock.findContainingViewHolder(mockedView)).thenReturn(holderMock);
    when(holderMock.getAdapterPosition()).thenReturn(1);
    when(holderMock.getModel()).thenReturn(model);
    View parentView = mock(View.class);
    when(holderMock.objectToBind()).thenReturn(parentView);
    doReturn(parentView).when(holderMock).objectToBind();
    return mockedView;
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CompoundButton(android.widget.CompoundButton)

Example 63 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project epoxy by airbnb.

the class ListenersUtils method getEpoxyHolderForChildView.

@Nullable
static EpoxyViewHolder getEpoxyHolderForChildView(View v) {
    RecyclerView recyclerView = findParentRecyclerView(v);
    if (recyclerView == null) {
        return null;
    }
    ViewHolder viewHolder = recyclerView.findContainingViewHolder(v);
    if (viewHolder == null) {
        return null;
    }
    if (!(viewHolder instanceof EpoxyViewHolder)) {
        return null;
    }
    return (EpoxyViewHolder) viewHolder;
}
Also used : ViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder) RecyclerView(androidx.recyclerview.widget.RecyclerView) Nullable(androidx.annotation.Nullable)

Example 64 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project simple-stack by Zhuinden.

the class WordListFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final Backstack backstack = Navigator.getBackstack(requireContext());
    dataProvider = backstack.lookupService(DataProvider.class.getName());
    actionHandler = backstack.lookupService(ActionHandler.class.getName());
    controllerEvents = backstack.lookupService("WordEventEmitter");
    RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(adapter);
    view.findViewById(R.id.buttonGoToAddNewWord).setOnClickListener(v -> actionHandler.onAddNewWordClicked());
    dataProvider.getWordList().observe(getViewLifecycleOwner(), words -> adapter.updateWords(words));
}
Also used : Backstack(com.zhuinden.simplestack.Backstack) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 65 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiCallingDisclaimerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.wfc_disclaimer_fragment, container, false);
    mAgreeButton = view.findViewById(R.id.agree_button);
    mAgreeButton.setOnClickListener(this);
    mDisagreeButton = view.findViewById(R.id.disagree_button);
    mDisagreeButton.setOnClickListener(this);
    final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.disclaimer_item_list);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(new DisclaimerItemListAdapter(mDisclaimerItemList));
    RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
    recyclerView.addItemDecoration(itemDecoration);
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (!recyclerView.canScrollVertically(1)) {
                mScrollToBottom = true;
                updateButtonState();
                recyclerView.removeOnScrollListener(this);
            }
        }
    });
    return view;
}
Also used : OnScrollListener(androidx.recyclerview.widget.RecyclerView.OnScrollListener) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

RecyclerView (androidx.recyclerview.widget.RecyclerView)272 View (android.view.View)174 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)115 TextView (android.widget.TextView)32 Test (org.junit.Test)24 Nullable (androidx.annotation.Nullable)22 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)22 ImageView (android.widget.ImageView)18 Toolbar (androidx.appcompat.widget.Toolbar)18 NonNull (androidx.annotation.NonNull)16 Bundle (android.os.Bundle)15 ViewGroup (android.view.ViewGroup)15 ArrayList (java.util.ArrayList)15 Intent (android.content.Intent)14 Rect (android.graphics.Rect)13 LayoutInflater (android.view.LayoutInflater)11 SuppressLint (android.annotation.SuppressLint)10 Context (android.content.Context)10 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)10 List (java.util.List)9