From baa4b81e77677c251a28090de67f8559c86d68aa Mon Sep 17 00:00:00 2001 From: davide Date: Sun, 14 Aug 2022 13:00:37 +0200 Subject: [PATCH] Inject dateUtils --- .../readerforselfossv2/android/adapters/ItemCardAdapter.kt | 3 +-- .../readerforselfossv2/android/adapters/ItemListAdapter.kt | 4 +--- .../readerforselfossv2/android/fragments/ArticleFragment.kt | 3 +-- .../amine/apps/readerforselfossv2/repository/Repository.kt | 2 ++ .../apps/readerforselfossv2/repository/RepositoryImpl.kt | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt index 0e9bf0f..2cdd01b 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt @@ -19,7 +19,6 @@ import bou.amine.apps.readerforselfossv2.android.utils.glide.circularBitmapDrawa import bou.amine.apps.readerforselfossv2.android.utils.network.isNetworkAvailable import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.rest.SelfossModel -import bou.amine.apps.readerforselfossv2.utils.DateUtils import com.amulyakhare.textdrawable.TextDrawable import com.amulyakhare.textdrawable.util.ColorGenerator import com.bumptech.glide.Glide @@ -67,7 +66,7 @@ class ItemCardAdapter( binding.title.setLinkTextColor(appColors.colorAccent) - binding.sourceTitleAndDate.text = itm.sourceAndDateText(DateUtils(repository.apiMajorVersion)) + binding.sourceTitleAndDate.text = itm.sourceAndDateText(repository.dateUtils) if (!fullHeightCards) { binding.itemImage.maxHeight = imageMaxHeight diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt index 94fa9dc..8efbc7f 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt @@ -15,8 +15,6 @@ import bou.amine.apps.readerforselfossv2.android.utils.glide.bitmapCenterCrop import bou.amine.apps.readerforselfossv2.android.utils.glide.circularBitmapDrawable import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.rest.SelfossModel -import bou.amine.apps.readerforselfossv2.service.SearchService -import bou.amine.apps.readerforselfossv2.utils.DateUtils import com.amulyakhare.textdrawable.TextDrawable import com.amulyakhare.textdrawable.util.ColorGenerator import org.kodein.di.DI @@ -56,7 +54,7 @@ class ItemListAdapter( binding.title.setLinkTextColor(appColors.colorAccent) - binding.sourceTitleAndDate.text = itm.sourceAndDateText(DateUtils(repository.apiMajorVersion)) + binding.sourceTitleAndDate.text = itm.sourceAndDateText(repository.dateUtils) if (itm.getThumbnail(repository.baseUrl).isEmpty()) { diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt index 06e4904..0deb6a1 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt @@ -38,7 +38,6 @@ import bou.amine.apps.readerforselfossv2.android.utils.glide.loadMaybeBasicAuth import bou.amine.apps.readerforselfossv2.android.utils.network.isNetworkAvailable import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.rest.SelfossModel -import bou.amine.apps.readerforselfossv2.utils.DateUtils import bou.amine.apps.readerforselfossv2.utils.isEmptyOrNullOrNullString import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy @@ -124,7 +123,7 @@ class ArticleFragment : Fragment(), DIAware { contentText = item.content contentTitle = item.getTitleDecoded() contentImage = item.getThumbnail(repository.baseUrl) - contentSource = item.sourceAndDateText(DateUtils(repository.apiMajorVersion)) + contentSource = item.sourceAndDateText(repository.dateUtils) allImages = item.getImages() fontSize = settings.getString("reader_font_size", "16").toInt() diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt index be225f8..c1dc7b1 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt @@ -1,12 +1,14 @@ package bou.amine.apps.readerforselfossv2.repository import bou.amine.apps.readerforselfossv2.rest.SelfossModel +import bou.amine.apps.readerforselfossv2.utils.DateUtils interface Repository { // TODO: remove the items variables in favor of storing everything in the database var items: ArrayList var baseUrl: String + var dateUtils: DateUtils var displayedItems: String diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index cc651d9..dc70a30 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -18,7 +18,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet set(value) { field = ArrayList(value) } override var baseUrl = apiDetails.getBaseUrl() - private lateinit var dateUtils: DateUtils + override lateinit var dateUtils: DateUtils override var displayedItems = "unread" set(value) {