use of gwtupload.client.PreloadedImage in project blogwt by billy1380.
the class EditResourcePage method onImageUploadFinished.
@SuppressWarnings("deprecation")
private void onImageUploadFinished(IUploader uploader) {
if (uploader.getStatus() == Status.SUCCESS) {
String msg = uploader.getServerMessage().getMessage();
if (msg != null && msg.startsWith("data:")) {
// NOTE: this does not happen
new PreloadedImage(msg, EditResourcePage.this::onImagePreloaderFinished);
} else {
Resource resource = new Resource();
if (uploader.getServerInfo().ctype.startsWith("image")) {
resource.type = ResourceTypeType.ResourceTypeTypeGoogleCloudServiceImage;
}
for (String name : uploader.getServerMessage().getUploadedFileNames()) {
resource.name = name;
break;
}
resource.id = Long.valueOf(uploader.getServerInfo().message);
resource.description = "New uploaded file " + resource.name;
resource.properties = "{\"contentType\":" + uploader.getServerInfo().ctype + "}";
resource.data = "gs://" + uploader.getServerInfo().key;
if (EditResourcePage.this.resource == null) {
EditResourcePage.this.resource = resource;
} else {
// find out if the page status is new then delete the preciously uploaded resource
}
uploader.getStatusWidget().setVisible(false);
show(EditResourcePage.this.resource = resource);
if (resource.type == ResourceTypeType.ResourceTypeTypeGoogleCloudServiceImage) {
for (String url : uploader.getServerMessage().getUploadedFileUrls()) {
new PreloadedImage(url.replace(ApiHelper.BASE_URL, ""), EditResourcePage.this::onImagePreloaderFinished);
break;
}
}
}
actionText = UPDATE_ACTION_TEXT;
elHeading.setInnerText(getHeadingText());
} else {
// Failed :(
}
ready();
}
use of gwtupload.client.PreloadedImage in project blogwt by billy1380.
the class EditPostPage method finishedImageUpload.
private void finishedImageUpload(IUploader uploader) {
if (uploader.getStatus() == Status.SUCCESS) {
String msg = uploader.getServerMessage().getMessage();
if (msg != null && msg.startsWith("data:")) {
// NOTE: this does not happen
new PreloadedImage(msg, PRELOAD_HANDLER);
} else {
Resource resource = new Resource();
resource.type = ResourceTypeType.ResourceTypeTypeBlobStoreImage;
for (String url : uploader.getServerMessage().getUploadedFileUrls()) {
resource.data = url.replace(ApiHelper.BASE_URL, "/");
break;
}
for (String name : uploader.getServerMessage().getUploadedFileNames()) {
resource.name = name;
break;
}
ensureResources().put(resource.name, resource);
uploader.getStatusWidget().setVisible(false);
new PreloadedImage(resource.data, PRELOAD_HANDLER);
}
} else {
// Failed :(
}
}
Aggregations