pass EventActivity only the event ID
This commit is contained in:
parent
53550a6471
commit
e043e1b814
|
@ -7,7 +7,7 @@ public class Constants {
|
|||
|
||||
public static final String DAY_CODE = "day_code";
|
||||
public static final String YEAR_LABEL = "year";
|
||||
public static final String EVENT = "event";
|
||||
public static final String EVENT_ID = "event_id";
|
||||
|
||||
public static final int MONTHLY_VIEW = 1;
|
||||
public static final int YEARLY_VIEW = 2;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class NotificationReceiver extends BroadcastReceiver {
|
|||
|
||||
private PendingIntent getPendingIntent(Context context, Event event) {
|
||||
final Intent intent = new Intent(context, EventActivity.class);
|
||||
intent.putExtra(Constants.EVENT, event);
|
||||
intent.putExtra(Constants.EVENT_ID, event);
|
||||
return PendingIntent.getActivity(context, event.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ class EventActivity : SimpleActivity(), DBHelper.EventsListener {
|
|||
val intent = intent ?: return
|
||||
|
||||
mWasReminderInit = false
|
||||
val event = intent.getSerializableExtra(Constants.EVENT) as Event?
|
||||
val eventId = intent.getIntExtra(Constants.EVENT_ID, 0)
|
||||
val event = DBHelper(applicationContext).getEvent(eventId)
|
||||
if (event != null) {
|
||||
mEvent = event
|
||||
setupEditEvent()
|
||||
|
|
|
@ -136,9 +136,9 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
|
|||
}
|
||||
}
|
||||
|
||||
private fun editEvent(event: Event) {
|
||||
private fun editEvent(eventId: Int) {
|
||||
val intent = Intent(activity.applicationContext, EventActivity::class.java)
|
||||
intent.putExtra(Constants.EVENT, event)
|
||||
intent.putExtra(Constants.EVENT_ID, eventId)
|
||||
startActivityForResult(intent, EDIT_EVENT)
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
|
|||
}
|
||||
|
||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||
editEvent(getEventsToShow(mEvents!!)[position])
|
||||
editEvent(getEventsToShow(mEvents!!)[position].id)
|
||||
}
|
||||
|
||||
override fun eventInserted(event: Event) {
|
||||
|
|
Loading…
Reference in New Issue