Merge pull request #163 from Yutatsu1/dev
added episode duration formatting
This commit is contained in:
commit
fad4032a78
2 changed files with 25 additions and 10 deletions
|
@ -95,8 +95,30 @@ class MediaInfoFragment : Fragment() {
|
||||||
binding.mediaInfoStart.text = media.startDate?.toString() ?: "??"
|
binding.mediaInfoStart.text = media.startDate?.toString() ?: "??"
|
||||||
binding.mediaInfoEnd.text = media.endDate?.toString() ?: "??"
|
binding.mediaInfoEnd.text = media.endDate?.toString() ?: "??"
|
||||||
if (media.anime != null) {
|
if (media.anime != null) {
|
||||||
binding.mediaInfoDuration.text =
|
val episodeDuration = media.anime.episodeDuration
|
||||||
if (media.anime.episodeDuration != null) media.anime.episodeDuration.toString() else "??"
|
|
||||||
|
binding.mediaInfoDuration.text = when {
|
||||||
|
episodeDuration != null -> {
|
||||||
|
val hours = episodeDuration / 60
|
||||||
|
val minutes = episodeDuration % 60
|
||||||
|
|
||||||
|
val formattedDuration = buildString {
|
||||||
|
if (hours > 0) {
|
||||||
|
append("$hours hour")
|
||||||
|
if (hours > 1) append("s")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minutes > 0) {
|
||||||
|
if (hours > 0) append(", ")
|
||||||
|
append("$minutes min")
|
||||||
|
if (minutes > 1) append("s")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
formattedDuration
|
||||||
|
}
|
||||||
|
else -> "??"
|
||||||
|
}
|
||||||
binding.mediaInfoDurationContainer.visibility = View.VISIBLE
|
binding.mediaInfoDurationContainer.visibility = View.VISIBLE
|
||||||
binding.mediaInfoSeasonContainer.visibility = View.VISIBLE
|
binding.mediaInfoSeasonContainer.visibility = View.VISIBLE
|
||||||
binding.mediaInfoSeason.text =
|
binding.mediaInfoSeason.text =
|
||||||
|
|
|
@ -145,13 +145,6 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:fontFamily="@font/poppins_bold"
|
android:fontFamily="@font/poppins_bold"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:fontFamily="@font/poppins_bold"
|
|
||||||
android:text="@string/min"
|
|
||||||
android:textAlignment="textEnd" />
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
|
@ -383,4 +376,4 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue