Search in sources :

Example 1 with PendingAttributesForView

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

the class BindingViewInflater method onViewCreated.

@Override
public void onViewCreated(View childView, AttributeSet attrs) {
    Map<String, String> pendingAttributeMappings = bindingAttributeParser.parse(attrs);
    if (!pendingAttributeMappings.isEmpty()) {
        PendingAttributesForView pendingAttributesForView = new PendingAttributesForViewImpl(childView, pendingAttributeMappings);
        resolveAndAddViewBindingAttributes(pendingAttributesForView);
    }
}
Also used : PendingAttributesForViewImpl(org.robobinding.PendingAttributesForViewImpl) PendingAttributesForView(org.robobinding.PendingAttributesForView) PredefinedPendingAttributesForView(org.robobinding.PredefinedPendingAttributesForView)

Example 2 with PendingAttributesForView

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

the class BindingViewInflater method addPredefinedPendingAttributesForViewGroup.

private void addPredefinedPendingAttributesForViewGroup(Collection<PredefinedPendingAttributesForView> predefinedPendingAttributesForViewGroup, View rootView) {
    for (PredefinedPendingAttributesForView predefinedPendingAttributesForView : predefinedPendingAttributesForViewGroup) {
        PendingAttributesForView pendingAttributesForView = predefinedPendingAttributesForView.createPendingAttributesForView(rootView);
        resolveAndAddViewBindingAttributes(pendingAttributesForView);
    }
}
Also used : PendingAttributesForView(org.robobinding.PendingAttributesForView) PredefinedPendingAttributesForView(org.robobinding.PredefinedPendingAttributesForView) PredefinedPendingAttributesForView(org.robobinding.PredefinedPendingAttributesForView)

Example 3 with PendingAttributesForView

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

the class BindingAttributeResolverTest method givenTwoCandidateResolvers_whenResolve_thenBothResolversShouldInvolveResolving.

@Test
public void givenTwoCandidateResolvers_whenResolve_thenBothResolversShouldInvolveResolving() {
    ByBindingAttributeMappingsResolver candidateResolver1 = mock(ByBindingAttributeMappingsResolver.class);
    ByBindingAttributeMappingsResolver candidateResolver2 = mock(ByBindingAttributeMappingsResolver.class);
    when(byBindingAttributeMappingsResolverFinder.findCandidates(any(View.class))).thenReturn(newArrayList(candidateResolver1, candidateResolver2));
    BindingAttributeResolver bindingAttributeResolver = new BindingAttributeResolver(byBindingAttributeMappingsResolverFinder);
    PendingAttributesForView pendingAttributesForView = mock(PendingAttributesForView.class);
    when(pendingAttributesForView.isEmpty()).thenReturn(false);
    bindingAttributeResolver.resolve(pendingAttributesForView);
    verify(candidateResolver1).resolve(pendingAttributesForView);
    verify(candidateResolver2).resolve(pendingAttributesForView);
}
Also used : PendingAttributesForView(org.robobinding.PendingAttributesForView) PendingAttributesForView(org.robobinding.PendingAttributesForView) View(android.view.View) Test(org.junit.Test)

Example 4 with PendingAttributesForView

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

the class BindingViewInflaterTest method createAPredefinedPendingAttributesForView.

private Collection<PredefinedPendingAttributesForView> createAPredefinedPendingAttributesForView() {
    PredefinedPendingAttributesForView predefinedPendingAttributesForView = mock(PredefinedPendingAttributesForView.class);
    PendingAttributesForView pendingAttributesForView = mock(PendingAttributesForView.class);
    when(predefinedPendingAttributesForView.createPendingAttributesForView(any(View.class))).thenReturn(pendingAttributesForView);
    return Lists.newArrayList(predefinedPendingAttributesForView);
}
Also used : PendingAttributesForView(org.robobinding.PendingAttributesForView) PredefinedPendingAttributesForView(org.robobinding.PredefinedPendingAttributesForView) PredefinedPendingAttributesForView(org.robobinding.PredefinedPendingAttributesForView) PendingAttributesForView(org.robobinding.PendingAttributesForView) View(android.view.View) PredefinedPendingAttributesForView(org.robobinding.PredefinedPendingAttributesForView)

Example 5 with PendingAttributesForView

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

the class ResolutionTest method givenASingleView_whenResolvingMissingGroupBindingAttributes_thenThrowExceptionReferencingView.

@Test
public void givenASingleView_whenResolvingMissingGroupBindingAttributes_thenThrowExceptionReferencingView() {
    PendingAttributesForView pendingAttributesForAdapterView = aPendingAttributesForAdapterView().withAttribute("source", "{names}").build();
    try {
        resolveBindingAttributes(pendingAttributesForAdapterView);
        fail("Expected exception to be thrown");
    } catch (ViewResolutionErrorsException e) {
        assertThat(e.getView(), equalTo(pendingAttributesForAdapterView.getView()));
        assertThat(e.getMissingRequiredAttributeErrors().size(), is(1));
    }
}
Also used : PendingAttributesForViewBuilder.aPendingAttributesForView(org.robobinding.binder.PendingAttributesForViewBuilder.aPendingAttributesForView) PendingAttributesForView(org.robobinding.PendingAttributesForView) ViewResolutionErrorsException(org.robobinding.ViewResolutionErrorsException) Test(org.junit.Test)

Aggregations

PendingAttributesForView (org.robobinding.PendingAttributesForView)6 View (android.view.View)3 Test (org.junit.Test)3 PredefinedPendingAttributesForView (org.robobinding.PredefinedPendingAttributesForView)3 PendingAttributesForViewImpl (org.robobinding.PendingAttributesForViewImpl)1 ViewResolutionErrorsException (org.robobinding.ViewResolutionErrorsException)1 PendingAttributesForViewBuilder.aPendingAttributesForView (org.robobinding.binder.PendingAttributesForViewBuilder.aPendingAttributesForView)1