Inject dateUtils

This commit is contained in:
davide 2022-08-14 13:00:37 +02:00
parent 7f8d04618a
commit baa4b81e77
5 changed files with 6 additions and 8 deletions

View File

@ -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

View File

@ -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()) {

View File

@ -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()

View File

@ -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<SelfossModel.Item>
var baseUrl: String
var dateUtils: DateUtils
var displayedItems: String

View File

@ -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) {