Search in sources :

Example 1 with LocationListener

use of com.codename1.location.LocationListener in project CodenameOne by codenameone.

the class IOSImplementation method locationUpdate.

/**
 * Callback for native
 */
public static void locationUpdate() {
    if (lm != null) {
        final LocationListener ls = lm.getActiveLocationListener();
        lm.setStatus();
        if (ls != null) {
            Display.getInstance().callSerially(new Runnable() {

                @Override
                public void run() {
                    ls.locationUpdated(lm.getCurrentLocation());
                }
            });
        }
    }
}
Also used : LocationListener(com.codename1.location.LocationListener)

Example 2 with LocationListener

use of com.codename1.location.LocationListener 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

LocationListener (com.codename1.location.LocationListener)2 Location (com.codename1.location.Location)1 IOException (java.io.IOException)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1