use of org.robobinding.presentationmodel.AbstractPresentationModelObject in project RoboBinding by RoboBinding.
the class PresentationModelObjectLoader method load.
public AbstractPresentationModelObject load(Object presentationModel) {
if (presentationModel instanceof HasPresentationModelChangeSupport) {
Preconditions.checkNotNull(((HasPresentationModelChangeSupport) presentationModel).getPresentationModelChangeSupport(), "The PresentationModelChangeSupport from presentationModel.getPresentationModelChangeSupport() must not be null");
}
String presentationModelObjectClassName = getObjectClassName(presentationModel.getClass().getName());
Class<?> presentationModelObjectType;
try {
presentationModelObjectType = Class.forName(presentationModelObjectClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException(MessageFormat.format("The source code for ''{0}'' is not generated. Is Java annotation processing(source code generation) correctly configured?", presentationModelObjectClassName));
}
try {
return (AbstractPresentationModelObject) ConstructorUtils.invokeConstructor(presentationModelObjectType, presentationModel);
} catch (NoSuchMethodException e) {
throw new Bug("This is a bug of constructor code generation", e);
} catch (IllegalAccessException e) {
throw new Bug("This is a bug of constructor code generation", e);
} catch (InvocationTargetException e) {
throw new Bug("This is a bug of constructor code generation", e);
} catch (InstantiationException e) {
throw new Bug("This is a bug of constructor code generation", e);
}
}
use of org.robobinding.presentationmodel.AbstractPresentationModelObject 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;
}
Aggregations