diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
index 0d6ec5b..59fb566 100644
--- a/.idea/deploymentTargetDropDown.xml
+++ b/.idea/deploymentTargetDropDown.xml
@@ -7,12 +7,12 @@
-
+
-
+
diff --git a/app-apk/app-debug.apk b/app-apk/app-debug.apk
index 61868c5..e8aa9d6 100644
Binary files a/app-apk/app-debug.apk and b/app-apk/app-debug.apk differ
diff --git a/app/src/main/java/com/udacity/project4/locationreminders/geofence/GeofenceBroadcastReceiver.kt b/app/src/main/java/com/udacity/project4/locationreminders/geofence/GeofenceBroadcastReceiver.kt
index 3574956..72cab31 100644
--- a/app/src/main/java/com/udacity/project4/locationreminders/geofence/GeofenceBroadcastReceiver.kt
+++ b/app/src/main/java/com/udacity/project4/locationreminders/geofence/GeofenceBroadcastReceiver.kt
@@ -32,22 +32,9 @@ class GeofenceBroadcastReceiver : BroadcastReceiver() {
Timber.e("GeoFence ${intent.extras.toString()}")
if (intent.action == ACTION_GEOFENCE_EVENT) {
val geofencingEvent: GeofencingEvent? = GeofencingEvent.fromIntent(intent)
-
if (geofencingEvent != null) {
- if (geofencingEvent.hasError()) {
- Timber.e(geofencingEvent.errorCode.toString())
- return
+ GeofenceTransitionsJobIntentService.enqueueWork(context, intent)
}
-
-
- Timber.e(geofencingEvent.triggeringGeofences.toString())
-
- if (geofencingEvent.geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) {
-
- GeofenceTransitionsJobIntentService.enqueueWork(context, intent)
- }
- }
-
}
}
diff --git a/app/src/main/java/com/udacity/project4/locationreminders/geofence/GeofenceTransitionsJobIntentService.kt b/app/src/main/java/com/udacity/project4/locationreminders/geofence/GeofenceTransitionsJobIntentService.kt
index e537d78..63b0aca 100644
--- a/app/src/main/java/com/udacity/project4/locationreminders/geofence/GeofenceTransitionsJobIntentService.kt
+++ b/app/src/main/java/com/udacity/project4/locationreminders/geofence/GeofenceTransitionsJobIntentService.kt
@@ -49,30 +49,26 @@ class GeofenceTransitionsJobIntentService : JobIntentService(), CoroutineScope {
return
}
Timber.e(geofencingEvent.triggeringGeofences.toString())
+ if (geofencingEvent.geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) {
+ val triggeredGeofence = geofencingEvent.triggeringGeofences
+ if(!triggeredGeofence.isNullOrEmpty()) {
+ sendNotification(triggeredGeofence.first())
+ }
- when (geofencingEvent.geofenceTransition) {
- Geofence.GEOFENCE_TRANSITION_ENTER -> {
- sendNotification(geofencingEvent.triggeringGeofences!!)
- }
}
+
+
}
- //TODO: get the request id of the current geofence
- private fun sendNotification(triggeringGeofences: List) {
- var requestId = ""
- for (geofence in triggeringGeofences) {
- Timber.e(geofence.requestId)
- requestId = geofence.requestId
- }
- //Get the local repository instance
+ private fun sendNotification(geofence: Geofence) {
+ //Get the local repository instance
val remindersLocalRepository: ReminderDataSource by inject()
// Interaction to the repository has to be through a coroutine scope
CoroutineScope(coroutineContext).launch(SupervisorJob()) {
//get the reminder with the request id
-
- val result = remindersLocalRepository.getReminder(requestId)
+ val result = remindersLocalRepository.getReminder(geofence.requestId)
if (result is Result.Success) {
val reminderDTO = result.data
//send a notification to the user with the reminder details