Search in sources :

Example 16 with Log

use of com.codename1.io.Log in project CodenameOne by codenameone.

the class TestUtils method pointerDrag.

/**
 * A component drag on a given named component at x/y where x and y are <b>NOT pixels</b>
 * but rather a number between 0 to 1 representing the percentage within the component where the
 * event took place. E.g. For a 100x100 component a press within 10,5 would be 0.1f, 0.05f.
 * @param x the offset within the component as a number between 0 and 1
 * @param y the offset within the component as a number between 0 and 1
 * @param path the path to the component
 */
public static void pointerDrag(float x, float y, int[] path) {
    if (verbose) {
        log("pointerDrag(" + x + ", " + y + ", " + toString(path) + ")");
    }
    Component c = getComponentByPath(path);
    int actualX = c.getAbsoluteX() + (int) (x * c.getWidth());
    int actualY = c.getAbsoluteY() + (int) (y * c.getHeight());
    Display.getInstance().getCurrent().pointerDragged(actualX, actualY);
}
Also used : Component(com.codename1.ui.Component)

Example 17 with Log

use of com.codename1.io.Log in project CodenameOne by codenameone.

the class TestComponent method getComponentAt_int_int_button.

private void getComponentAt_int_int_button() {
    log("Testing getComponentAt(x, y) with button");
    int w = Display.getInstance().getDisplayWidth();
    int h = Display.getInstance().getDisplayHeight();
    Form f = new Form("My Form", new BorderLayout());
    Label l = new Button("Hello");
    f.add(BorderLayout.CENTER, l);
    f.show();
    TestUtils.waitForFormTitle("My Form");
    Component middleComponent = f.getComponentAt(w / 2, h / 2);
    assertEqual(l, middleComponent, "Found wrong component");
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout)

Example 18 with Log

use of com.codename1.io.Log in project CodenameOne by codenameone.

the class TestComponent method getComponentAt_int_int_label.

private void getComponentAt_int_int_label() {
    log("Testing getComponentAt(x, y) with label");
    int w = Display.getInstance().getDisplayWidth();
    int h = Display.getInstance().getDisplayHeight();
    Form f = new Form("My Form", new BorderLayout());
    Label l = new Label("Hello");
    f.add(BorderLayout.CENTER, l);
    f.show();
    TestUtils.waitForFormTitle("My Form", 2000);
    Component middleComponent = f.getComponentAt(w / 2, h / 2);
    assertEqual(l, middleComponent, "Found wrong component");
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout)

Example 19 with Log

use of com.codename1.io.Log in project CodenameOne by codenameone.

the class FaceBookAccess method logOut.

/**
 * log out the current user
 */
public static void logOut() {
    ConnectionRequest req = new ConnectionRequest();
    req.setPost(false);
    req.setUrl("https://www.facebook.com/logout.php?access_token=" + token + "&confirm=1&next=" + redirectURI);
    NetworkManager.getInstance().addToQueueAndWait(req);
    token = null;
}
Also used : ConnectionRequest(com.codename1.io.ConnectionRequest)

Example 20 with Log

use of com.codename1.io.Log in project CodenameOne by codenameone.

the class StubLocationManager method bindListener.

@Override
protected void bindListener() {
    checkLocationRegistration();
    setStatus(AVAILABLE);
    final LocationListener l = getLocationListener();
    task = new TimerTask() {

        @Override
        public void run() {
            Display.getInstance().callSerially(new Runnable() {

                public void run() {
                    Location loc;
                    try {
                        loc = getCurrentLocation();
                        if (JavaSEPort.locSimulation == null) {
                            loc.setLongitude(loc.getLongitude() + 0.001);
                            loc.setLatitude(loc.getLatitude() + +0.001);
                        } else {
                            int s = JavaSEPort.locSimulation.getState();
                            if (s != StubLocationManager.super.getStatus()) {
                                l.providerStateChanged(s);
                                setStatus(s);
                            }
                        }
                        l.locationUpdated(loc);
                    } catch (IOException ex) {
                        Logger.getLogger(StubLocationManager.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });
        }
    };
    timer = new Timer();
    timer.schedule(task, 3000, 3000);
}
Also used : TimerTask(java.util.TimerTask) Timer(java.util.Timer) LocationListener(com.codename1.location.LocationListener) IOException(java.io.IOException) Location(com.codename1.location.Location)

Aggregations

Component (com.codename1.ui.Component)9 IOException (java.io.IOException)9 TextArea (com.codename1.ui.TextArea)8 Label (com.codename1.ui.Label)4 InputStream (java.io.InputStream)4 Button (com.codename1.ui.Button)3 Form (com.codename1.ui.Form)3 BorderLayout (com.codename1.ui.layouts.BorderLayout)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ParseException (java.text.ParseException)3 Date (java.util.Date)3 TimerTask (java.util.TimerTask)3 Cursor (android.database.Cursor)2 Address (com.codename1.contacts.Address)2 Contact (com.codename1.contacts.Contact)2 BufferedInputStream (com.codename1.io.BufferedInputStream)2 Location (com.codename1.location.Location)2 Command (com.codename1.ui.Command)2 ActionEvent (com.codename1.ui.events.ActionEvent)2 SimpleDateFormat (java.text.SimpleDateFormat)2