Search in sources :

Example 1 with ItemContext

use of org.robobinding.itempresentationmodel.ItemContext 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);
}
Also used : ItemContext(org.robobinding.itempresentationmodel.ItemContext) RefreshableItemPresentationModel(org.robobinding.itempresentationmodel.RefreshableItemPresentationModel)

Example 2 with ItemContext

use of org.robobinding.itempresentationmodel.ItemContext 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;
}
Also used : ItemContext(org.robobinding.itempresentationmodel.ItemContext) RefreshableItemPresentationModel(org.robobinding.itempresentationmodel.RefreshableItemPresentationModel) BindableView(org.robobinding.BindableView) AbstractPresentationModelObject(org.robobinding.presentationmodel.AbstractPresentationModelObject) BindableView(org.robobinding.BindableView) View(android.view.View)

Example 3 with ItemContext

use of org.robobinding.itempresentationmodel.ItemContext 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)

Aggregations

ItemContext (org.robobinding.itempresentationmodel.ItemContext)3 RefreshableItemPresentationModel (org.robobinding.itempresentationmodel.RefreshableItemPresentationModel)3 View (android.view.View)2 BindableView (org.robobinding.BindableView)2 RecyclerView (android.support.v7.widget.RecyclerView)1 AbstractPresentationModelObject (org.robobinding.presentationmodel.AbstractPresentationModelObject)1