Remove StatsData.casedLabel

just use the regular label and uppercase it
This commit is contained in:
Jays2Kings 2022-12-16 18:53:56 -05:00
parent f10c36348c
commit f75c3d7acf
2 changed files with 16 additions and 27 deletions

View file

@ -51,10 +51,7 @@ class StatsDetailsAdapter(
} }
override fun getItemId(position: Int): Long { override fun getItemId(position: Int): Long {
return when (stat) { return list[position].id ?: list[position].label?.hashCode()?.toLong() ?: 0L
Stats.READ_DURATION -> list[position].id
else -> list[position].label?.hashCode()?.toLong()
} ?: 0L
} }
override fun onBindViewHolder(holder: StatsDetailsHolder, position: Int) { override fun onBindViewHolder(holder: StatsDetailsHolder, position: Int) {
@ -65,8 +62,7 @@ class StatsDetailsAdapter(
else -> handleLayout(holder, position) else -> handleLayout(holder, position)
} }
holder.itemView.setOnClickListener { holder.itemView.setOnClickListener {
val item = list[position] list[position].let { item -> listener?.onItemClicked(item.id, item.label) }
listener?.onItemClicked(item.id, item.casedLabel ?: item.label)
} }
holder.itemView.isClickable = stat in arrayOf( holder.itemView.isClickable = stat in arrayOf(
Stats.SERIES_TYPE, Stats.SERIES_TYPE,
@ -96,7 +92,7 @@ class StatsDetailsAdapter(
statsLabelText.setTextColor( statsLabelText.setTextColor(
item.color ?: context.getResourceColor(R.attr.colorOnBackground), item.color ?: context.getResourceColor(R.attr.colorOnBackground),
) )
statsLabelText.text = item.label statsLabelText.text = item.label?.uppercase()
if (item.iconRes != null) { if (item.iconRes != null) {
logoContainer.isVisible = true logoContainer.isVisible = true
item.iconBGColor?.let { logoContainer.setCardBackgroundColor(it) } item.iconBGColor?.let { logoContainer.setCardBackgroundColor(it) }
@ -132,7 +128,8 @@ class StatsDetailsAdapter(
statsLabelText.setTextColor( statsLabelText.setTextColor(
item.color ?: context.getResourceColor(R.attr.colorOnBackground), item.color ?: context.getResourceColor(R.attr.colorOnBackground),
) )
statsLabelText.text = item.label val formattedScore = item.label?.uppercase() + if (item.label?.toIntOrNull() != null) "" else ""
statsLabelText.text = formattedScore
statsCountText.text = getCountText(item) statsCountText.text = getCountText(item)
statsCountPercentageText.text = getCountPercentageText(item) statsCountPercentageText.text = getCountPercentageText(item)
statsProgressText.text = getProgressText(item) statsProgressText.text = getProgressText(item)
@ -155,7 +152,7 @@ class StatsDetailsAdapter(
statsLabelText.setTextColor( statsLabelText.setTextColor(
item.color ?: context.getResourceColor(R.attr.colorOnBackground), item.color ?: context.getResourceColor(R.attr.colorOnBackground),
) )
statsLabelText.text = item.label statsLabelText.text = item.label?.uppercase()
if (item.icon != null) { if (item.icon != null) {
logoContainer.isVisible = true logoContainer.isVisible = true
logoContainer.setCardBackgroundColor(Color.TRANSPARENT) logoContainer.setCardBackgroundColor(Color.TRANSPARENT)
@ -189,7 +186,7 @@ class StatsDetailsAdapter(
statsLabelText.setTextColor( statsLabelText.setTextColor(
item.color ?: context.getResourceColor(R.attr.colorOnBackground), item.color ?: context.getResourceColor(R.attr.colorOnBackground),
) )
statsLabelText.text = item.label statsLabelText.text = item.label?.uppercase()
statsScoreText.text = statsScoreText.text =
item.readDuration.getReadDuration(context.getString(R.string.none)) item.readDuration.getReadDuration(context.getString(R.string.none))
statsSublabelText.isVisible = !item.subLabel.isNullOrBlank() statsSublabelText.isVisible = !item.subLabel.isNullOrBlank()

View file

@ -146,9 +146,8 @@ class StatsDetailsPresenter(
meanScore = mangaList.getMeanScoreRounded(), meanScore = mangaList.getMeanScoreRounded(),
chaptersRead = mangaList.sumOf { it.read }, chaptersRead = mangaList.sumOf { it.read },
totalChapters = mangaList.sumOf { it.totalChapters }, totalChapters = mangaList.sumOf { it.totalChapters },
label = context.mapSeriesType(seriesType).uppercase(), label = context.mapSeriesType(seriesType),
readDuration = mangaList.getReadDuration(), readDuration = mangaList.getReadDuration(),
casedLabel = context.mapSeriesType(seriesType),
), ),
) )
} }
@ -167,9 +166,8 @@ class StatsDetailsPresenter(
meanScore = mangaList.getMeanScoreRounded(), meanScore = mangaList.getMeanScoreRounded(),
chaptersRead = mangaList.sumOf { it.read }, chaptersRead = mangaList.sumOf { it.read },
totalChapters = mangaList.sumOf { it.totalChapters }, totalChapters = mangaList.sumOf { it.totalChapters },
label = context.mapStatus(status).uppercase(), label = context.mapStatus(status),
readDuration = mangaList.getReadDuration(), readDuration = mangaList.getReadDuration(),
casedLabel = context.mapStatus(status),
), ),
) )
} }
@ -190,9 +188,8 @@ class StatsDetailsPresenter(
meanScore = score?.toDouble() ?: 0.0, meanScore = score?.toDouble() ?: 0.0,
chaptersRead = mangaList?.sumOf { it.read } ?: 0, chaptersRead = mangaList?.sumOf { it.read } ?: 0,
totalChapters = mangaList?.sumOf { it.totalChapters } ?: 0, totalChapters = mangaList?.sumOf { it.totalChapters } ?: 0,
label = score?.toString() ?: context.getString(R.string.not_rated).uppercase(), label = score?.toString() ?: context.getString(R.string.not_rated),
readDuration = mangaList?.getReadDuration() ?: 0L, readDuration = mangaList?.getReadDuration() ?: 0L,
casedLabel = score?.toString() ?: context.getString(R.string.not_rated),
id = score?.toLong(), id = score?.toLong(),
), ),
) )
@ -211,9 +208,8 @@ class StatsDetailsPresenter(
meanScore = mangaList.getMeanScoreRounded(), meanScore = mangaList.getMeanScoreRounded(),
chaptersRead = mangaList.sumOf { it.read }, chaptersRead = mangaList.sumOf { it.read },
totalChapters = mangaList.sumOf { it.totalChapters }, totalChapters = mangaList.sumOf { it.totalChapters },
label = language.uppercase(), label = language,
readDuration = mangaList.getReadDuration(), readDuration = mangaList.getReadDuration(),
casedLabel = language,
), ),
) )
} }
@ -264,12 +260,11 @@ class StatsDetailsPresenter(
meanScore = mangaAndTrack.map { it.second }.getMeanScoreByTracker()?.roundToTwoDecimal(), meanScore = mangaAndTrack.map { it.second }.getMeanScoreByTracker()?.roundToTwoDecimal(),
chaptersRead = mangaAndTrack.sumOf { it.first.read }, chaptersRead = mangaAndTrack.sumOf { it.first.read },
totalChapters = mangaAndTrack.sumOf { it.first.totalChapters }, totalChapters = mangaAndTrack.sumOf { it.first.totalChapters },
label = label.uppercase(), label = label,
iconRes = service?.getLogo(), iconRes = service?.getLogo(),
iconBGColor = service?.getLogoColor(), iconBGColor = service?.getLogoColor(),
readDuration = mangaAndTrack.map { it.first }.getReadDuration(), readDuration = mangaAndTrack.map { it.first }.getReadDuration(),
id = service?.id?.toLong(), id = service?.id?.toLong(),
casedLabel = label,
), ),
) )
} }
@ -290,10 +285,9 @@ class StatsDetailsPresenter(
meanScore = mangaList.getMeanScoreRounded(), meanScore = mangaList.getMeanScoreRounded(),
chaptersRead = mangaList.sumOf { it.read }, chaptersRead = mangaList.sumOf { it.read },
totalChapters = mangaList.sumOf { it.totalChapters }, totalChapters = mangaList.sumOf { it.totalChapters },
label = source.nameBasedOnEnabledLanguages(isMultiLingual, extensionManager).uppercase(), label = source.nameBasedOnEnabledLanguages(isMultiLingual, extensionManager),
icon = source.icon(), icon = source.icon(),
readDuration = mangaList.getReadDuration(), readDuration = mangaList.getReadDuration(),
casedLabel = source?.name,
id = sourceId, id = sourceId,
), ),
) )
@ -315,7 +309,7 @@ class StatsDetailsPresenter(
meanScore = mangaList.getMeanScoreRounded(), meanScore = mangaList.getMeanScoreRounded(),
chaptersRead = mangaList.sumOf { it.read }, chaptersRead = mangaList.sumOf { it.read },
totalChapters = mangaList.sumOf { it.totalChapters }, totalChapters = mangaList.sumOf { it.totalChapters },
label = label.uppercase(), label = label,
readDuration = mangaList.getReadDuration(), readDuration = mangaList.getReadDuration(),
), ),
) )
@ -341,9 +335,8 @@ class StatsDetailsPresenter(
meanScore = mangaList.getMeanScoreRounded(), meanScore = mangaList.getMeanScoreRounded(),
chaptersRead = mangaList.sumOf { it.read }, chaptersRead = mangaList.sumOf { it.read },
totalChapters = mangaList.sumOf { it.totalChapters }, totalChapters = mangaList.sumOf { it.totalChapters },
label = tag.uppercase(), label = tag,
readDuration = mangaList.getReadDuration(), readDuration = mangaList.getReadDuration(),
casedLabel = tag,
), ),
) )
} }
@ -363,7 +356,7 @@ class StatsDetailsPresenter(
meanScore = mangaList.getMeanScoreRounded(), meanScore = mangaList.getMeanScoreRounded(),
chaptersRead = mangaList.sumOf { it.read }, chaptersRead = mangaList.sumOf { it.read },
totalChapters = mangaList.sumOf { it.totalChapters }, totalChapters = mangaList.sumOf { it.totalChapters },
label = year?.toString() ?: context.getString(R.string.not_started).uppercase(), label = year?.toString() ?: context.getString(R.string.not_started),
readDuration = mangaList.getReadDuration(), readDuration = mangaList.getReadDuration(),
id = year?.toLong(), id = year?.toLong(),
), ),
@ -692,6 +685,5 @@ class StatsDetailsPresenter(
var subLabel: String? = null, var subLabel: String? = null,
var readDuration: Long = 0, var readDuration: Long = 0,
var id: Long? = null, var id: Long? = null,
var casedLabel: String? = null,
) )
} }