Search in sources :

Example 1 with SubBindingContext

use of org.robobinding.SubBindingContext in project RoboBinding by RoboBinding.

the class SubViewPresentationModelAttribute method bindTo.

@Override
public void bindTo(BindingContext bindingContext) {
    SubBindingContext subBindingContext = bindingContext.navigateToSubContext(attribute.getPropertyName());
    View subView = subBindingContext.inflateAndBindWithoutAttachingToRoot(layoutId, parent);
    subViewHolder.setSubView(subView);
}
Also used : SubBindingContext(org.robobinding.SubBindingContext) View(android.view.View)

Example 2 with SubBindingContext

use of org.robobinding.SubBindingContext in project RoboBinding by RoboBinding.

the class SubViewPresentationModelAttributeTest method whenBind_thenBoundSubViewIsSetOnHolder.

@Test
public void whenBind_thenBoundSubViewIsSetOnHolder() {
    int layoutId = 1;
    String presentationModelPropertyName = "propertyName";
    ViewGroup parent = mock(ViewGroup.class);
    View boundSubView = mock(View.class);
    BindingContext context = mock(BindingContext.class);
    SubViewHolder subViewHolder = mock(SubViewHolder.class);
    SubBindingContext subBindingContext = mock(SubBindingContext.class);
    when(context.navigateToSubContext(presentationModelPropertyName)).thenReturn(subBindingContext);
    when(subBindingContext.inflateAndBindWithoutAttachingToRoot(layoutId, parent)).thenReturn(boundSubView);
    SubViewPresentationModelAttribute subViewAttribute = new SubViewPresentationModelAttribute(parent, layoutId, subViewHolder);
    subViewAttribute.setAttribute(aValueModelAttribute(presentationModelPropertyName));
    subViewAttribute.bindTo(context);
    verify(subViewHolder).setSubView(boundSubView);
}
Also used : ViewGroup(android.view.ViewGroup) SubBindingContext(org.robobinding.SubBindingContext) SubBindingContext(org.robobinding.SubBindingContext) BindingContext(org.robobinding.BindingContext) View(android.view.View) Test(org.junit.Test)

Aggregations

View (android.view.View)2 SubBindingContext (org.robobinding.SubBindingContext)2 ViewGroup (android.view.ViewGroup)1 Test (org.junit.Test)1 BindingContext (org.robobinding.BindingContext)1