Search in sources :

Example 6 with BindingContext

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

the class SubViewWithoutPresentationModelAttributeTest method whenBindTo_thenStaticSubViewIsSetOnHolder.

@Test
public void whenBindTo_thenStaticSubViewIsSetOnHolder() {
    BindingContext bindingContext = mock(BindingContext.class);
    when(bindingContext.inflateWithoutAttachingToRoot(anyInt(), any(ViewGroup.class))).thenReturn(staticSubView);
    SubViewWithoutPresentationModelAttribute attribute = new SubViewWithoutPresentationModelAttribute(null, 0, subViewHolder);
    attribute.bindTo(bindingContext);
    verify(subViewHolder).setSubView(staticSubView);
}
Also used : ViewGroup(android.view.ViewGroup) BindingContext(org.robobinding.BindingContext) Test(org.junit.Test)

Example 7 with BindingContext

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

the class ViewBinderImpl method inflateAndBind.

@Override
public View inflateAndBind(int layoutId, Object presentationModel) {
    checkLayoutId(layoutId);
    checkPresentationModel(presentationModel);
    BindingContext bindingContext = bindingContextFactory.create(presentationModel);
    InflatedViewWithRoot inflatedView = bindingViewInflater.inflateView(layoutId);
    viewBindingLifecycle.run(inflatedView, bindingContext);
    return inflatedView.getRootView();
}
Also used : BindingContext(org.robobinding.BindingContext)

Example 8 with BindingContext

use of org.robobinding.BindingContext 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

BindingContext (org.robobinding.BindingContext)8 ViewGroup (android.view.ViewGroup)3 View (android.view.View)2 Test (org.junit.Test)2 Attributes.aValueModelAttribute (org.robobinding.attribute.Attributes.aValueModelAttribute)2 ValueModelAttribute (org.robobinding.attribute.ValueModelAttribute)2 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 BindableView (org.robobinding.BindableView)1 BinderProvider (org.robobinding.BinderProvider)1 BindingContextFactory (org.robobinding.BindingContextFactory)1 ItemBinder (org.robobinding.ItemBinder)1 PendingAttributesForView (org.robobinding.PendingAttributesForView)1 SubBindingContext (org.robobinding.SubBindingContext)1 PendingAttributesForViewBuilder.aPendingAttributesForView (org.robobinding.binder.PendingAttributesForViewBuilder.aPendingAttributesForView)1 PresentationModelAdapterFactory (org.robobinding.presentationmodel.PresentationModelAdapterFactory)1 JavaReflectionPresentationModelObject (org.robobinding.test.JavaReflectionPresentationModelObject)1