use of com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse in project blogwt by billy1380.
the class ResourceController method fetchResources.
private void fetchResources() {
final GetResourcesRequest input = ApiHelper.setAccessCode(new GetResourcesRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
if (getResourcesRequest != null) {
getResourcesRequest.cancel();
}
getResourcesRequest = ApiHelper.createBlogClient().getResources(input, new AsyncCallback<GetResourcesResponse>() {
@Override
public void onSuccess(GetResourcesResponse output) {
getResourcesRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.resources != null && output.resources.size() > 0) {
pager = output.pager;
updateRowCount(input.pager.count == null ? 0 : input.pager.count.intValue(), input.pager.count == null || input.pager.count.intValue() == 0);
updateRowData(input.pager.start.intValue(), output.resources);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<Resource>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetResourcesSuccess(input, output), ResourceController.this);
}
@Override
public void onFailure(Throwable caught) {
getResourcesRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetResourcesFailure(input, caught), ResourceController.this);
}
});
}
use of com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse in project blogwt by billy1380.
the class BlogService method getResources.
public Request getResources(GetResourcesRequest input, AsyncSuccess<GetResourcesRequest, GetResourcesResponse> onSuccess, AsyncFailure<GetResourcesRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(BlogMethodGetResources, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
GetResourcesResponse outputParameter = new GetResourcesResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(BlogService.this, BlogMethodGetResources, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodGetResources, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodGetResources, input, exception);
}
});
onCallStart(BlogService.this, BlogMethodGetResources, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodGetResources, input, exception);
}
return handle;
}
Aggregations