use of org.robobinding.itempresentationmodel.RefreshableItemPresentationModel in project RoboBinding by RoboBinding.
the class DataSetAdapter method updateItemPresentationModel.
private void updateItemPresentationModel(View view, int position) {
ViewTag<RefreshableItemPresentationModel> viewTag = viewTags.tagFor(view);
RefreshableItemPresentationModel itemPresentationModel = viewTag.get();
itemPresentationModel.updateData(getItem(position), new ItemContext(view, position));
refreshIfRequired(itemPresentationModel);
}
use of org.robobinding.itempresentationmodel.RefreshableItemPresentationModel in project RoboBinding by RoboBinding.
the class DataSetAdapter method newView.
private View newView(int position, ViewGroup parent, DisplayType displayType) {
BindableView bindableView;
Object item = getItem(position);
if (displayType == DisplayType.ITEM_LAYOUT) {
int layoutId = itemLayoutSelector.selectLayout(getItemViewType(position));
bindableView = itemLayoutBinder.inflate(parent, layoutId);
} else {
bindableView = dropdownLayoutBinder.inflate(parent, dropdownLayoutId);
}
View view = bindableView.getRootView();
RefreshableItemPresentationModel itemPresentationModel = dataSetValueModel.newRefreshableItemPresentationModel(getItemViewType(position));
itemPresentationModel.updateData(item, new ItemContext(view, position));
bindableView.bindTo((AbstractPresentationModelObject) itemPresentationModel);
ViewTag<RefreshableItemPresentationModel> viewTag = viewTags.tagFor(view);
viewTag.set(itemPresentationModel);
return view;
}
use of org.robobinding.itempresentationmodel.RefreshableItemPresentationModel in project RoboBinding by RoboBinding.
the class DataSetAdapterTest method whenGenerateDropdownView_thenInflateTheCorrectViewWithItemPresentationModelAttached.
@Test
public void whenGenerateDropdownView_thenInflateTheCorrectViewWithItemPresentationModelAttached() {
View view = mock(View.class);
ItemLayoutBinder dropdownLayoutBinder = aItemLayoutBinder().inflateAndReturnRootView(view);
ViewTag<RefreshableItemPresentationModel> viewTag = mockViewTag();
ViewTags<RefreshableItemPresentationModel> viewTags = aViewTags().tagForViewAndReturn(view, viewTag);
DataSetAdapter dataSetAdapter = aDataSetAdapter().withDropdownLayoutBinder(dropdownLayoutBinder).withViewTags(viewTags).build();
View result = dataSetAdapter.getDropDownView(0, null, null);
assertThat(result, sameInstance(view));
verify(viewTag).set(notNull(RefreshableItemPresentationModel.class));
}
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);
ItemLayoutSelector itemLayoutSelector = buildItemLayoutSelector();
DataSetAdapter dataSetAdapter = new DataSetAdapter(valueModelWithPreInitializeViews(), itemLayoutBinder, itemLayoutSelector, 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 DataSetAdapter method onCreateViewHolder.
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
BindableView bindableView;
int layoutId = layoutSelector.selectLayout(viewType);
bindableView = itemLayoutBinder.inflate(parent, layoutId);
View view = bindableView.getRootView();
RefreshableItemPresentationModel itemPresentationModel = dataSetValueModel.newRefreshableItemPresentationModel(viewType);
ViewTag<RefreshableItemPresentationModel> viewTag = viewTags.tagFor(view);
viewTag.set(itemPresentationModel);
return new ViewHolder(view, bindableView, (AbstractPresentationModelObject) itemPresentationModel);
}
Aggregations