Search in sources :

Example 1 with WiFiLocator

use of im.tny.segvault.s2ls.wifi.WiFiLocator in project underlx by underlx.

the class MainService method putNetwork.

private void putNetwork(final Network net) {
    synchronized (lock) {
        // create Realm stations for the network if they don't exist already
        Realm realm = Application.getDefaultRealmInstance(this);
        realm.executeTransaction(new Realm.Transaction() {

            @Override
            public void execute(Realm realm) {
                for (Station s : net.getStations()) {
                    if (realm.where(RStation.class).equalTo("id", s.getId()).count() == 0) {
                        RStation rs = new RStation();
                        rs.setStop(s);
                        rs.setNetwork(net.getId());
                        realm.copyToRealm(rs);
                    }
                }
            }
        });
        realm.close();
        net.setEdgeWeighter(cweighter);
        networks.put(net.getId(), net);
        S2LS loc = new S2LS(net, new S2LSChangeListener());
        locServices.put(net.getId(), loc);
        WiFiLocator wl = new WiFiLocator(net);
        wfc.setLocatorForNetwork(net, wl);
        loc.addNetworkDetector(wl);
        loc.addProximityDetector(wl);
        loc.addLocator(wl);
    }
}
Also used : RStation(im.tny.segvault.disturbances.model.RStation) Station(im.tny.segvault.subway.Station) S2LS(im.tny.segvault.s2ls.S2LS) RStation(im.tny.segvault.disturbances.model.RStation) Realm(io.realm.Realm) WiFiLocator(im.tny.segvault.s2ls.wifi.WiFiLocator)

Aggregations

RStation (im.tny.segvault.disturbances.model.RStation)1 S2LS (im.tny.segvault.s2ls.S2LS)1 WiFiLocator (im.tny.segvault.s2ls.wifi.WiFiLocator)1 Station (im.tny.segvault.subway.Station)1 Realm (io.realm.Realm)1