removed async loading for enntrypoints

This commit is contained in:
Kai Boernert committed 2017-11-22 14:46:11 +01:00
1 parent 2c6743ca79
commit 04777c0e84
1 file changed
+15 -47
@@ -10,7 +10,6 @@ import java.util.logging.Logger;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
@@ -18,8 +17,6 @@ import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceHistoryMapper;
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.sap.sailing.gwt.common.client.SharedResources;
import com.sap.sailing.gwt.home.desktop.DesktopEntryPoint;
import com.sap.sailing.gwt.home.mobile.MobileEntryPoint;
@@ -35,9 +32,10 @@ import com.sap.sse.gwt.client.formfactor.DeviceDetector;
*
* The decision is made on the following aspects:
* <ul>
* <li>the type of device (desktop, phone, table)</li>
* <li>the place to be shown and if the place is available for one or the other form factor</li>
* <li>the user preference that is being triggered by the user clicking "desktop version" or "mobile version" links in the page footer</li>
* <li>the type of device (desktop, phone, table)</li>
* <li>the place to be shown and if the place is available for one or the other form factor</li>
* <li>the user preference that is being triggered by the user clicking "desktop version" or "mobile version" links in
* the page footer</li>
* </ul>
*/
public class SwitchingEntryPoint implements EntryPoint {
@@ -51,10 +49,10 @@ public class SwitchingEntryPoint implements EntryPoint {
public void onModuleLoad() {
Document.get().getElementById("loading").removeFromParent();
LOG.info("Start switching entry point");
SharedResources.INSTANCE.mediaCss().ensureInjected();
SharedResources.INSTANCE.mainCss().ensureInjected();
String hash = Window.Location.getHash();
if (hash != null && hash.startsWith("#")) {
hash = hash.substring(1);
@@ -91,8 +89,9 @@ public class SwitchingEntryPoint implements EntryPoint {
*
* @param place
* {@link Place} to check
* @return <code>true</code> if the given {@link Place} implements {@link HasMobileVersion} interface or the implemented
* {@link MobileSupport#hasMobileVersion()} method returns <code>true</code>, <code>false</code> otherwise
* @return <code>true</code> if the given {@link Place} implements {@link HasMobileVersion} interface or the
* implemented {@link MobileSupport#hasMobileVersion()} method returns <code>true</code>, <code>false</code>
* otherwise
*/
public static boolean hasMobileVersion(Place place) {
return place instanceof HasMobileVersion
@@ -111,12 +110,7 @@ public class SwitchingEntryPoint implements EntryPoint {
// only force "not mobile" on mobile devices
Cookies.setCookie(SAPSAILING_MOBILE, "false");
}
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Window.Location.reload();
}
});
reloadApp();
}
public static void switchToMobile() {
@@ -126,48 +120,22 @@ public class SwitchingEntryPoint implements EntryPoint {
// only force mobile version on desktop
Cookies.setCookie(SAPSAILING_MOBILE, "true");
}
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Window.Location.reload();
}
});
reloadApp();
}
private void startMobile() {
configureMobileHeader();
GWT.runAsync(MobileEntryPoint.class, new RunAsyncCallback() {
@Override
public void onSuccess() {
new MobileEntryPoint().onModuleLoad();
}
@Override
public void onFailure(Throwable reason) {
LOG.severe("Failed to async start mobile version: " + reason.getMessage());
RootPanel.get().add(new Label("Failed to load mobile version"));
}
});
new MobileEntryPoint().onModuleLoad();
}
private void startDesktop() {
configureDesktopHeader();
GWT.runAsync(DesktopEntryPoint.class, new RunAsyncCallback() {
@Override
public void onSuccess() {
new DesktopEntryPoint().onModuleLoad();
}
@Override
public void onFailure(Throwable reason) {
LOG.severe("Failed to async start desktop version: " + reason.getMessage());
RootPanel.get().add(new Label("Failed to load desktop version"));
}
});
new DesktopEntryPoint().onModuleLoad();
}
private void configureDesktopHeader() {
setViewportToDeviceWidth(DeviceDetector.isTablet() ? SCALE_VALUE_SMALLER : SCALE_VALUE_SMALL, SCALE_VALUE_LARGE);
setViewportToDeviceWidth(DeviceDetector.isTablet() ? SCALE_VALUE_SMALLER : SCALE_VALUE_SMALL,
SCALE_VALUE_LARGE);
}
private void configureMobileHeader() {