Fixed going to date from event list widget (#1607)
This commit is contained in:
parent
2090d81be2
commit
977e9aa7f6
|
@ -849,12 +849,13 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
currentFragments.clear()
|
||||
currentFragments.add(fragment)
|
||||
val bundle = Bundle()
|
||||
val fixedDayCode = fixDayCode(dayCode)
|
||||
|
||||
when (config.storedView) {
|
||||
DAILY_VIEW -> bundle.putString(DAY_CODE, dayCode ?: Formatter.getTodayCode())
|
||||
WEEKLY_VIEW -> bundle.putString(WEEK_START_DATE_TIME, dayCode ?: getDatesWeekDateTime(DateTime()))
|
||||
MONTHLY_VIEW, MONTHLY_DAILY_VIEW -> bundle.putString(DAY_CODE, dayCode ?: Formatter.getTodayCode())
|
||||
YEARLY_VIEW -> bundle.putString(YEAR_TO_OPEN, dayCode)
|
||||
DAILY_VIEW -> bundle.putString(DAY_CODE, fixedDayCode ?: Formatter.getTodayCode())
|
||||
WEEKLY_VIEW -> bundle.putString(WEEK_START_DATE_TIME, fixedDayCode ?: getDatesWeekDateTime(DateTime()))
|
||||
MONTHLY_VIEW, MONTHLY_DAILY_VIEW -> bundle.putString(DAY_CODE, fixedDayCode ?: Formatter.getTodayCode())
|
||||
YEARLY_VIEW -> bundle.putString(YEAR_TO_OPEN, fixedDayCode)
|
||||
}
|
||||
|
||||
fragment.arguments = bundle
|
||||
|
@ -862,6 +863,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
||||
}
|
||||
|
||||
private fun fixDayCode(dayCode: String? = null): String? = when {
|
||||
config.storedView == WEEKLY_VIEW && (dayCode?.length == Formatter.DAYCODE_PATTERN.length) -> getDatesWeekDateTime(Formatter.getDateTimeFromCode(dayCode))
|
||||
config.storedView == YEARLY_VIEW && (dayCode?.length == Formatter.DAYCODE_PATTERN.length) -> Formatter.getYearFromDayCode(dayCode)
|
||||
else -> dayCode
|
||||
}
|
||||
|
||||
fun openMonthFromYearly(dateTime: DateTime) {
|
||||
if (currentFragments.last() is MonthFragmentsHolder) {
|
||||
return
|
||||
|
|
|
@ -136,4 +136,6 @@ object Formatter {
|
|||
fun getUTCDayCodeFromTS(ts: Long) = getUTCDateTimeFromTS(ts).toString(DAYCODE_PATTERN)
|
||||
|
||||
fun getShiftedImportTimestamp(ts: Long) = getUTCDateTimeFromTS(ts).withTime(13, 0, 0, 0).withZoneRetainFields(DateTimeZone.getDefault()).seconds()
|
||||
|
||||
fun getYearFromDayCode(dayCode: String) = getDateTimeFromCode(dayCode).toString(YEAR_PATTERN)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue