use the general EVENT_ID constant at NotificationReceiver

This commit is contained in:
tibbi 2016-11-17 20:45:51 +01:00
parent 412e796abb
commit 7809f4282b
3 changed files with 6 additions and 9 deletions

View File

@ -19,9 +19,9 @@ import org.joda.time.DateTime
import org.joda.time.DateTimeZone
class EventActivity : SimpleActivity(), DBHelper.EventsListener {
private var mWasReminderInit: Boolean = false
private var mWasEndDateSet: Boolean = false
private var mWasEndTimeSet: Boolean = false
private var mWasReminderInit = false
private var mWasEndDateSet = false
private var mWasEndTimeSet = false
lateinit var mEventStartDateTime: DateTime
lateinit var mEventEndDateTime: DateTime

View File

@ -75,6 +75,6 @@ fun Context.scheduleEventIn(notifTS: Int, event: Event) {
private fun getNotificationIntent(context: Context, eventId: Int): PendingIntent {
val intent = Intent(context, NotificationReceiver::class.java)
intent.putExtra(NotificationReceiver.EVENT_ID, eventId)
intent.putExtra(EVENT_ID, eventId)
return PendingIntent.getBroadcast(context, eventId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}

View File

@ -11,14 +11,11 @@ import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.EventActivity
import com.simplemobiletools.calendar.extensions.scheduleNextEvent
import com.simplemobiletools.calendar.helpers.DBHelper
import com.simplemobiletools.calendar.helpers.EVENT_ID
import com.simplemobiletools.calendar.helpers.Formatter
import com.simplemobiletools.calendar.models.Event
class NotificationReceiver : BroadcastReceiver() {
companion object {
var EVENT_ID = "event_id"
}
override fun onReceive(context: Context, intent: Intent) {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val id = intent.getIntExtra(EVENT_ID, -1)
@ -44,7 +41,7 @@ class NotificationReceiver : BroadcastReceiver() {
private fun getPendingIntent(context: Context, event: Event): PendingIntent {
val intent = Intent(context, EventActivity::class.java)
intent.putExtra(EVENT_ID, event)
intent.putExtra(EVENT_ID, event.id)
return PendingIntent.getActivity(context, event.id, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}