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

View file

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