Cleaning. #88
@ -10,9 +10,7 @@ import kotlinx.datetime.toInstant
|
||||
import org.junit.Test
|
||||
|
||||
class DatesTest {
|
||||
private val appSettingsService = mockk<AppSettingsService>()
|
||||
|
||||
private val dateUtils: DateUtils = DateUtils(appSettingsService)
|
||||
private val dateUtils: DateUtils = DateUtils()
|
||||
|
||||
private val v3Date = "2013-04-07T13:43:00+01:00"
|
||||
private val v4Date = "2013-04-07 13:43:00"
|
||||
|
@ -1,6 +1,5 @@
|
||||
package bou.amine.apps.readerforselfossv2.repository
|
||||
|
||||
import bou.amine.apps.readerforselfossv2.dao.ITEM
|
||||
import bou.amine.apps.readerforselfossv2.dao.ReaderForSelfossDB
|
||||
import bou.amine.apps.readerforselfossv2.dao.SOURCE
|
||||
import bou.amine.apps.readerforselfossv2.dao.TAG
|
||||
|
@ -1,12 +1,10 @@
|
||||
package bou.amine.apps.readerforselfossv2.utils
|
||||
|
||||
import android.text.format.DateUtils
|
||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||
import kotlinx.datetime.*
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
|
||||
actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) {
|
||||
actual class DateUtils {
|
||||
|
||||
|
||||
actual fun parseDate(dateString: String): Long {
|
||||
return try {
|
||||
|
@ -11,7 +11,6 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
class Repository(private val api: SelfossApi, private val appSettingsService: AppSettingsService, val isConnectionAvailable: MutableStateFlow<Boolean>, private val db: ReaderForSelfossDB) {
|
||||
|
||||
@ -19,7 +18,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
var connectionMonitored = false
|
||||
|
||||
var baseUrl = appSettingsService.getBaseUrl()
|
||||
lateinit var dateUtils: DateUtils
|
||||
var dateUtils: DateUtils = DateUtils()
|
||||
|
||||
var displayedItems = ItemType.UNREAD
|
||||
|
||||
@ -394,7 +393,6 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
appSettingsService.updateApiVersion(fetchedVersion.data.getApiMajorVersion())
|
||||
}
|
||||
}
|
||||
dateUtils = DateUtils(appSettingsService)
|
||||
}
|
||||
|
||||
fun isNetworkAvailable() = isConnectionAvailable.value && !offlineOverride
|
||||
|
@ -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() {
|
||||
fun parseDate(dateString: String): Long
|
||||
|
||||
fun parseRelativeDate(dateString: String): String
|
||||
|
Loading…
Reference in New Issue
Block a user
Since DateUtils does not need to store any data, wouldn't it be better to just have it as two expect functions?
In this way we remove the need of instantiating the object within the repository.
Moreover, if I'm not mistaken one of the two is full kotlin and could thus be in the common source.
It is now.
I cleaned a little bit.