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 kotlinx.android.synthetic.main.event_list_item.view.*
|
||||||
import java.util.*
|
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>() {
|
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||||
val multiSelector = MultiSelector()
|
val multiSelector = MultiSelector()
|
||||||
val views = ArrayList<View>()
|
val views = ArrayList<View>()
|
||||||
|
@ -142,7 +142,7 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
|
||||||
|
|
||||||
override fun getItemCount() = mItems.size
|
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 {
|
fun bindView(multiSelectorCallback: ModalMultiSelectorCallback, multiSelector: MultiSelector, listItem: ListItem, pos: Int): View {
|
||||||
val item = listItem as ListEvent
|
val item = listItem as ListEvent
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
|
@ -220,7 +220,7 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
|
||||||
actMode?.invalidate()
|
actMode?.invalidate()
|
||||||
} else {
|
} else {
|
||||||
val listEvent = listItem as ListEvent
|
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))
|
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 ->
|
val eventsAdapter = EventListAdapter(activity as SimpleActivity, listItems, this) {
|
||||||
editEvent(eventId, eventTS)
|
editEvent(it)
|
||||||
}
|
}
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
mView.calendar_events_list.apply {
|
mView.calendar_events_list.apply {
|
||||||
|
@ -101,10 +101,10 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
|
||||||
mView.calendar_empty_list_placeholder.setTextColor(activity.config.textColor)
|
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 {
|
Intent(activity.applicationContext, EventActivity::class.java).apply {
|
||||||
putExtra(EVENT_OCCURRENCE_TS, eventTS)
|
putExtra(EVENT_OCCURRENCE_TS, event.startTS)
|
||||||
putExtra(EVENT_ID, eventId)
|
putExtra(EVENT_ID, event.id)
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue