Compare commits

..

No commits in common. "109050d0cf9ca0ecd871a38f21354b70310fcc61" and "8b2be5c55c92387dd2283f24f77a098622182afc" have entirely different histories.

5 changed files with 9 additions and 10 deletions

View File

@ -8,13 +8,14 @@ import java.time.OffsetDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) {
actual class DateUtils actual constructor(appSettingsService: AppSettingsService) {
val ads: AppSettingsService = appSettingsService // TODO: why is this needed now ?
actual fun parseDate(dateString: String): Long {
val FORMATTERV1 = "yyyy-MM-dd HH:mm:ss"
return if (appSettingsService.getApiVersion() >= 4) {
return if (ads.getApiVersion() >= 4) {
OffsetDateTime.parse(dateString).toInstant().toEpochMilli()
} else {
LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(FORMATTERV1)).toInstant(

View File

@ -69,7 +69,7 @@ class AppSettingsService {
fun getUserName(): String {
if (_userName.isEmpty()) {
refreshUsername()
refrershUsername()
}
return _userName
}
@ -108,7 +108,7 @@ class AppSettingsService {
_baseUrl = settings.getString("url", "")
}
private fun refreshUsername() {
private fun refrershUsername() {
_userName = settings.getString("login", "")
}
@ -344,7 +344,7 @@ class AppSettingsService {
fun refreshApiSettings() {
refreshPassword()
refreshUsername()
refrershUsername()
refreshBaseUrl()
refreshApiVersion()
}

View File

@ -7,9 +7,7 @@ import bou.amine.apps.readerforselfossv2.service.AppSettingsService
fun SelfossModel.Item.parseDate(dateUtils: DateUtils): Long =
dateUtils.parseDate(this.datetime)
expect class DateUtils constructor(appSettingsService: AppSettingsService) {
val appSettingsService: AppSettingsService // This is needed because of https://stackoverflow.com/a/65249085
expect class DateUtils(appSettingsService: AppSettingsService) {
fun parseDate(dateString: String): Long
fun parseRelativeDate(dateString: String): String

View File

@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.utils
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) {
actual class DateUtils actual constructor(appSettingsService: AppSettingsService) {
actual fun parseDate(dateString: String): Long {
TODO("Not yet implemented")
}

View File

@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.utils
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) {
actual class DateUtils actual constructor(appSettingsService: AppSettingsService) {
actual fun parseDate(dateString: String): Long {
TODO("Not yet implemented")
}