use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class FullScreenAdService method showWelcomeAd.
/**
* Invoked on application startup, this code will download an ad or timeout
*/
public void showWelcomeAd() {
if (!UIManager.getInstance().wasThemeInstalled()) {
if (Display.getInstance().hasNativeTheme()) {
Display.getInstance().installNativeTheme();
}
}
ConnectionRequest r = createAdRequest();
r.setPriority(ConnectionRequest.PRIORITY_HIGH);
r.setTimeout(timeout);
InfiniteProgress ip = new InfiniteProgress();
Dialog ipDialog = ip.showInifiniteBlocking();
NetworkManager.getInstance().addToQueueAndWait(r);
if (failed()) {
ipDialog.dispose();
if (!allowWithoutNetwork) {
ipDialog.dispose();
Dialog.show("Network Error", "Please try again later", "Exit", null);
Display.getInstance().exitApplication();
} else {
return;
}
}
Component c = getPendingAd();
if (c != null) {
Form adForm = new AdForm(c);
adForm.setTransitionInAnimator(CommonTransitions.createEmpty());
adForm.setTransitionOutAnimator(CommonTransitions.createEmpty());
adForm.show();
}
}
use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class ThemeEditor method initMIDlet.
private void initMIDlet() {
JavaSEPortWithSVGSupport.setShowEDTWarnings(false);
JavaSEPortWithSVGSupport.setShowEDTViolationStacks(false);
// its a UI form
if (uiPreviewContent.getSelectedIndex() == uiPreviewContent.getModel().getSize() - 1) {
previewPanel.removeAll();
if (com.codename1.ui.Display.isInitialized()) {
com.codename1.ui.Display.deinitialize();
}
JavaSEPortWithSVGSupport.setDefaultInitTarget(previewPanel);
com.codename1.ui.Display.init(previewPanel);
previewPanel.getComponent(0).setBounds(0, 0, get(widthResoltution), get(heightResolution));
previewPanel.getComponent(0).setPreferredSize(new java.awt.Dimension(get(widthResoltution), get(heightResolution)));
PickMIDlet.startMIDlet(themeHash);
} else {
Preferences.userNodeForPackage(getClass()).put("uiPreviewContent", (String) uiPreviewContent.getSelectedItem());
Accessor.setTheme(themeHash);
if (com.codename1.ui.Display.isInitialized()) {
com.codename1.ui.Display.deinitialize();
}
previewPanel.removeAll();
com.codename1.ui.Display.init(previewPanel);
previewPanel.getComponent(0).setBounds(0, 0, get(widthResoltution), get(heightResolution));
previewPanel.getComponent(0).setPreferredSize(new java.awt.Dimension(get(widthResoltution), get(heightResolution)));
com.codename1.ui.util.UIBuilder.registerCustomComponent("Table", com.codename1.ui.table.Table.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MediaPlayer", com.codename1.components.MediaPlayer.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ContainerList", com.codename1.ui.list.ContainerList.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ComponentGroup", com.codename1.ui.ComponentGroup.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Tree", com.codename1.ui.tree.Tree.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("HTMLComponent", com.codename1.ui.html.HTMLComponent.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("RSSReader", com.codename1.components.RSSReader.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("FileTree", com.codename1.components.FileTree.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("WebBrowser", com.codename1.components.WebBrowser.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("NumericSpinner", com.codename1.ui.spinner.NumericSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("DateSpinner", com.codename1.ui.spinner.DateSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("TimeSpinner", com.codename1.ui.spinner.TimeSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("DateTimeSpinner", com.codename1.ui.spinner.DateTimeSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("GenericSpinner", com.codename1.ui.spinner.GenericSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("LikeButton", com.codename1.facebook.ui.LikeButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("InfiniteProgress", com.codename1.components.InfiniteProgress.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MultiButton", com.codename1.components.MultiButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("SpanButton", com.codename1.components.SpanButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("SpanLabel", com.codename1.components.SpanLabel.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Ads", com.codename1.components.Ads.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MapComponent", com.codename1.maps.MapComponent.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MultiList", com.codename1.ui.list.MultiList.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ShareButton", com.codename1.components.ShareButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("OnOffSwitch", com.codename1.components.OnOffSwitch.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ImageViewer", com.codename1.components.ImageViewer.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("AutoCompleteTextField", com.codename1.ui.AutoCompleteTextField.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Picker", com.codename1.ui.spinner.Picker.class);
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
com.codename1.ui.util.UIBuilder builder = new com.codename1.ui.util.UIBuilder();
final com.codename1.ui.Container c = builder.createContainer(resources, (String) uiPreviewContent.getSelectedItem());
if (c instanceof com.codename1.ui.Form) {
if (c instanceof com.codename1.ui.Dialog) {
com.codename1.ui.animations.Transition t = ((com.codename1.ui.Dialog) c).getTransitionInAnimator();
((com.codename1.ui.Dialog) c).setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
((com.codename1.ui.Dialog) c).showModeless();
((com.codename1.ui.Dialog) c).setTransitionInAnimator(t);
} else {
com.codename1.ui.animations.Transition t = ((com.codename1.ui.Form) c).getTransitionInAnimator();
((com.codename1.ui.Form) c).setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
((com.codename1.ui.Form) c).show();
((com.codename1.ui.Form) c).setTransitionInAnimator(t);
}
} else {
com.codename1.ui.Form f = new Form();
f.setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
f.setLayout(new com.codename1.ui.layouts.BorderLayout());
f.addComponent(com.codename1.ui.layouts.BorderLayout.CENTER, c);
f.show();
}
}
});
}
}
use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class Util method downloadUrlTo.
private static boolean downloadUrlTo(String url, String fileName, boolean showProgress, boolean background, boolean storage, ActionListener callback) {
ConnectionRequest cr = new ConnectionRequest();
cr.setPost(false);
cr.setFailSilently(true);
cr.setReadResponseForErrors(false);
cr.setDuplicateSupported(true);
cr.setUrl(url);
if (callback != null) {
cr.addResponseListener(callback);
}
if (storage) {
cr.setDestinationStorage(fileName);
} else {
cr.setDestinationFile(fileName);
}
if (background) {
NetworkManager.getInstance().addToQueue(cr);
return true;
}
if (showProgress) {
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
NetworkManager.getInstance().addToQueueAndWait(cr);
d.dispose();
} else {
NetworkManager.getInstance().addToQueueAndWait(cr);
}
int rc = cr.getResponseCode();
return rc == 200 || rc == 201;
}
use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class FacebookShare method share.
/**
* {@inheritDoc}
*/
public void share(String text, final String image, final String mime) {
final ShareForm[] f = new ShareForm[1];
if (image == null) {
f[0] = new ShareForm(getOriginal(), "Post on My Wall", null, text, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
InfiniteProgress inf = new InfiniteProgress();
final Dialog progress = inf.showInifiniteBlocking();
FaceBookAccess.getInstance().addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
NetworkEvent ne = (NetworkEvent) evt;
int code = ne.getResponseCode();
FaceBookAccess.getInstance().removeResponseCodeListener(this);
progress.dispose();
Dialog.show("Failed to Share", "for some reason sharing has failed, try again later.", "Ok", null);
finish();
}
});
FaceBookAccess.getInstance().postOnWall("me", f[0].getMessage(), new ActionListener() {
public void actionPerformed(ActionEvent evt) {
progress.dispose();
finish();
}
});
} catch (IOException ex) {
Log.e(ex);
System.out.println("failed to share " + ex.getMessage());
}
}
});
f[0].show();
} else {
f[0] = new ShareForm(getOriginal(), "Post on My Wall", null, text, image, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
InfiniteProgress inf = new InfiniteProgress();
final Dialog progress = inf.showInifiniteBlocking();
FaceBookAccess.getInstance().addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
NetworkEvent ne = (NetworkEvent) evt;
int code = ne.getResponseCode();
FaceBookAccess.getInstance().removeResponseCodeListener(this);
progress.dispose();
Dialog.show("Failed to Share", "for some reason sharing has failed, try again later.", "Ok", null);
finish();
}
});
MultipartRequest req = new MultipartRequest();
req.addResponseListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
progress.dispose();
finish();
}
});
final String endpoint = "https://graph.facebook.com/me/photos?access_token=" + token;
req.setUrl(endpoint);
req.addArgumentNoEncoding("message", f[0].getMessage());
InputStream is = null;
try {
is = FileSystemStorage.getInstance().openInputStream(image);
req.addData("source", is, FileSystemStorage.getInstance().getLength(image), mime);
NetworkManager.getInstance().addToQueue(req);
} catch (IOException ioe) {
Log.e(ioe);
}
}
});
f[0].show();
}
}
Aggregations