Commit c24e2a67 authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey Schiller

Fix broken gallery resources due to route refactor

Change-Id: Ib34de5abd350b1408e05f5431b55e34e51b282d9
parent d3449728
......@@ -407,9 +407,6 @@ public class GalleryClient {
}
public static final String DEFAULTGALLERYIMAGE="images/genericApp.png";
public static final String DEFAULTUSERIMAGE="images/android_icon_.png";
/**
* URL is in GCS, of form: /gs/<bucket>/gallery/apps/6046115656892416/aia
* @return gallery bucket
......
......@@ -9,6 +9,7 @@ package com.google.appinventor.client;
import java.util.Date;
import java.util.List;
import com.google.appinventor.client.explorer.youngandroid.GalleryImages;
import com.google.appinventor.client.explorer.youngandroid.GalleryPage;
import com.google.appinventor.shared.rpc.project.GalleryApp;
import com.google.appinventor.shared.rpc.project.GalleryComment;
......@@ -28,12 +29,12 @@ public class GalleryGuiFactory {
public static final OdeMessages MESSAGES = Ode.getMessages();
private final String PERSON_URL = "/images/person.png";
private final String HOLLOW_HEART_ICON_URL = "/images/numLikeHollow.png";
private final String RED_HEART_ICON_URL = "/images/numLike.png";
private final String DOWNLOAD_ICON_URL = "/images/numDownload.png";
private final String NUM_VIEW_ICON_URL = "/images/numView.png";
private final String NUM_COMMENT_ICON_URL = "/images/numComment.png";
private static final String PERSON_URL = "/static/images/person.png";
private static final String RED_HEART_ICON_URL = "/static/images/numLike.png";
private static final String HOLLOW_HEART_ICON_URL = "/static/images/numLikeHollow.png";
private static final String DOWNLOAD_ICON_URL = "/static/images/numDownload.png";
private static final String NUM_VIEW_ICON_URL = "/static/images/numView.png";
private static final String NUM_COMMENT_ICON_URL = "/static/images/numComment.png";
/**
* Generates a new GalleryGuiFactory instance.
......@@ -63,20 +64,22 @@ public class GalleryGuiFactory {
image = new Image();
image.addErrorHandler(new ErrorHandler() {
public void onError(ErrorEvent event) {
image.setUrl(GalleryApp.DEFAULTGALLERYIMAGE);
image.setResource(GalleryImages.get().genericApp());
}
});
String url = gallery.getCloudImageURL(app.getGalleryAppId());
image.setUrl(url);
if(gallery.getSystemEnvironment() != null &&
gallery.getSystemEnvironment().toString().equals("Development")){
gallery.getSystemEnvironment().equals("Development")){
final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
// failure message
MESSAGES.galleryError()) {
@Override
public void onSuccess(String newUrl) {
image.setUrl(newUrl + "?" + System.currentTimeMillis());
if (newUrl != null) {
image.setUrl(newUrl + "?" + System.currentTimeMillis());
}
}
};
Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
......@@ -138,14 +141,14 @@ public class GalleryGuiFactory {
// Set helper icons
Image numViews = new Image();
numViews.setUrl("/images/numView.png");
numViews.setUrl(NUM_VIEW_ICON_URL);
Image numDownloads = new Image();
numDownloads.setUrl("/images/numDownload.png");
numDownloads.setUrl(DOWNLOAD_ICON_URL);
Image numLikes = new Image();
numLikes.setUrl("/images/numLikeHollow.png");
numLikes.setUrl(HOLLOW_HEART_ICON_URL);
// For generic cards, do not show comment
// Image numComments = new Image();
// numComments.setUrl("/image/numComment.png");
// numComments.setUrl(NUM_COMMENT_ICON_URL);
// appCardMeta.add(numViews);
// appCardMeta.add(gaw.numViewsLabel);
......
package com.google.appinventor.client.explorer.youngandroid;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public class GalleryImages {
public interface Images extends ClientBundle {
@Source("genericApp.png")
ImageResource genericApp();
@Source("androidIcon.png")
ImageResource androidIcon();
}
private static final Images INSTANCE = GWT.create(Images.class);
public static Images get() {
return INSTANCE;
}
}
......@@ -73,11 +73,12 @@ public class GalleryPage extends Composite implements GalleryRequestListener {
String projectName = null;
Project project;
private final String HOLLOW_HEART_ICON_URL = "/images/numLikeHollow.png";
private final String RED_HEART_ICON_URL = "/images/numLike.png";
private final String DOWNLOAD_ICON_URL = "/images/numDownload.png";
private final String NUM_VIEW_ICON_URL = "/images/numView.png";
private final String NUM_COMMENT_ICON_URL = "/images/numComment.png";
private static final String PERSON_URL = "/static/images/person.png";
private static final String RED_HEART_ICON_URL = "/static/images/numLike.png";
private static final String HOLLOW_HEART_ICON_URL = "/static/images/numLikeHollow.png";
private static final String DOWNLOAD_ICON_URL = "/static/images/numDownload.png";
private static final String NUM_VIEW_ICON_URL = "/static/images/numView.png";
private static final String NUM_COMMENT_ICON_URL = "/static/images/numComment.png";
private boolean imageUploaded = false;
private VerticalPanel panel; // the main panel
......@@ -465,7 +466,7 @@ panel
// the error will occur and we'll load default image
image.addErrorHandler(new ErrorHandler() {
public void onError(ErrorEvent event) {
image.setUrl(GalleryApp.DEFAULTGALLERYIMAGE);
image.setResource(GalleryImages.get().genericApp());
}
});
container.add(image);
......@@ -477,7 +478,9 @@ panel
MESSAGES.galleryError()) {
@Override
public void onSuccess(String newUrl) {
image.setUrl(newUrl + "?" + System.currentTimeMillis());
if (newUrl != null) {
image.setUrl(newUrl + "?" + System.currentTimeMillis());
}
}
};
Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
......@@ -546,7 +549,7 @@ panel
// the error will occur and we'll load default image
authorAvatar.addErrorHandler(new ErrorHandler() {
public void onError(ErrorEvent event) {
authorAvatar.setUrl(GalleryApp.DEFAULTUSERIMAGE);
authorAvatar.setResource(GalleryImages.get().androidIcon());
}
});
authorAvatar.addClickHandler(new ClickHandler() {
......
......@@ -506,7 +506,7 @@ public class ProfilePage extends Composite/* implements GalleryRequestListener*/
// the error will occur and we'll load default image
userAvatar.addErrorHandler(new ErrorHandler() {
public void onError(ErrorEvent event) {
userAvatar.setUrl(GalleryApp.DEFAULTUSERIMAGE);
userAvatar.setResource(GalleryImages.get().androidIcon());
}
});
container.add(userAvatar);
......@@ -518,7 +518,9 @@ public class ProfilePage extends Composite/* implements GalleryRequestListener*/
MESSAGES.galleryError()) {
@Override
public void onSuccess(String newUrl) {
userAvatar.setUrl(newUrl + "?" + System.currentTimeMillis());
if (userAvatar != null) {
userAvatar.setUrl(newUrl + "?" + System.currentTimeMillis());
}
}
};
Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
......
......@@ -39,9 +39,6 @@ public class GalleryApp implements IsSerializable {
this.credit = "no credit";
}
public static final String DEFAULTGALLERYIMAGE="images/genericApp.png";
public static final String DEFAULTUSERIMAGE="images/android_icon_.png";
public GalleryApp(String title, String developerId, String description,
long creationDate, long updateDate, String imageURL, String projectName,
int downloads, int views, int likes, int unreadLikes,
......@@ -488,4 +485,4 @@ public class GalleryApp implements IsSerializable {
public String toString() {
return title + " ||| " + description + " ||| " + imageURL;
}
}
\ No newline at end of file
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment