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;
}
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;
}
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;
}
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));
}
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;
}
Aggregations