mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 22:01:42 +08:00
namespaces removed (except Application)
This commit is contained in:
@ -1,88 +1,84 @@
|
||||
import types_module = require("Location/location_types");
|
||||
import app_module = require("Application/application");
|
||||
|
||||
export module tk {
|
||||
export module location {
|
||||
export class LocationManager {
|
||||
export class LocationManager {
|
||||
|
||||
//public regions: LocationRegion[];
|
||||
//public regions: LocationRegion[];
|
||||
|
||||
private _locationManager: any;
|
||||
private _locationListener: android.location.LocationListener;
|
||||
private _locationManager: any;
|
||||
private _locationListener: android.location.LocationListener;
|
||||
|
||||
public isLocationEnabled(): boolean {
|
||||
// TODO add proper implementation
|
||||
return true;
|
||||
public isLocationEnabled(): boolean {
|
||||
// TODO add proper implementation
|
||||
return true;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
//this.regions = [];
|
||||
this.desiredAccuracy = types_module.DesiredAccuracy.ANY;
|
||||
this._locationManager = app_module.tk.ui.Application.current.android.context.getSystemService('location');
|
||||
Log('location manager: ' + this._locationManager);
|
||||
|
||||
this._locationListener = new android.location.LocationListener({
|
||||
onLocationChanged: function (location: android.location.Location) {
|
||||
},
|
||||
|
||||
onProviderDisabled: function (provider: string) {
|
||||
},
|
||||
|
||||
onProviderEnabled: function (provider: string) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
constructor() {
|
||||
//this.regions = [];
|
||||
this.desiredAccuracy = types_module.tk.location.DesiredAccuracy.ANY;
|
||||
this._locationManager = app_module.tk.ui.Application.current.android.context.getSystemService('location');
|
||||
Log('location manager: ' + this._locationManager);
|
||||
// in meters
|
||||
// we might need some predefined values here like 'any' and 'high'
|
||||
public desiredAccuracy: number;
|
||||
|
||||
this._locationListener = new android.location.LocationListener({
|
||||
onLocationChanged: function (location: android.location.Location) {
|
||||
},
|
||||
// listeners
|
||||
public locationChangeListener: types_module.LocationChangeListener;
|
||||
|
||||
onProviderDisabled: function (provider: string) {
|
||||
},
|
||||
|
||||
onProviderEnabled: function (provider: string) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// in meters
|
||||
// we might need some predefined values here like 'any' and 'high'
|
||||
public desiredAccuracy: number;
|
||||
|
||||
// listeners
|
||||
public locationChangeListener: types_module.tk.location.LocationChangeListener;
|
||||
|
||||
// public regionChangeListener: RegionChangeListener;
|
||||
// public regionChangeListener: RegionChangeListener;
|
||||
|
||||
|
||||
/* // regions
|
||||
public addRegion(region: LocationRegion) {
|
||||
this.regions.push(region);
|
||||
}
|
||||
/* // regions
|
||||
public addRegion(region: LocationRegion) {
|
||||
this.regions.push(region);
|
||||
}
|
||||
|
||||
public removeRegion(region: LocationRegion) {
|
||||
public removeRegion(region: LocationRegion) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public clearRegions() {
|
||||
public clearRegions() {
|
||||
|
||||
}*/
|
||||
}*/
|
||||
|
||||
// monitoring
|
||||
// monitoring
|
||||
|
||||
public startLocationMonitoring() {
|
||||
var criteria = new android.location.Criteria();
|
||||
criteria.setAccuracy((this.desiredAccuracy === types_module.tk.location.DesiredAccuracy.HIGH) ? 3 : 1);
|
||||
var providers = this._locationManager.getProviders(criteria, false);
|
||||
var it = providers.iterator();
|
||||
while (it.hasNext()) {
|
||||
var element = it.next();
|
||||
Log('found provider: ' + element);
|
||||
this._locationManager.requestLocationUpdates(element, 200, 10, this._locationListener);
|
||||
}
|
||||
}
|
||||
|
||||
public stopLocationMonitoring() {
|
||||
this._locationManager.removeUpdates(this._locationListener);
|
||||
}
|
||||
|
||||
// other
|
||||
|
||||
public getLastKnownLocation(): types_module.tk.location.LocationPoint {
|
||||
return null;
|
||||
}
|
||||
|
||||
public distanceInMeters(loc1: types_module.tk.location.LocationPoint, loc2: types_module.tk.location.LocationPoint): number {
|
||||
return 0;
|
||||
}
|
||||
public startLocationMonitoring() {
|
||||
var criteria = new android.location.Criteria();
|
||||
criteria.setAccuracy((this.desiredAccuracy === types_module.DesiredAccuracy.HIGH) ? 3 : 1);
|
||||
var providers = this._locationManager.getProviders(criteria, false);
|
||||
var it = providers.iterator();
|
||||
while (it.hasNext()) {
|
||||
var element = it.next();
|
||||
Log('found provider: ' + element);
|
||||
this._locationManager.requestLocationUpdates(element, 200, 10, this._locationListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public stopLocationMonitoring() {
|
||||
this._locationManager.removeUpdates(this._locationListener);
|
||||
}
|
||||
|
||||
// other
|
||||
|
||||
public getLastKnownLocation(): types_module.LocationPoint {
|
||||
return null;
|
||||
}
|
||||
|
||||
public distanceInMeters(loc1: types_module.LocationPoint, loc2: types_module.LocationPoint): number {
|
||||
return 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user