use of com.codename1.rad.nodes.ActionNode in project CodeRAD by shannah.
the class EntityListView method refresh.
public void refresh() {
ActionNode refreshAction = getViewNode().getAction(ActionCategories.LIST_REFRESH_ACTION);
ActionNode loadMoreAction = getViewNode().getAction(ActionCategories.LIST_LOAD_MORE_ACTION);
Entity requestData = null;
if (refreshAction != null) {
Map extraData = new HashMap();
EventContext.addExtra(extraData, EntityListProvider.RequestType.REFRESH);
ControllerEvent evt = ActionSupport.as(refreshAction.fireEvent(getEntity(), this, extraData), ControllerEvent.class);
if (evt != null && evt.isConsumed()) {
EntityListProvider.Request request = evt.getAsyncResource(EntityListProvider.Request.class);
if (request != null) {
// The provider is fulfilling the request asynchronously.
request.onResult((res, err) -> {
if (err != null) {
return;
}
nextProviderRequest = request.getNextRequest();
EntityList modelList = getEntity();
modelList.startTransaction();
modelList.clear();
for (Object o : res) {
modelList.add((Entity) o);
}
boolean localAnimateInsertions = animateInsertions;
animateInsertions = false;
boolean localAnimateRemovals = animateRemovals;
animateRemovals = false;
modelList.commitTransaction();
animateInsertions = localAnimateInsertions;
animateRemovals = localAnimateRemovals;
if (loadMoreAction != null) {
InfiniteScrollAdapter.addMoreComponents(wrapper, new Component[0], request.hasMore());
}
Form f = getComponentForm();
if (f != null) {
getComponentForm().revalidateWithAnimationSafety();
}
});
}
}
}
}
Aggregations