fix #643, always properly determine which layout show be used at list views
This commit is contained in:
parent
a9e7dec84f
commit
d89a1043ea
|
@ -76,6 +76,14 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
val detailField = if (replaceDescriptionWithLocation) event.location else event.description
|
||||
return if (event.startTS == event.endTS && detailField.isEmpty()) {
|
||||
ITEM_EVENT_SIMPLE
|
||||
} else if (event.getIsAllDay()) {
|
||||
val startCode = Formatter.getDayCodeFromTS(event.startTS)
|
||||
val endCode = Formatter.getDayCodeFromTS(event.endTS)
|
||||
if (startCode == endCode) {
|
||||
ITEM_EVENT_SIMPLE
|
||||
} else {
|
||||
ITEM_EVENT
|
||||
}
|
||||
} else {
|
||||
ITEM_EVENT
|
||||
}
|
||||
|
@ -94,7 +102,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
val startCode = Formatter.getDayCodeFromTS(event.startTS)
|
||||
val endCode = Formatter.getDayCodeFromTS(event.endTS)
|
||||
|
||||
event_item_end.apply {
|
||||
event_item_end?.apply {
|
||||
text = Formatter.getTimeFromTS(context, event.endTS)
|
||||
if (startCode != endCode) {
|
||||
if (event.getIsAllDay()) {
|
||||
|
|
|
@ -102,6 +102,14 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
|
|||
val detailField = if (replaceDescription) event.location else event.description
|
||||
if (event.startTS == event.endTS && detailField.isEmpty()) {
|
||||
ITEM_EVENT_SIMPLE
|
||||
} else if (event.isAllDay) {
|
||||
val startCode = Formatter.getDayCodeFromTS(event.startTS)
|
||||
val endCode = Formatter.getDayCodeFromTS(event.endTS)
|
||||
if (startCode == endCode) {
|
||||
ITEM_EVENT_SIMPLE
|
||||
} else {
|
||||
ITEM_EVENT
|
||||
}
|
||||
} else {
|
||||
ITEM_EVENT
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||
|
||||
if (type == ITEM_EVENT) {
|
||||
val event = events[position] as ListEvent
|
||||
val detailField = if (replaceDescription) event.location else event.description
|
||||
val layout = if (event.startTS == event.endTS && detailField.isEmpty()) R.layout.event_list_item_widget_simple else R.layout.event_list_item_widget
|
||||
val layout = getItemViewLayout(event)
|
||||
remoteView = RemoteViews(context.packageName, layout)
|
||||
setupListEvent(remoteView, event)
|
||||
} else {
|
||||
|
@ -53,6 +52,23 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||
return remoteView
|
||||
}
|
||||
|
||||
fun getItemViewLayout(event: ListEvent): Int {
|
||||
val detailField = if (replaceDescription) event.location else event.description
|
||||
return if (event.startTS == event.endTS && detailField.isEmpty()) {
|
||||
R.layout.event_list_item_widget_simple
|
||||
} else if (event.isAllDay) {
|
||||
val startCode = Formatter.getDayCodeFromTS(event.startTS)
|
||||
val endCode = Formatter.getDayCodeFromTS(event.endTS)
|
||||
if (startCode == endCode) {
|
||||
R.layout.event_list_item_widget_simple
|
||||
} else {
|
||||
R.layout.event_list_item_widget
|
||||
}
|
||||
} else {
|
||||
R.layout.event_list_item_widget
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupListEvent(remoteView: RemoteViews, item: ListEvent) {
|
||||
var curTextColor = textColor
|
||||
remoteView.apply {
|
||||
|
|
Loading…
Reference in New Issue