Java Code Examples for com.codename1.ui.events.ActionListener

The following examples show how to use com.codename1.ui.events.ActionListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: CodenameOne   Author: codenameone   File: RequestBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Executes the request asynchronously and writes the response to the provided
 * Callback. This fetches JSON data and parses it into a properties business object
 * @param callback writes the response to this callback
 * @param type the class of the business object returned
 * @return returns the Connection Request object so it can be killed if necessary
 */ 
public ConnectionRequest fetchAsProperties(final OnComplete<Response<PropertyBusinessObject>> callback, final Class type) {
    final Connection request = createRequest(true);
    request.addResponseListener(new ActionListener<NetworkEvent>() {
        @Override
        public void actionPerformed(NetworkEvent evt) {
            if(request.errorCode) {
                return;
            }
            Response res = null;
            Map response = (Map)evt.getMetaData();
            try {
                PropertyBusinessObject pb = (PropertyBusinessObject)type.newInstance();
                pb.getPropertyIndex().populateFromMap(response);
                res = new Response(evt.getResponseCode(), pb, evt.getMessage());
                callback.completed(res);
            } catch(Exception err) {
                Log.e(err);
                throw new RuntimeException(err.toString());
            }
        }
    });
    fetched = true;
    CN.addToQueue(request);       
    return request;
}
 
Example #2
Source Project: codenameone-demos   Author: codenameone   File: PushDemo.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    s = new StateMachine("/theme");        
    
    Display.getInstance().addEdtErrorHandler(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            evt.consume();
            Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
            Log.p("OS " + Display.getInstance().getPlatformName());
            Log.p("Error " + evt.getSource());
            Log.p("Current Form " + Display.getInstance().getCurrent().getName());
            Log.e((Throwable)evt.getSource());
            Log.sendLog();
        }
    });
}
 
Example #3
Source Project: CodenameOne   Author: codenameone   File: Sheet.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void initUI() {
    setLayout(new BorderLayout());
    contentPane.setSafeArea(true);
    titleBar.setSafeArea(true);
    add(BorderLayout.NORTH, titleBar);
    if (parentSheet != null) {
        FontImage.setMaterialIcon(backButton, FontImage.MATERIAL_ARROW_BACK);
    }
    add(BorderLayout.CENTER, contentPane);
    backButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            back(DEFAULT_TRANSITION_DURATION);
        }
    });
    
}
 
Example #4
Source Project: CodenameOne   Author: codenameone   File: Form.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void addKeyListener(int keyCode, ActionListener listener, HashMap<Integer, ArrayList<ActionListener>> keyListeners) {
    if (keyListeners == null) {
        keyListeners = new HashMap<Integer, ArrayList<ActionListener>>();
    }
    Integer code = new Integer(keyCode);
    ArrayList<ActionListener> vec = keyListeners.get(code);
    if (vec == null) {
        vec = new ArrayList<ActionListener>();
        vec.add(listener);
        keyListeners.put(code, vec);
        return;
    }
    if (!vec.contains(listener)) {
        vec.add(listener);
    }
}
 
Example #5
Source Project: codenameone-demos   Author: codenameone   File: FBDemo.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Component showShare() {
    final Container c = new Container(new BorderLayout());
    final ShareButton share = new ShareButton();
    final TextArea t = new TextArea("Sharing on Facebook with CodenameOne is a breeze.\n"
            + "http://www.codenameone.com\n"
            + "(Sent from the facebook demo app)");
    t.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            share.setTextToShare(t.getText());
        }
    });
    c.addComponent(BorderLayout.CENTER, t);
    share.setTextToShare(t.getText());
    Container cnt = new Container(new BorderLayout());
    cnt.addComponent(BorderLayout.SOUTH, share);
    c.addComponent(BorderLayout.EAST, cnt);
    return c;
}
 
Example #6
Source Project: CodenameOne   Author: codenameone   File: SideMenuBar.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Folds the current side menu if it is open, when the menu is closed it
 * will invoke the runnable callback method
 *
 * @param callback will be invoked when the menu is actually closed
 */
public static void closeCurrentMenu(final Runnable callback) {
    if(Toolbar.isOnTopSideMenu() && (Toolbar.isGlobalToolbar() || Display.getInstance().getCommandBehavior() != Display.COMMAND_BEHAVIOR_SIDE_NAVIGATION)) {
        Display.getInstance().getCurrent().getToolbar().closeSideMenu();
        callback.run();
        return;
    }
    Form f = Display.getInstance().getCurrent();
    final SideMenuBar b = (SideMenuBar) f.getClientProperty("cn1$sideMenuParent");
    if (b != null && !b.transitionRunning) {
        b.parent.addShowListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                b.parent.removeShowListener(this);
                callback.run();
            }
        });
        b.closeMenu();
    } else {
        callback.run();
    }
}
 
Example #7
Source Project: CodenameOne   Author: codenameone   File: Ads.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void initComponent() {
    if(service != null) {
        service.initialize(this);
        service.addResponseListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String a = (String) evt.getSource();
                setAd(a);
            }
        });
        
        if (refreshAd) {
            getComponentForm().registerAnimated(this);
        }else{
            requestAd();            
        }
    }
}
 
Example #8
Source Project: CodenameOne   Author: codenameone   File: FaceBookAccess.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get a list of FaceBook objects for a given id
 * 
 * @param faceBookId the id to preform the query upon
 * @param itemsConnection the type of the query
 * @param feed
 * @param params
 * @param callback the callback that should be updated when the data arrives
 */
public void getFaceBookObjectItems(String faceBookId, String itemsConnection,
        final DefaultListModel feed, Hashtable params, final ActionListener callback) throws IOException {
    checkAuthentication();

    final FacebookRESTService con = new FacebookRESTService(token, faceBookId, itemsConnection, false);
    con.setResponseDestination(feed);
    con.addResponseListener(new Listener(con, callback));
    if (params != null) {
        Enumeration keys = params.keys();
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            con.addArgument(key, (String) params.get(key));
        }
    }
    if (slider != null) {
        SliderBridge.bindProgress(con, slider);
    }
    for (int i = 0; i < responseCodeListeners.size(); i++) {
        con.addResponseCodeListener((ActionListener) responseCodeListeners.elementAt(i));
    }
    current = con;
    NetworkManager.getInstance().addToQueue(con);
}
 
Example #9
Source Project: CodenameOne   Author: codenameone   File: FaceBookAccess.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gest an album from an albumId
 *
 * @param albumId the albumId
 * @param album an Object to fill with the data
 * @param callback the callback that should be updated when the data arrives
 */
public void getAlbum(String albumId, final Album album, final ActionListener callback) throws IOException {
    getFaceBookObject(albumId, new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            Vector v = (Vector) ((NetworkEvent) evt).getMetaData();
            Hashtable t = (Hashtable) v.elementAt(0);
            if (album != null) {
                album.copy(t);
            }
            if (callback != null) {
                callback.actionPerformed(evt);
            }
        }
    });
}
 
Example #10
Source Project: CodenameOne   Author: codenameone   File: FaceBookAccess.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the picture of the given facebook object id
 *
 * @param id the object id to query
 * @param callback the callback that should be updated when the data arrives
 * @param toScale picture dimension or null
 * @param tempStorage if true place the image in a temp storage
 */
public void getPicture(String id, final ActionListener callback, Dimension toScale, boolean tempStorage) throws IOException {
    checkAuthentication();

    FacebookRESTService fb = new FacebookRESTService(token, id, FacebookRESTService.PICTURE, false);
    if(toScale != null){
        fb.addArgument("width", "" + toScale.getWidth());
        fb.addArgument("height", "" + toScale.getHeight());
    }else{
        fb.addArgument("type", "small");
    }
    String cacheKey = id;
    //check if this image is a temporarey resource and it is not saved
    //already has a permanent image
    if (tempStorage && !Storage.getInstance().exists(id)) {
        cacheKey = TEMP_STORAGE + id;
    }
    ImageDownloadService.createImageToStorage(fb.requestURL(), callback, cacheKey);
}
 
Example #11
Source Project: CodenameOne   Author: codenameone   File: FaceBookAccess.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Post a message on the users wall
 *
 * @param userId the userId
 * @param message the message to post
 */
public void postOnWall(String userId, String message, ActionListener callback) throws IOException {
    checkAuthentication();

    FacebookRESTService con = new FacebookRESTService(token, userId, FacebookRESTService.FEED, true);
    con.addArgument("message", "" + message);
    con.addResponseListener(new Listener(con, callback));
    if (slider != null) {
        SliderBridge.bindProgress(con, slider);
    }
    for (int i = 0; i < responseCodeListeners.size(); i++) {
        con.addResponseCodeListener((ActionListener) responseCodeListeners.elementAt(i));
    }
    current = con;
    NetworkManager.getInstance().addToQueueAndWait(con);
}
 
Example #12
Source Project: CodenameOne   Author: codenameone   File: CachedDataService.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks that the cached data is up to date and if a newer version exits it updates the data in place
 * 
 * @param d the data to check
 * @param callback optional callback to be invoked on request completion
 */
public static void updateData(CachedData d, ActionListener callback) {
    if(d.isFetching()) {
        return;
    }
    d.setFetching(true);
    CachedDataService c = new CachedDataService();
    c.setUrl(d.getUrl());
    c.setPost(false);
    if(callback != null) {
        c.addResponseListener(callback);
    }
    if(d.getModified() != null && d.getModified().length() > 0) {
        c.addRequestHeader("If-Modified-Since", d.getModified());
        if(d.getEtag() != null) {
            c.addRequestHeader("If-None-Match", d.getEtag());
        }
    }
    NetworkManager.getInstance().addToQueue(c);        
}
 
Example #13
Source Project: CodenameOne   Author: codenameone   File: Calendar.java    License: GNU General Public License v2.0 5 votes vote down vote up
public MonthView(long time) {
    super(new BoxLayout(BoxLayout.Y_AXIS));
    setUIID("MonthView");
    titles = new Container(new GridLayout(1, 7));
    days = new Container(new GridLayout(6, 7));
    addComponent(titles);
    addComponent(days);
    if (UIManager.getInstance().isThemeConstant("calTitleDayStyleBool", false)) {
        titles.setUIID("CalendarTitleArea");
        days.setUIID("CalendarDayArea");
    }
    for (int iter = 0; iter < DAYS.length; iter++) {
        titles.addComponent(createDayTitle(iter));
    }
    for (int iter = 0; iter < components.length; iter++) {
        components[iter] = createDayComponent();
        days.add(components[iter]);
        if (iter <= 7) {
            components[iter].setNextFocusUp(year);
        }
        bindDayListener(components[iter], this);
        for (ActionListener dayListener : dayListeners) {
            bindDayListener(components[iter], dayListener);
        }
    }
    setCurrentDay(time);

}
 
Example #14
Source Project: CodenameOne   Author: codenameone   File: ProxyHttpTile.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an Http Tile
 * 
 * @param tileSize the tile size
 * @param bbox the tile bounding box
 * @param url the url to bring the image from
 */
public ProxyHttpTile(Dimension tileSize, BoundingBox bbox, final String url) {
    super(tileSize, bbox, null);
    _url = url;
    String cacheId = url.substring(url.indexOf(":")+1);
    cacheId = StringUtil.replaceAll(cacheId, "\\", "_");
    cacheId = StringUtil.replaceAll(cacheId, "/", "_");
    cacheId = StringUtil.replaceAll(cacheId, ".", "_");
    cacheId = StringUtil.replaceAll(cacheId, "?", "_");
    cacheId = StringUtil.replaceAll(cacheId, "&", "_");
    
    ImageDownloadService.createImageToStorage(url, new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            NetworkEvent ne = (NetworkEvent) evt;

            Image i = (Image) ne.getMetaData();
            i.lock();
            _tile = new Tile(ProxyHttpTile.this.dimension(),
                    ProxyHttpTile.this.getBoundingBox(),
                    i);
            ProxyHttpTile.this.fireReady();
        }
    }, cacheId, true);


}
 
Example #15
Source Project: CodenameOne   Author: codenameone   File: Tree.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Since a node may be any component type developers should override this method to
 * add support for binding the click listener to the given component.
 * @param l listener interface
 * @param node node component returned by createNode
 */
protected void bindNodeListener(ActionListener l, Component node) {
    if(node instanceof Button) {
        ((Button)node).addActionListener(l);
        return;
    }
    ((SpanButton)node).addActionListener(l);
}
 
Example #16
Source Project: CodenameOne   Author: codenameone   File: RequestBuilder.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Executes the request asynchronously and writes the response to the provided
 * Callback. This fetches JSON data and parses it into a properties business object
 * @param callback writes the response to this callback
 * @param type the class of the business object returned
 * @return returns the Connection Request object so it can be killed if necessary
 */ 
public ConnectionRequest fetchAsPropertyList(final OnComplete<Response<List<PropertyBusinessObject>>> callback, final Class type) {
    final Connection request = createRequest(true);
    request.addResponseListener(new ActionListener<NetworkEvent>() {
        @Override
        public void actionPerformed(NetworkEvent evt) {
            if(request.errorCode) {
                return;
            }
            Response res = null;
            Map response = (Map)evt.getMetaData();
            List<Map> lst = (List<Map>)response.get("root");
            if(lst == null) {
                return;
            }
            try {
                List<PropertyBusinessObject> result = new ArrayList<PropertyBusinessObject>();
                for(Map m : lst) {
                    PropertyBusinessObject pb = (PropertyBusinessObject)type.newInstance();
                    pb.getPropertyIndex().populateFromMap(m);
                    result.add(pb);
                }
                res = new Response(evt.getResponseCode(), result, evt.getMessage());
                callback.completed(res);
            } catch(Exception err) {
                Log.e(err);
                throw new RuntimeException(err.toString());
            }
        }
    });
    fetched = true;
    CN.addToQueue(request);       
    return request;
}
 
Example #17
Source Project: codenameone-demos   Author: codenameone   File: Web.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Container createDemo() {
    Container cnt = new Container(new BorderLayout());
    final WebBrowser wb = new WebBrowser();
    if(wb.getInternal() instanceof BrowserComponent) {
        Button btn = new Button("Add");
        final TextArea content = new TextArea();
        Container north = new Container(new BorderLayout());
        north.addComponent(BorderLayout.CENTER, content);
        north.addComponent(BorderLayout.EAST, btn);
        cnt.addComponent(BorderLayout.NORTH, north);
        content.setHint("Add to web document");
        btn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                ((BrowserComponent)wb.getInternal()).execute("fnc('" + content.getText() + "');");
            }
        });
        ((BrowserComponent)wb.getInternal()).setBrowserNavigationCallback(new BrowserNavigationCallback() {
            public boolean shouldNavigate(String url) {
                if(url.startsWith("http://sayhello")) {
                    // warning!!! This is not on the EDT and this method MUST return immediately!
                    Display.getInstance().callSerially(new Runnable() {
                        public void run() {
                            ((BrowserComponent)wb.getInternal()).execute("fnc('this was written by Java code!')");
                        }
                    });
                    return false;
                }
                return true;
            }
        });
    }
    
    cnt.addComponent(BorderLayout.CENTER, wb);
    wb.setURL("jar:///Page.html");
    return cnt;
}
 
Example #18
Source Project: CodenameOne   Author: codenameone   File: TextArea.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds a listener to be called with this TextArea is "closed".  I.e. when it is
 * no longer the active virtual input device for the form.
 * @param l 
 * @see Form#setCurrentInputDevice(com.codename1.ui.VirtualInputDevice) 
 */
public void addCloseListener(ActionListener l) {
    if (closeListeners == null) {
        closeListeners = new EventDispatcher();
    }
    closeListeners.addListener(l);
}
 
Example #19
Source Project: CodenameOne   Author: codenameone   File: Form.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This listener is invoked when device orientation changes on devices that support orientation change
 *
 * @param l the listener
 */
public void removeOrientationListener(ActionListener l) {
    if (orientationListener == null) {
        return;
    }
    orientationListener.removeListener(l);
}
 
Example #20
Source Project: CodenameOne   Author: codenameone   File: NetworkManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Identical to add to queue but returns an AsyncResource object that will resolve to
 * the ConnectionRequest.
 * 
 * @param request the request object to add.
 * @return AsyncResource resolving to the connection request on complete.
 * @since 7.0
 */
public AsyncResource<ConnectionRequest> addToQueueAsync(final ConnectionRequest request) {
    final AsyncResource<ConnectionRequest> out = new AsyncResource<ConnectionRequest>();
    class WaitingClass implements ActionListener<NetworkEvent> {
        

        public void actionPerformed(NetworkEvent e) {
            if(e.getError() != null) {
                
                removeProgressListener(this);
                removeErrorListener(this);
                if (!out.isDone()) {
                    out.error(e.getError());
                }
                return;
            }
            if(e.getConnectionRequest() == request) {
                if(e.getProgressType() == NetworkEvent.PROGRESS_TYPE_COMPLETED) {
                    if(request.retrying) {
                        request.retrying = false;
                        return;
                    }
                    
                    removeProgressListener(this);
                    removeErrorListener(this);
                    if (!out.isDone()) {
                        out.complete(request);
                    }
                    return;
                }
            }
        }
    }
    WaitingClass w = new WaitingClass();
    addProgressListener(w);
    addErrorListener(w);
    addToQueue(request);
    return out;
}
 
Example #21
Source Project: CodenameOne   Author: codenameone   File: TextArea.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes an action listener
 * 
 * @param a actionListener
 */
public void removeActionListener(ActionListener a) {
    if(actionListeners == null) {
        return;
    }
    actionListeners.removeListener(a);
    if(!actionListeners.hasListeners()) {
        actionListeners = null;
    }
}
 
Example #22
Source Project: CodenameOne   Author: codenameone   File: ConnectionRequest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the given listener
 *
 * @param a listener
 */
public void removeResponseCodeListener(ActionListener<NetworkEvent> a) {
    if(responseCodeListeners == null) {
        return;
    }
    responseCodeListeners.removeListener(a);
    if(responseCodeListeners.getListenerCollection()== null || responseCodeListeners.getListenerCollection().size() == 0) {
        responseCodeListeners = null;
    }
}
 
Example #23
Source Project: CodenameOne   Author: codenameone   File: BrowserWindow.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds listeners to be notified when a page is loaded in the browser window.  ActionEvents
 * will have the URL of the page as a string as its "source" property.
 * @param l Listener to add.
 */
public void addLoadListener(ActionListener l) {
    if (nativeWindow != null) {
        Display.impl.addNativeBrowserWindowOnLoadListener(nativeWindow, l);
    } else {
        webview.addWebEventListener("onLoad", l);
    }
}
 
Example #24
Source Project: CodenameOne   Author: codenameone   File: BrowserComponent.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Registers a callback to be run when the BrowserComponent is "ready".  The browser component
 * is considered to be ready once the onLoad event has been fired on the first page.
 * If this method is called after the browser component is already "ready", then the callback
 * will be executed immediately.  Otherwise it will be called in the first onLoad event.
 * @param onReady Callback to be executed when the browser component is ready.
 * @return Self for chaining.
 * @since 7.0
 * @see #waitForReady() 
 */
public BrowserComponent ready(final SuccessCallback<BrowserComponent> onReady) {
    if (ready) {
        onReady.onSucess(this);
    } else {
        ActionListener l = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                removeWebEventListener(onStart, this);
                onReady.onSucess(BrowserComponent.this);
            }
        };
        addWebEventListener(onStart, l);
    }
    return this;
}
 
Example #25
Source Project: CodenameOne   Author: codenameone   File: FaceBookAccess.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method creates a component which can authenticate. You will receive either the
 * authentication key or an Exception object within the ActionListener callback method.
 * 
 * @param al a listener that will receive at its source either a token for the service or an exception in case of a failure
 * @return a component that should be displayed to the user in order to perform the authentication
 */
public Component createAuthComponent(final ActionListener al) {
    return createOAuth().createAuthComponent(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            if(evt.getSource() instanceof String){
                token = (String) evt.getSource();
            }
            al.actionPerformed(evt);
        }
    });
}
 
Example #26
Source Project: CodenameOne   Author: codenameone   File: UIBuilder.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a command listener
 *
 * @param l the listener to remove
 */
public void removeCommandListener(ActionListener l) {
    if(globalCommandListeners == null) {
        return;
    }
    globalCommandListeners.removeListener(l);
}
 
Example #27
Source Project: CodenameOne   Author: codenameone   File: NetworkManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds a listener to be notified when progress updates
 *
 * @param al action listener
 */
public void addProgressListener(ActionListener<NetworkEvent> al) {
    if(progressListeners == null) {
        progressListeners = new EventDispatcher();
        progressListeners.setBlocking(false);
    }
    progressListeners.addListener(al);
}
 
Example #28
Source Project: CodenameOne   Author: codenameone   File: SideMenuBar.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    if(Display.getInstance().isEdt()) {
        ActionEvent e = new ActionEvent(cmd, ActionEvent.Type.Command);
        if (cmd instanceof NavigationCommand) {
            parent.getContentPane().setVisible(true);
            final Form nextForm = ((NavigationCommand) cmd).getNextForm();
            if (nextForm != null) {
                final Transition out = parent.getTransitionOutAnimator();
                final Transition in = nextForm.getTransitionInAnimator();
                parent.setTransitionOutAnimator(CommonTransitions.createEmpty());
                nextForm.setTransitionInAnimator(CommonTransitions.createEmpty());
                nextForm.addShowListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        parent.setTransitionOutAnimator(out);
                        nextForm.setTransitionInAnimator(in);
                        nextForm.removeShowListener(this);
                    }
                });
            }
        }
        parent.dispatchCommand(cmd, e);

        return;
    }

    synchronized (LOCK) {
        while (Display.getInstance().getCurrent() != parent) {
            try {
                LOCK.wait(40);
            } catch (Exception ex) {
            }
        }
    }
    Display.getInstance().callSerially(this);
}
 
Example #29
Source Project: CodenameOne   Author: codenameone   File: UIManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a Theme refresh listener.
 * 
 * @param l an ActionListener to be removed
 */
public void removeThemeRefreshListener(ActionListener l) {

    if (themelisteners == null) {
        return;
    }
    themelisteners.removeListener(l);
}
 
Example #30
Source Project: CodenameOne   Author: codenameone   File: NetworkManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the given error listener
 *
 * @param e callback to remove
 */
public void removeErrorListener(ActionListener<NetworkEvent> e) {
    if(errorListeners == null) {
        return;
    }

    errorListeners.removeListener(e);
}