Swapped rating and state fields on details screen
This commit is contained in:
@@ -104,20 +104,11 @@ class DetailsFragment :
|
||||
textViewTitle.text = manga.title
|
||||
textViewSubtitle.textAndVisible = manga.altTitle
|
||||
textViewAuthor.textAndVisible = manga.author
|
||||
when (manga.state) {
|
||||
MangaState.FINISHED -> {
|
||||
textViewState.apply {
|
||||
textAndVisible = resources.getString(R.string.state_finished)
|
||||
drawableStart = ContextCompat.getDrawable(context, R.drawable.ic_state_finished)
|
||||
}
|
||||
}
|
||||
MangaState.ONGOING -> {
|
||||
textViewState.apply {
|
||||
textAndVisible = resources.getString(R.string.state_ongoing)
|
||||
drawableStart = ContextCompat.getDrawable(context, R.drawable.ic_state_ongoing)
|
||||
}
|
||||
}
|
||||
else -> textViewState.isVisible = false
|
||||
if (manga.hasRating) {
|
||||
ratingBar.rating = manga.rating * ratingBar.numStars
|
||||
ratingBar.isVisible = true
|
||||
} else {
|
||||
ratingBar.isVisible = false
|
||||
}
|
||||
|
||||
// Info containers
|
||||
@@ -132,11 +123,20 @@ class DetailsFragment :
|
||||
chapters.size,
|
||||
)
|
||||
}
|
||||
if (manga.hasRating) {
|
||||
infoLayout.textViewRating.text = String.format("%.1f", manga.rating * 5)
|
||||
infoLayout.ratingContainer.isVisible = true
|
||||
} else {
|
||||
infoLayout.ratingContainer.isVisible = false
|
||||
when (manga.state) {
|
||||
MangaState.FINISHED -> {
|
||||
infoLayout.textViewState.apply {
|
||||
textAndVisible = resources.getString(R.string.state_finished)
|
||||
drawableTop = ContextCompat.getDrawable(context, R.drawable.ic_state_finished)
|
||||
}
|
||||
}
|
||||
MangaState.ONGOING -> {
|
||||
infoLayout.textViewState.apply {
|
||||
textAndVisible = resources.getString(R.string.state_ongoing)
|
||||
drawableTop = ContextCompat.getDrawable(context, R.drawable.ic_state_ongoing)
|
||||
}
|
||||
}
|
||||
else -> infoLayout.textViewState.isVisible = false
|
||||
}
|
||||
if (manga.source == MangaSource.LOCAL) {
|
||||
infoLayout.textViewSource.isVisible = false
|
||||
|
||||
@@ -28,6 +28,13 @@ var TextView.drawableEnd: Drawable?
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(dr[0], dr[1], value, dr[3])
|
||||
}
|
||||
|
||||
var TextView.drawableTop: Drawable?
|
||||
inline get() = compoundDrawablesRelative[1]
|
||||
set(value) {
|
||||
val dr = compoundDrawablesRelative
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(dr[0], value, dr[2], dr[3])
|
||||
}
|
||||
|
||||
fun TextView.setTextAndVisible(@StringRes textResId: Int) {
|
||||
if (textResId == 0) {
|
||||
text = null
|
||||
@@ -40,4 +47,4 @@ fun TextView.setTextAndVisible(@StringRes textResId: Int) {
|
||||
|
||||
fun TextView.setTextColorAttr(@AttrRes attrResId: Int) {
|
||||
setTextColor(context.getThemeColorStateList(attrResId))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user