Search in sources :

Example 36 with Dialog

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();
    }
}
Also used : ConnectionRequest(com.codename1.io.ConnectionRequest) InfiniteProgress(com.codename1.components.InfiniteProgress) Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog) Component(com.codename1.ui.Component)

Example 37 with Dialog

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();
            }
        }
    });
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) Command(com.codename1.ui.Command) Form(com.codename1.ui.Form) ActionEvent(com.codename1.ui.events.ActionEvent) Dialog(com.codename1.ui.Dialog) Label(com.codename1.ui.Label)

Example 38 with Dialog

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;
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) BoxLayout(com.codename1.ui.layouts.BoxLayout) Label(com.codename1.ui.Label)

Example 39 with Dialog

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();
    }
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog) ActionEvent(com.codename1.ui.events.ActionEvent) Component(com.codename1.ui.Component)

Example 40 with Dialog

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;
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog)

Aggregations

Dialog (com.codename1.ui.Dialog)28 Form (com.codename1.ui.Form)23 BorderLayout (com.codename1.ui.layouts.BorderLayout)17 Component (com.codename1.ui.Component)16 ActionEvent (com.codename1.ui.events.ActionEvent)14 Container (com.codename1.ui.Container)13 Style (com.codename1.ui.plaf.Style)12 ActionListener (com.codename1.ui.events.ActionListener)10 GridLayout (com.codename1.ui.layouts.GridLayout)8 UIManager (com.codename1.ui.plaf.UIManager)7 IOException (java.io.IOException)7 InfiniteProgress (com.codename1.components.InfiniteProgress)6 Command (com.codename1.ui.Command)6 Label (com.codename1.ui.Label)6 BoxLayout (com.codename1.ui.layouts.BoxLayout)6 ConnectionRequest (com.codename1.io.ConnectionRequest)4 Button (com.codename1.ui.Button)4 CheckBox (com.codename1.ui.CheckBox)4 Painter (com.codename1.ui.Painter)4 TextArea (com.codename1.ui.TextArea)4