Search in sources :

Example 6 with RefreshableItemPresentationModel

use of org.robobinding.itempresentationmodel.RefreshableItemPresentationModel in project RoboBinding by RoboBinding.

the class DataSetAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
    View view = viewHolder.itemView;
    ViewTag<RefreshableItemPresentationModel> viewTag = viewTags.tagFor(view);
    RefreshableItemPresentationModel itemPresentationModel = viewTag.get();
    itemPresentationModel.updateData(getItem(position), new ItemContext(view, position));
    if (viewHolder.isNewView()) {
        viewHolder.bindView();
    } else {
        refreshIfRequired(itemPresentationModel);
    }
}
Also used : ItemContext(org.robobinding.itempresentationmodel.ItemContext) RefreshableItemPresentationModel(org.robobinding.itempresentationmodel.RefreshableItemPresentationModel) RecyclerView(android.support.v7.widget.RecyclerView) BindableView(org.robobinding.BindableView) View(android.view.View)

Example 7 with RefreshableItemPresentationModel

use of org.robobinding.itempresentationmodel.RefreshableItemPresentationModel in project RoboBinding by RoboBinding.

the class DataSetAdapterBuilder method build.

public DataSetAdapter build() {
    ItemBinder itemBinder = bindingContext.createItemBinder();
    ItemLayoutBinder itemLayoutBinder = new ItemLayoutBinder(itemBinder, itemPredefinedMappings);
    ItemLayoutBinder dropdownLayoutBinder = new ItemLayoutBinder(itemBinder, dropdownPredefinedMappings);
    ItemLayoutSelector itemLayoutSelector = buildItemLayoutSelector();
    DataSetAdapter dataSetAdapter = new DataSetAdapter(valueModelWithPreInitializingViews(), itemLayoutBinder, dropdownLayoutBinder, itemLayoutSelector, dropdownLayoutId, new ViewTags<RefreshableItemPresentationModel>(ITEM_PRESENTATION_MODEL_KEY), bindingContext.shouldPreInitializeViews());
    registerPropertyChangeListener(dataSetAdapter);
    return dataSetAdapter;
}
Also used : ItemBinder(org.robobinding.ItemBinder) RefreshableItemPresentationModel(org.robobinding.itempresentationmodel.RefreshableItemPresentationModel)

Example 8 with RefreshableItemPresentationModel

use of org.robobinding.itempresentationmodel.RefreshableItemPresentationModel in project RoboBinding by RoboBinding.

the class DataSetAdapterTest method whenGenerateItemView_thenInflateTheCorrectViewWithItemPresentationModelAttached.

@Test
public void whenGenerateItemView_thenInflateTheCorrectViewWithItemPresentationModelAttached() {
    View view = mock(View.class);
    ItemLayoutBinder itemLayoutBinder = aItemLayoutBinder().inflateAndReturnRootView(view);
    ViewTag<RefreshableItemPresentationModel> viewTag = mockViewTag();
    ViewTags<RefreshableItemPresentationModel> viewTags = aViewTags().tagForViewAndReturn(view, viewTag);
    DataSetAdapter dataSetAdapter = aDataSetAdapter().withItemLayoutBinder(itemLayoutBinder).withViewTags(viewTags).build();
    View result = dataSetAdapter.getView(0, null, null);
    assertThat(result, sameInstance(view));
    verify(viewTag).set(notNull(RefreshableItemPresentationModel.class));
}
Also used : RefreshableItemPresentationModel(org.robobinding.itempresentationmodel.RefreshableItemPresentationModel) View(android.view.View) BindableView(org.robobinding.BindableView) Test(org.junit.Test)

Aggregations

RefreshableItemPresentationModel (org.robobinding.itempresentationmodel.RefreshableItemPresentationModel)8 View (android.view.View)5 BindableView (org.robobinding.BindableView)5 ItemContext (org.robobinding.itempresentationmodel.ItemContext)3 RecyclerView (android.support.v7.widget.RecyclerView)2 Test (org.junit.Test)2 ItemBinder (org.robobinding.ItemBinder)2 AbstractPresentationModelObject (org.robobinding.presentationmodel.AbstractPresentationModelObject)1 ItemLayoutBinder (org.robobinding.widget.adapterview.ItemLayoutBinder)1 ItemLayoutSelector (org.robobinding.widget.adapterview.ItemLayoutSelector)1 MultiItemLayoutSelector (org.robobinding.widget.adapterview.MultiItemLayoutSelector)1 SingleItemLayoutSelector (org.robobinding.widget.adapterview.SingleItemLayoutSelector)1