From c6e1ff21644083787bc14642c8e2c1a4b4ad4e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sun, 29 Mar 2020 15:26:48 +0200 Subject: [PATCH] [Events] Fix event sorting. Fix showing event teacher name. --- .../java/pl/szczodrzynski/edziennik/data/db/dao/EventDao.kt | 2 +- .../pl/szczodrzynski/edziennik/data/db/full/EventFull.kt | 2 +- .../edziennik/ui/dialogs/event/EventDetailsDialog.kt | 4 ++-- .../edziennik/ui/dialogs/event/EventListAdapter.kt | 4 ++-- .../edziennik/ui/modules/agenda/AgendaFragment.kt | 2 +- .../edziennik/ui/modules/homework/HomeworkAdapter.java | 2 +- app/src/main/res/layout/dialog_event_details.xml | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/EventDao.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/EventDao.kt index e90353b5..4ab8d15f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/EventDao.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/dao/EventDao.kt @@ -33,7 +33,7 @@ abstract class EventDao : BaseDao { LEFT JOIN metadata ON eventId = thingId AND (thingType = ${Metadata.TYPE_EVENT} OR thingType = ${Metadata.TYPE_HOMEWORK}) AND metadata.profileId = events.profileId """ - private const val ORDER_BY = """GROUP BY eventId ORDER BY addedDate ASC""" + private const val ORDER_BY = """GROUP BY eventId ORDER BY eventDate, eventTime, addedDate ASC""" private const val NOT_BLACKLISTED = """events.eventBlacklisted = 0""" } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/full/EventFull.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/full/EventFull.kt index 16a6a5c3..a3dcc2cb 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/db/full/EventFull.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/db/full/EventFull.kt @@ -40,7 +40,7 @@ class EventFull( var typeName: String? = null var typeColor: Int? = null - var teacherFullName: String? = null + var teacherName: String? = null var subjectLongName: String? = null var subjectShortName: String? = null var teamName: String? = null diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventDetailsDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventDetailsDialog.kt index b31edc01..a5a682c6 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventDetailsDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventDetailsDialog.kt @@ -102,14 +102,14 @@ class EventDetailsDialog( when (event.sharedBy) { null -> when { event.addedManually -> R.string.event_details_added_by_self_format - event.teacherFullName == null -> R.string.event_details_added_by_unknown_format + event.teacherName == null -> R.string.event_details_added_by_unknown_format else -> R.string.event_details_added_by_format } "self" -> R.string.event_details_shared_by_self_format else -> R.string.event_details_shared_by_format }, Date.fromMillis(event.addedDate).formattedString, - event.sharedByName ?: event.teacherFullName ?: "" + event.sharedByName ?: event.teacherName ?: "" ) b.editButton.visibility = if (event.addedManually) View.VISIBLE else View.GONE diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventListAdapter.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventListAdapter.kt index 6f4f6eba..64c4b6ce 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventListAdapter.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/event/EventListAdapter.kt @@ -61,14 +61,14 @@ class EventListAdapter( when (event.sharedBy) { null -> when { event.addedManually -> R.string.event_list_added_by_self_format - event.teacherFullName == null -> R.string.event_list_added_by_unknown_format + event.teacherName == null -> R.string.event_list_added_by_unknown_format else -> R.string.event_list_added_by_format } "self" -> R.string.event_list_shared_by_self_format else -> R.string.event_list_shared_by_format }, Date.fromMillis(event.addedDate).formattedString, - event.sharedByName ?: event.teacherFullName ?: "", + event.sharedByName ?: event.teacherName ?: "", event.teamName?.let { bullet+it } ?: "" ) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.kt index 6395fa8c..9ee93be9 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.kt @@ -226,7 +226,7 @@ class AgendaFragment : Fragment(), CoroutineScope { "", (if (event.time == null) getString(R.string.agenda_event_all_day) else event.time!!.stringHM) + (event.subjectLongName?.let { ", $it" } ?: "") + - (event.teacherFullName?.let { ", $it" } ?: "") + + (event.teacherName?.let { ", $it" } ?: "") + (event.teamName?.let { ", $it" } ?: ""), event.eventColor, Colors.legibleTextColor(event.eventColor), diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkAdapter.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkAdapter.java index b017543b..0a568464 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkAdapter.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkAdapter.java @@ -54,7 +54,7 @@ public class HomeworkAdapter extends RecyclerView.Adapter + android:visibility="@{event.teacherName != null ? View.VISIBLE : View.GONE}"/>