use of com.codename1.ui.Dialog 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.ui.Dialog in project CodenameOne by codenameone.
the class MasterDetail method bindTabletLandscapeMaster.
/**
* @deprecated this was a half baked idea that made it into the public API
*/
public static void bindTabletLandscapeMaster(final Form rootForm, Container parentContainer, Component landscapeUI, final Component portraitUI, final String commandTitle, Image commandIcon) {
landscapeUI.setHideInPortrait(true);
parentContainer.addComponent(BorderLayout.WEST, landscapeUI);
final Command masterCommand = new Command(commandTitle, commandIcon) {
public void actionPerformed(ActionEvent ev) {
Dialog dlg = new Dialog();
dlg.setLayout(new BorderLayout());
dlg.setDialogUIID("Container");
dlg.getContentPane().setUIID("Container");
Container titleArea = new Container(new BorderLayout());
dlg.addComponent(BorderLayout.NORTH, titleArea);
titleArea.setUIID("TitleArea");
Label title = new Label(commandTitle);
titleArea.addComponent(BorderLayout.CENTER, title);
title.setUIID("Title");
Container body = new Container(new BorderLayout());
body.setUIID("Form");
body.addComponent(BorderLayout.CENTER, portraitUI);
dlg.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 250));
dlg.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, true, 250));
dlg.addComponent(BorderLayout.CENTER, body);
dlg.setDisposeWhenPointerOutOfBounds(true);
dlg.showStetched(BorderLayout.WEST, true);
dlg.removeComponent(portraitUI);
}
};
if (Display.getInstance().isPortrait()) {
if (rootForm.getCommandCount() > 0) {
rootForm.addCommand(masterCommand, 1);
} else {
rootForm.addCommand(masterCommand);
}
}
rootForm.addOrientationListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (portraitUI.getParent() != null) {
Form f = Display.getInstance().getCurrent();
if (f instanceof Dialog) {
((Dialog) f).dispose();
}
}
if (Display.getInstance().isPortrait()) {
rootForm.addCommand(masterCommand, 1);
} else {
rootForm.removeCommand(masterCommand);
rootForm.revalidate();
}
}
});
}
use of com.codename1.ui.Dialog in project CodenameOne by codenameone.
the class FloatingActionButton method createPopupContent.
/**
* Creates the popup content container to display on the dialog.
*
* @param fabs List of sub FloatingActionButton
* @return a Container that contains all fabs
*/
protected Container createPopupContent(List<FloatingActionButton> fabs) {
Container con = new Container(new BoxLayout(BoxLayout.Y_AXIS));
for (FloatingActionButton next : subMenu) {
next.setPreferredW(getWidth());
Container c = new Container(new BorderLayout());
Label txt = new Label(next.text);
txt.setUIID("FloatingActionText");
c.add(BorderLayout.CENTER, FlowLayout.encloseRight(txt));
c.add(BorderLayout.EAST, next);
con.add(c);
}
return con;
}
use of com.codename1.ui.Dialog in project CodenameOne by codenameone.
the class FloatingActionButton method released.
@Override
public void released(int x, int y) {
super.released(x, y);
if (current != null) {
current.dispose();
current = null;
}
// if this fab has sub fab's display them
if (subMenu != null) {
final Container con = createPopupContent(subMenu);
Dialog d = new Dialog();
d.setDialogUIID("Container");
d.getContentPane().setUIID("Container");
d.setLayout(new BorderLayout());
d.add(BorderLayout.CENTER, con);
for (FloatingActionButton next : subMenu) {
next.current = d;
}
d.setTransitionInAnimator(CommonTransitions.createEmpty());
d.setTransitionOutAnimator(CommonTransitions.createEmpty());
for (Component c : con) {
c.setVisible(false);
}
Form f = getComponentForm();
int oldTint = f.getTintColor();
f.setTintColor(0);
d.setBlurBackgroundRadius(-1);
d.addShowListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
for (Component c : con) {
c.setY(con.getHeight());
c.setVisible(true);
}
con.animateLayout(200);
}
});
showPopupDialog(d);
f.setTintColor(oldTint);
for (FloatingActionButton next : subMenu) {
next.remove();
}
con.removeAll();
}
}
use of com.codename1.ui.Dialog in project CodenameOne by codenameone.
the class InfiniteProgress method showInifiniteBlocking.
/**
* Shows the infinite progress over the whole screen, the blocking can be competed by calling <code>dispose()</code>
* on the returned <code>Dialog</code>.
*<script src="https://gist.github.com/codenameone/a0a6abca781cd86e4f5e.js"></script>
* @return the dialog created for the blocking effect, disposing it will return to the previous form and remove the input block.
*/
public Dialog showInifiniteBlocking() {
Form f = Display.getInstance().getCurrent();
if (f == null) {
f = new Form();
f.show();
}
if (f.getClientProperty("isInfiniteProgress") == null) {
f.setTintColor(tintColor);
}
Dialog d = new Dialog();
d.putClientProperty("isInfiniteProgress", true);
d.setTintColor(0x0);
d.setDialogUIID("Container");
d.setLayout(new BorderLayout());
d.addComponent(BorderLayout.CENTER, this);
d.setTransitionInAnimator(CommonTransitions.createEmpty());
d.setTransitionOutAnimator(CommonTransitions.createEmpty());
d.showPacked(BorderLayout.CENTER, false);
return d;
}
Aggregations