Skip to content

Commit

Permalink
Quick widget fix
Browse files Browse the repository at this point in the history
  • Loading branch information
m-i-n-a-r committed Nov 14, 2022
1 parent a93cc05 commit 8c7c7e2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/src/main/java/com/minar/birday/widgets/EventWidgetService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import com.minar.birday.model.EventResult
import com.minar.birday.persistence.EventDao
import com.minar.birday.persistence.EventDatabase
import com.minar.birday.utilities.formatName
import com.minar.birday.utilities.getReducedDate
import com.minar.birday.utilities.getRemainingDays
import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle
import java.util.*


class EventWidgetService : RemoteViewsService() {
Expand Down Expand Up @@ -53,7 +55,15 @@ internal class EventWidgetRemoteViewsFactory(context: Context) : RemoteViewsFact
val formatter: DateTimeFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG)
val event = events[position]
rv.setTextViewText(R.id.eventWidgetRowPerson, formatName(events[position], surnameFirst))
rv.setTextViewText(R.id.eventWidgetRowDate, event.originalDate.format(formatter))
rv.setTextViewText(
R.id.eventWidgetRowDate,
if (event.yearMatter!!) event.originalDate.format(formatter)
else getReducedDate(event.originalDate).replaceFirstChar {
if (it.isLowerCase()) it.titlecase(
Locale.getDefault()
) else it.toString()
}
)
val remainingDays = getRemainingDays(event.nextDate!!)
rv.setTextViewText(
R.id.eventWidgetRowCountdown,
Expand Down

0 comments on commit 8c7c7e2

Please sign in to comment.