Search in sources :

Example 1 with BindingContext

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

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

the class OneWayBindingPropertyTest method aBoundProperty.

private OneWayBindingProperty aBoundProperty() {
    ValueModelAttribute attribute = aValueModelAttribute(PROPERTY_NAME);
    OneWayBindingProperty bindingProperty = new OneWayBindingProperty(view, viewAttributeSpy, attribute);
    BindingContext bindingContext = aBindingContextWithReadOnlyProperty(PROPERTY_NAME, valueModel);
    bindingProperty.performBind(bindingContext);
    return bindingProperty;
}
Also used : ValueModelAttribute(org.robobinding.attribute.ValueModelAttribute) Attributes.aValueModelAttribute(org.robobinding.attribute.Attributes.aValueModelAttribute) BindingContext(org.robobinding.BindingContext)

Example 3 with BindingContext

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

the class TwoWayBindingPropertyTest method aBoundProperty.

private TwoWayBindingProperty aBoundProperty(ValueModel<Integer> valueModel) {
    ValueModelAttribute attribute = aValueModelAttribute(PROPERTY_NAME);
    TwoWayBindingProperty bindingProperty = new TwoWayBindingProperty(view, viewAddOn, viewAttributeSpy, attribute);
    BindingContext bindingContext = aBindingContextWithProperty(PROPERTY_NAME, valueModel);
    bindingProperty.performBind(bindingContext);
    return bindingProperty;
}
Also used : ValueModelAttribute(org.robobinding.attribute.ValueModelAttribute) Attributes.aValueModelAttribute(org.robobinding.attribute.Attributes.aValueModelAttribute) BindingContext(org.robobinding.BindingContext)

Example 4 with BindingContext

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

the class MenuBinderImpl method inflateAndBind.

public void inflateAndBind(int menuRes, Object presentationModel) {
    checkMenuRes(menuRes);
    checkPresentationModel(presentationModel);
    BindingContext bindingContext = bindingContextFactory.create(presentationModel);
    InflatedView inflatedView = bindingMenuInflater.inflate(menuRes);
    viewBindingLifecycle.run(inflatedView, bindingContext);
}
Also used : BindingContext(org.robobinding.BindingContext)

Example 5 with BindingContext

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

the class ViewBinderImpl method inflateAndBind.

private View inflateAndBind(int layoutId, Object presentationModel, ViewGroup root, boolean attachToRoot) {
    checkLayoutId(layoutId);
    checkPresentationModel(presentationModel);
    checkRoot(root);
    BindingContext bindingContext = bindingContextFactory.create(presentationModel);
    InflatedViewWithRoot inflatedView = bindingViewInflater.inflateView(layoutId, root, attachToRoot);
    viewBindingLifecycle.run(inflatedView, bindingContext);
    return inflatedView.getRootView();
}
Also used : BindingContext(org.robobinding.BindingContext)

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