unify event click handling a bit
This commit is contained in:
parent
c1850c7da8
commit
2d6f3f4907
|
@ -22,7 +22,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: DeleteEventsListener?, val itemClick: (Int, Int) -> Unit) :
|
||||
class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>, val listener: DeleteEventsListener?, val itemClick: (ListEvent) -> Unit) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
val multiSelector = MultiSelector()
|
||||
val views = ArrayList<View>()
|
||||
|
@ -142,7 +142,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, Int) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
|
||||
class ViewHolder(val activity: SimpleActivity, view: View, val itemClick: (ListEvent) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
|
||||
fun bindView(multiSelectorCallback: ModalMultiSelectorCallback, multiSelector: MultiSelector, listItem: ListItem, pos: Int): View {
|
||||
val item = listItem as ListEvent
|
||||
itemView.apply {
|
||||
|
@ -220,7 +220,7 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
|
|||
actMode?.invalidate()
|
||||
} else {
|
||||
val listEvent = listItem as ListEvent
|
||||
itemClick(listEvent.id, listEvent.startTS)
|
||||
itemClick(listEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,8 +83,8 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
|
|||
listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.isAllDay))
|
||||
}
|
||||
|
||||
val eventsAdapter = EventListAdapter(activity as SimpleActivity, listItems, this) { eventId, eventTS ->
|
||||
editEvent(eventId, eventTS)
|
||||
val eventsAdapter = EventListAdapter(activity as SimpleActivity, listItems, this) {
|
||||
editEvent(it)
|
||||
}
|
||||
activity?.runOnUiThread {
|
||||
mView.calendar_events_list.apply {
|
||||
|
@ -101,10 +101,10 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
|
|||
mView.calendar_empty_list_placeholder.setTextColor(activity.config.textColor)
|
||||
}
|
||||
|
||||
private fun editEvent(eventId: Int, eventTS: Int) {
|
||||
private fun editEvent(event: ListEvent) {
|
||||
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
||||
putExtra(EVENT_OCCURRENCE_TS, eventTS)
|
||||
putExtra(EVENT_ID, eventId)
|
||||
putExtra(EVENT_OCCURRENCE_TS, event.startTS)
|
||||
putExtra(EVENT_ID, event.id)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue