Compare commits
2 Commits
8b2be5c55c
...
109050d0cf
Author | SHA1 | Date | |
---|---|---|---|
|
109050d0cf | ||
|
0392e1b406 |
@ -8,14 +8,13 @@ import java.time.OffsetDateTime
|
|||||||
import java.time.ZoneOffset
|
import java.time.ZoneOffset
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
actual class DateUtils actual constructor(appSettingsService: AppSettingsService) {
|
actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) {
|
||||||
val ads: AppSettingsService = appSettingsService // TODO: why is this needed now ?
|
|
||||||
|
|
||||||
actual fun parseDate(dateString: String): Long {
|
actual fun parseDate(dateString: String): Long {
|
||||||
|
|
||||||
val FORMATTERV1 = "yyyy-MM-dd HH:mm:ss"
|
val FORMATTERV1 = "yyyy-MM-dd HH:mm:ss"
|
||||||
|
|
||||||
return if (ads.getApiVersion() >= 4) {
|
return if (appSettingsService.getApiVersion() >= 4) {
|
||||||
OffsetDateTime.parse(dateString).toInstant().toEpochMilli()
|
OffsetDateTime.parse(dateString).toInstant().toEpochMilli()
|
||||||
} else {
|
} else {
|
||||||
LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(FORMATTERV1)).toInstant(
|
LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(FORMATTERV1)).toInstant(
|
||||||
|
@ -69,7 +69,7 @@ class AppSettingsService {
|
|||||||
|
|
||||||
fun getUserName(): String {
|
fun getUserName(): String {
|
||||||
if (_userName.isEmpty()) {
|
if (_userName.isEmpty()) {
|
||||||
refrershUsername()
|
refreshUsername()
|
||||||
}
|
}
|
||||||
return _userName
|
return _userName
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ class AppSettingsService {
|
|||||||
_baseUrl = settings.getString("url", "")
|
_baseUrl = settings.getString("url", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun refrershUsername() {
|
private fun refreshUsername() {
|
||||||
_userName = settings.getString("login", "")
|
_userName = settings.getString("login", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ class AppSettingsService {
|
|||||||
|
|
||||||
fun refreshApiSettings() {
|
fun refreshApiSettings() {
|
||||||
refreshPassword()
|
refreshPassword()
|
||||||
refrershUsername()
|
refreshUsername()
|
||||||
refreshBaseUrl()
|
refreshBaseUrl()
|
||||||
refreshApiVersion()
|
refreshApiVersion()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
|||||||
fun SelfossModel.Item.parseDate(dateUtils: DateUtils): Long =
|
fun SelfossModel.Item.parseDate(dateUtils: DateUtils): Long =
|
||||||
dateUtils.parseDate(this.datetime)
|
dateUtils.parseDate(this.datetime)
|
||||||
|
|
||||||
expect class DateUtils(appSettingsService: AppSettingsService) {
|
expect class DateUtils constructor(appSettingsService: AppSettingsService) {
|
||||||
|
val appSettingsService: AppSettingsService // This is needed because of https://stackoverflow.com/a/65249085
|
||||||
|
|
||||||
fun parseDate(dateString: String): Long
|
fun parseDate(dateString: String): Long
|
||||||
|
|
||||||
fun parseRelativeDate(dateString: String): String
|
fun parseRelativeDate(dateString: String): String
|
||||||
|
@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.utils
|
|||||||
|
|
||||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||||
|
|
||||||
actual class DateUtils actual constructor(appSettingsService: AppSettingsService) {
|
actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) {
|
||||||
actual fun parseDate(dateString: String): Long {
|
actual fun parseDate(dateString: String): Long {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.utils
|
|||||||
|
|
||||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||||
|
|
||||||
actual class DateUtils actual constructor(appSettingsService: AppSettingsService) {
|
actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) {
|
||||||
actual fun parseDate(dateString: String): Long {
|
actual fun parseDate(dateString: String): Long {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user