Search in sources :

Example 1 with BindableView

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));
}
Also used : ViewGroup(android.view.ViewGroup) BindableView(org.robobinding.BindableView) BindingContext(org.robobinding.BindingContext) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) PendingAttributesForViewBuilder.aPendingAttributesForView(org.robobinding.binder.PendingAttributesForViewBuilder.aPendingAttributesForView) BindableView(org.robobinding.BindableView) PendingAttributesForView(org.robobinding.PendingAttributesForView) BindingContextFactory(org.robobinding.BindingContextFactory) ItemBinder(org.robobinding.ItemBinder) PresentationModelAdapterFactory(org.robobinding.presentationmodel.PresentationModelAdapterFactory) BinderProvider(org.robobinding.BinderProvider) InvocationOnMock(org.mockito.invocation.InvocationOnMock) JavaReflectionPresentationModelObject(org.robobinding.test.JavaReflectionPresentationModelObject)

Example 2 with BindableView

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;
}
Also used : ItemContext(org.robobinding.itempresentationmodel.ItemContext) RefreshableItemPresentationModel(org.robobinding.itempresentationmodel.RefreshableItemPresentationModel) BindableView(org.robobinding.BindableView) AbstractPresentationModelObject(org.robobinding.presentationmodel.AbstractPresentationModelObject) BindableView(org.robobinding.BindableView) View(android.view.View)

Example 3 with BindableView

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);
}
Also used : RefreshableItemPresentationModel(org.robobinding.itempresentationmodel.RefreshableItemPresentationModel) BindableView(org.robobinding.BindableView) RecyclerView(android.support.v7.widget.RecyclerView) BindableView(org.robobinding.BindableView) View(android.view.View)

Aggregations

View (android.view.View)3 BindableView (org.robobinding.BindableView)3 RefreshableItemPresentationModel (org.robobinding.itempresentationmodel.RefreshableItemPresentationModel)2 RecyclerView (android.support.v7.widget.RecyclerView)1 ViewGroup (android.view.ViewGroup)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 BinderProvider (org.robobinding.BinderProvider)1 BindingContext (org.robobinding.BindingContext)1 BindingContextFactory (org.robobinding.BindingContextFactory)1 ItemBinder (org.robobinding.ItemBinder)1 PendingAttributesForView (org.robobinding.PendingAttributesForView)1 PendingAttributesForViewBuilder.aPendingAttributesForView (org.robobinding.binder.PendingAttributesForViewBuilder.aPendingAttributesForView)1 ItemContext (org.robobinding.itempresentationmodel.ItemContext)1 AbstractPresentationModelObject (org.robobinding.presentationmodel.AbstractPresentationModelObject)1 PresentationModelAdapterFactory (org.robobinding.presentationmodel.PresentationModelAdapterFactory)1 JavaReflectionPresentationModelObject (org.robobinding.test.JavaReflectionPresentationModelObject)1