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);
}
}
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;
}
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));
}
Aggregations