Commit b777cefe authored by Evan W. Patton's avatar Evan W. Patton

Hide gallery loading message after all tabs load

Commit e38f54e9 deferred gallery loading until the user opened the
gallery. This commit provides more complex logic for managing the
"Loading..." messages shown during loading of the gallery by counting
the number of tabs that have loaded content. In the earlier commit, if
the primary tab wasn't loaded the message would go away if one of the
non-visible tabs finished loading. Now the loading message will only
go away if all tabs have loaded their content.

Change-Id: I019891c4b3160f91658f43ad1d42f47e00cffd32
parent e066dc0e
......@@ -37,9 +37,11 @@ import com.google.appinventor.client.explorer.project.Project;
import com.google.appinventor.client.explorer.project.ProjectChangeAdapter;
import com.google.appinventor.client.explorer.project.ProjectManager;
import com.google.appinventor.client.explorer.project.ProjectManagerEventAdapter;
import com.google.appinventor.client.explorer.youngandroid.GalleryList;
import com.google.appinventor.client.explorer.youngandroid.GalleryPage;
import com.google.appinventor.client.explorer.youngandroid.GalleryToolbar;
import com.google.appinventor.client.explorer.youngandroid.ProjectToolbar;
import com.google.appinventor.client.explorer.youngandroid.ReportList;
import com.google.appinventor.client.output.OdeLog;
import com.google.appinventor.client.settings.Settings;
import com.google.appinventor.client.settings.user.UserSettings;
......@@ -962,7 +964,7 @@ public class Ode implements EntryPoint {
// Gallery list tab
VerticalPanel gVertPanel = new VerticalPanel();
gVertPanel.add(createLoadingWidget());
gVertPanel.add(createLoadingWidget(GalleryList.INITIAL_RPCS));
galleryTabIndex = deckPanel.getWidgetCount();
deckPanel.add(gVertPanel);
......@@ -1009,6 +1011,7 @@ public class Ode implements EntryPoint {
// Moderation Page tab
VerticalPanel mPVertPanel = new VerticalPanel();
mPVertPanel.add(createLoadingWidget(ReportList.INITIAL_RPCS));
moderationPageTabIndex = deckPanel.getWidgetCount();
deckPanel.add(mPVertPanel);
......@@ -2239,7 +2242,7 @@ public class Ode implements EntryPoint {
galleryInitialized = true;
}
private Widget createLoadingWidget() {
private Widget createLoadingWidget(final int pending) {
final HorizontalPanel container = new HorizontalPanel();
container.setWidth("100%");
container.setSpacing(0);
......@@ -2253,6 +2256,7 @@ public class Ode implements EntryPoint {
panel.add(label);
container.add(panel);
GalleryClient.getInstance().addListener(new GalleryRequestListener() {
volatile int count = pending;
private void hideLoadingWidget() {
if (container.getParent() != null) {
container.clear();
......@@ -2261,18 +2265,27 @@ public class Ode implements EntryPoint {
}
@Override
public boolean onAppListRequestCompleted(GalleryAppListResult appsResult, int requestID, boolean refreshable) {
hideLoadingWidget();
return true;
if ((--count) <= 0) {
hideLoadingWidget();
return true;
}
return false;
}
@Override
public boolean onCommentsRequestCompleted(List<GalleryComment> comments) {
hideLoadingWidget();
return true;
if ((--count) <= 0) {
hideLoadingWidget();
return true;
}
return false;
}
@Override
public boolean onSourceLoadCompleted(UserProject projectInfo) {
hideLoadingWidget();
return true;
if ((--count) <= 0) {
hideLoadingWidget();
return true;
}
return false;
}
});
return container;
......
......@@ -41,6 +41,11 @@ import com.google.gwt.user.client.ui.VerticalPanel;
* @author wolberd@google.com (Dave Wolber)
*/
public class GalleryList extends Composite implements GalleryRequestListener {
/**
* The number of RPCs that will be made when the GalleryList is initialized. This is used in
* {@link Ode#initializeUi()} to determine when to hide the Loading message.
*/
public static final int INITIAL_RPCS = 4;
final Ode ode = Ode.getInstance();
private List<GalleryApp> apps;
......
......@@ -55,6 +55,11 @@ import com.google.gwt.user.client.ui.VerticalPanel;
* @author blu2@dons.usfca.edu (Bin Lu)
*/
public class ReportList extends Composite {
/**
* The number of RPCs that will be made when the ReportList is initialized. This is used in
* {@link Ode#initializeUi()} to determine when to hide the Loading message.
*/
public static final int INITIAL_RPCS = 1;
public static final int MAX_EMAIL_PREVIEW_LENGTH = 40;
private final CheckBox checkBox;
private final VerticalPanel panel;
......
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