use of org.robobinding.BindableView in project RoboBinding by RoboBinding.
the class BindingTest method newBindingContext.
@SuppressWarnings("unchecked")
private BindingContext newBindingContext() {
BinderProvider binderProvider = mock(BinderProvider.class);
BindableView bindableView = mock(BindableView.class);
when(bindableView.getRootView()).then(new Answer<View>() {
@Override
public View answer(InvocationOnMock invocation) throws Throwable {
return new View(context);
}
});
ItemBinder itemBinder = mock(ItemBinder.class);
when(itemBinder.inflateWithoutAttachingToRoot(anyInt(), anyCollection(), any(ViewGroup.class))).thenReturn(bindableView);
when(binderProvider.createItemBinder(any(BindingContextFactory.class))).thenReturn(itemBinder);
return new BindingContext(binderProvider, context, new PresentationModelAdapterFactory().create(new JavaReflectionPresentationModelObject(new PresentationModelForTest())), PreInitializingViews.initial(true));
}
use of org.robobinding.BindableView in project RoboBinding by RoboBinding.
the class DataSetAdapter method newView.
private View newView(int position, ViewGroup parent, DisplayType displayType) {
BindableView bindableView;
Object item = getItem(position);
if (displayType == DisplayType.ITEM_LAYOUT) {
int layoutId = itemLayoutSelector.selectLayout(getItemViewType(position));
bindableView = itemLayoutBinder.inflate(parent, layoutId);
} else {
bindableView = dropdownLayoutBinder.inflate(parent, dropdownLayoutId);
}
View view = bindableView.getRootView();
RefreshableItemPresentationModel itemPresentationModel = dataSetValueModel.newRefreshableItemPresentationModel(getItemViewType(position));
itemPresentationModel.updateData(item, new ItemContext(view, position));
bindableView.bindTo((AbstractPresentationModelObject) itemPresentationModel);
ViewTag<RefreshableItemPresentationModel> viewTag = viewTags.tagFor(view);
viewTag.set(itemPresentationModel);
return view;
}
use of org.robobinding.BindableView in project RoboBinding by RoboBinding.
the class DataSetAdapter method onCreateViewHolder.
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
BindableView bindableView;
int layoutId = layoutSelector.selectLayout(viewType);
bindableView = itemLayoutBinder.inflate(parent, layoutId);
View view = bindableView.getRootView();
RefreshableItemPresentationModel itemPresentationModel = dataSetValueModel.newRefreshableItemPresentationModel(viewType);
ViewTag<RefreshableItemPresentationModel> viewTag = viewTags.tagFor(view);
viewTag.set(itemPresentationModel);
return new ViewHolder(view, bindableView, (AbstractPresentationModelObject) itemPresentationModel);
}
Aggregations