Skip to content

Commit

Permalink
Changed id to String
Browse files Browse the repository at this point in the history
  • Loading branch information
radshag committed Feb 18, 2013
1 parent c087d24 commit a62c11a
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 94 deletions.
86 changes: 0 additions & 86 deletions android/Sample/GeofencingAndroidSample/assets/www/index.html~

This file was deleted.

Binary file modified android/Sample/GeofencingAndroidSample/bin/Geofencing.apk
Binary file not shown.
Binary file modified android/Sample/GeofencingAndroidSample/bin/classes.dex
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified android/Sample/GeofencingAndroidSample/bin/resources.ap_
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackCo
try {
if ("addRegion".equals(action)) {
JSONObject params = parseParameters(data);
int id = params.getInt("fid");
String id = params.getString("fid");
service.addRegion(id, params.getDouble("latitude"), params.getDouble("longitude"),
(float) params.getInt("radius"));
registerListener(id);
Expand All @@ -67,7 +67,7 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackCo
return true;
}
if ("getWatchedRegionIds".equals(action)) {
Set<Integer> watchedRegionIds = service.getWatchedRegionIds();
Set<String> watchedRegionIds = service.getWatchedRegionIds();
callbackContext.success(new JSONArray(watchedRegionIds));
}

Expand Down Expand Up @@ -126,7 +126,7 @@ private void addLocation(Location location, JSONObject object, String prefix) th
object.put(prefix + "_longitude", location.getLongitude());
}

private void registerListener(int id) {
private void registerListener(String id) {
IntentFilter filter = new IntentFilter(DGGeofencingService.PROXIMITY_ALERT_INTENT + id);
cordova.getActivity().registerReceiver(new BroadcastReceiver() {

Expand All @@ -141,12 +141,12 @@ private void fireRegionChangedEvent(Intent intent) {
Log.d("DGGeofencingService", "received proximity alert");

String status = intent.getBooleanExtra(KEY_PROXIMITY_ENTERING, false) ? "enter" : "left";
Integer id = (Integer) intent.getExtras().get("id");
String id = intent.getExtras().get("id").toString();

webView.loadUrl("javascript:DGGeofencing.regionMonitorUpdate(" + createRegionEvent(id, status) + ")");
}

private String createRegionEvent(Integer id, String status) {
private String createRegionEvent(String id, String status) {
return "{fid:" + id + ",status:\"" + status + "\"}";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public class DGGeofencingService extends Service implements LocationListener {

static final String PROXIMITY_ALERT_INTENT = "geoFencingProximityAlert";

private Map<Integer, PendingIntent> regionIdIntentMapping = new HashMap<Integer, PendingIntent>();
private Map<String, PendingIntent> regionIdIntentMapping = new HashMap<String, PendingIntent>();
private LocationManager locationManager;
private Set<LocationChangedListener> listeners = new HashSet<LocationChangedListener>();

public boolean isGpsEnabled() {
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}

public void addRegion(int id, double latitude, double longitude, float radius) {
public void addRegion(String id, double latitude, double longitude, float radius) {
Intent intent = new Intent(PROXIMITY_ALERT_INTENT + id);
intent.putExtra("id", id);
PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent, FLAG_ACTIVITY_NEW_TASK);
Expand Down Expand Up @@ -93,7 +93,7 @@ public IBinder onBind(Intent intent) {
return binder;
}

public Set<Integer> getWatchedRegionIds() {
public Set<String> getWatchedRegionIds() {
return regionIdIntentMapping.keySet();
}

Expand Down

0 comments on commit a62c11a

Please sign in to comment.