send the specific event timestamp to event activity
This commit is contained in:
parent
66a9c31830
commit
678d9e0d06
|
@ -29,6 +29,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
private var mRepeatLimit = 0
|
||||
private var mEventTypeId = DBHelper.REGULAR_EVENT_TYPE_ID
|
||||
private var mDialogTheme = 0
|
||||
private var mEventOccurrenceTS = 0
|
||||
|
||||
lateinit var mEventStartDateTime: DateTime
|
||||
lateinit var mEventEndDateTime: DateTime
|
||||
|
@ -45,6 +46,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
val event = DBHelper.newInstance(applicationContext).getEvent(eventId)
|
||||
if (event != null) {
|
||||
mEvent = event
|
||||
mEventOccurrenceTS = intent.getIntExtra(EVENT_OCCURRENCE_TS, 0)
|
||||
setupEditEvent()
|
||||
} else {
|
||||
mEvent = Event()
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.simplemobiletools.commons.extensions.beInvisibleIf
|
|||
import kotlinx.android.synthetic.main.event_list_item.view.*
|
||||
import java.util.*
|
||||
|
||||
class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>, val listener: DeleteItemsListener?, val itemClick: (Int) -> Unit) :
|
||||
class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>, val listener: DeleteItemsListener?, val itemClick: (Int, Int) -> Unit) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
val multiSelector = MultiSelector()
|
||||
val views = ArrayList<View>()
|
||||
|
@ -123,7 +123,7 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
|
|||
|
||||
override fun getItemCount() = mItems.size
|
||||
|
||||
class ViewHolder(val activity: SimpleActivity, view: View, val itemClick: (Int) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
|
||||
class ViewHolder(val activity: SimpleActivity, view: View, val itemClick: (Int, Int) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
|
||||
fun bindView(multiSelectorCallback: ModalMultiSelectorCallback, multiSelector: MultiSelector, listItem: ListItem, pos: Int): View {
|
||||
val item = listItem as ListEvent
|
||||
itemView.apply {
|
||||
|
@ -187,7 +187,8 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
|
|||
}
|
||||
actMode?.invalidate()
|
||||
} else {
|
||||
itemClick((listItem as ListEvent).id)
|
||||
val listEvent = listItem as ListEvent
|
||||
itemClick(listEvent.id, listEvent.startTS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,7 @@ import com.simplemobiletools.calendar.adapters.DayEventsAdapter
|
|||
import com.simplemobiletools.calendar.extensions.config
|
||||
import com.simplemobiletools.calendar.extensions.getAppropriateTheme
|
||||
import com.simplemobiletools.calendar.extensions.getFilteredEvents
|
||||
import com.simplemobiletools.calendar.helpers.DAY_CODE
|
||||
import com.simplemobiletools.calendar.helpers.DBHelper
|
||||
import com.simplemobiletools.calendar.helpers.EVENT_ID
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.interfaces.DeleteItemsListener
|
||||
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
||||
|
@ -122,7 +120,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents
|
|||
return
|
||||
|
||||
val eventsAdapter = DayEventsAdapter(activity as SimpleActivity, events, this) {
|
||||
editEvent(it.id)
|
||||
editEvent(it)
|
||||
}
|
||||
mHolder.day_events.apply {
|
||||
this@apply.adapter = eventsAdapter
|
||||
|
@ -130,9 +128,10 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents
|
|||
}
|
||||
}
|
||||
|
||||
private fun editEvent(eventId: Int) {
|
||||
private fun editEvent(event: Event) {
|
||||
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
||||
putExtra(EVENT_ID, eventId)
|
||||
putExtra(EVENT_OCCURRENCE_TS, event.startTS)
|
||||
putExtra(EVENT_ID, event.id)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.simplemobiletools.calendar.extensions.getFilteredEvents
|
|||
import com.simplemobiletools.calendar.extensions.seconds
|
||||
import com.simplemobiletools.calendar.helpers.DBHelper
|
||||
import com.simplemobiletools.calendar.helpers.EVENT_ID
|
||||
import com.simplemobiletools.calendar.helpers.EVENT_OCCURRENCE_TS
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.interfaces.DeleteItemsListener
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
|
@ -76,8 +77,8 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.Event
|
|||
listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.isAllDay))
|
||||
}
|
||||
|
||||
val eventsAdapter = EventListAdapter(activity as SimpleActivity, listItems, this) {
|
||||
editEvent(it)
|
||||
val eventsAdapter = EventListAdapter(activity as SimpleActivity, listItems, this) { eventId, eventTS ->
|
||||
editEvent(eventId, eventTS)
|
||||
}
|
||||
activity?.runOnUiThread {
|
||||
mView.calendar_events_list.apply {
|
||||
|
@ -94,8 +95,9 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.Event
|
|||
mView.calendar_empty_list_placeholder.setTextColor(activity.config.textColor)
|
||||
}
|
||||
|
||||
private fun editEvent(eventId: Int) {
|
||||
private fun editEvent(eventId: Int, eventTS: Int) {
|
||||
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
||||
putExtra(EVENT_OCCURRENCE_TS, eventTS)
|
||||
putExtra(EVENT_ID, eventId)
|
||||
startActivity(this)
|
||||
}
|
||||
|
|
|
@ -257,6 +257,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
}
|
||||
setOnClickListener {
|
||||
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
||||
putExtra(EVENT_OCCURRENCE_TS, event.startTS)
|
||||
putExtra(EVENT_ID, event.id)
|
||||
startActivity(this)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ val MEDIUM_ALPHA = .6f
|
|||
val DAY_CODE = "day_code"
|
||||
val YEAR_LABEL = "year"
|
||||
val EVENT_ID = "event_id"
|
||||
val EVENT_OCCURRENCE_TS = "event_occurrence_ts"
|
||||
val NEW_EVENT_START_TS = "new_event_start_ts"
|
||||
val WEEK_START_TIMESTAMP = "week_start_timestamp"
|
||||
val NEW_EVENT_SET_HOUR_DURATION = "new_event_set_hour_duration"
|
||||
|
|
|
@ -429,8 +429,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
val eventType = cursor.getIntValue(COL_EVENT_TYPE)
|
||||
if (flags and FLAG_ALL_DAY != 0)
|
||||
endTS -= 1
|
||||
events.add(Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes,
|
||||
repeatInterval, importId, flags, repeatLimit, eventType))
|
||||
|
||||
val event = Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes,
|
||||
repeatInterval, importId, flags, repeatLimit, eventType)
|
||||
events.add(event)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
} finally {
|
||||
|
|
Loading…
Reference in New Issue