make sure the events in day view are sorted by start time

This commit is contained in:
tibbi 2016-11-19 17:07:32 +01:00
parent ff1e2e3bb9
commit 8e4388c749
2 changed files with 4 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import com.simplemobiletools.calendar.models.Event
import kotlinx.android.synthetic.main.day_fragment.view.* import kotlinx.android.synthetic.main.day_fragment.view.*
import kotlinx.android.synthetic.main.top_navigation.view.* import kotlinx.android.synthetic.main.top_navigation.view.*
import java.util.* import java.util.*
import kotlin.comparisons.compareBy
class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClickListener, AbsListView.MultiChoiceModeListener, DBHelper.GetEventsListener { class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClickListener, AbsListView.MultiChoiceModeListener, DBHelper.GetEventsListener {
@ -232,8 +233,9 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
} }
override fun gotEvents(events: MutableList<Event>) { override fun gotEvents(events: MutableList<Event>) {
val sorted = ArrayList<Event>(events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description })))
activity?.runOnUiThread { activity?.runOnUiThread {
updateEvents(events) updateEvents(sorted)
} }
} }

View File

@ -63,7 +63,7 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On
override fun gotEvents(events: MutableList<Event>) { override fun gotEvents(events: MutableList<Event>) {
val filtered = getEventsToShow(events) val filtered = getEventsToShow(events)
mListItems = ArrayList<ListItem>(filtered.size) mListItems = ArrayList<ListItem>(filtered.size)
val sorted = filtered.sortedWith(compareBy({ it.startTS }, { it.endTS })) val sorted = filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description }))
var prevCode = "" var prevCode = ""
sorted.forEach { sorted.forEach {
val code = Formatter.getDayCodeFromTS(it.startTS) val code = Formatter.getDayCodeFromTS(it.startTS)