light Manga details refactoring

This commit is contained in:
Jay 2020-04-09 02:01:56 -04:00
parent a73c847e3f
commit 1aebd3aced
7 changed files with 19 additions and 68 deletions

View File

@ -54,7 +54,7 @@ interface Manga : SManga {
TYPE_MANHUA -> R.string.manhua
TYPE_COMIC -> R.string.comic
else -> R.string.manga
})
}).toLowerCase(Locale.getDefault())
}
/**

View File

@ -111,58 +111,20 @@ class MangaDetailsAdapter(
}
private fun get100sRange(value: Float): String {
return when (value.toInt()) {
in 0..99 -> "0-99"
in 100..199 -> "100-199"
in 200..299 -> "200-299"
in 300..399 -> "300-399"
in 400..499 -> "400-499"
in 500..599 -> "500-599"
in 600..699 -> "600-699"
in 700..799 -> "700-799"
in 800..899 -> "800-899"
in 900..Int.MAX_VALUE -> "900+"
else -> "None"
val number = value.toInt()
return if (number < 100) "0-99"
else {
val hundred = number / 100
"${hundred}00-${hundred}99"
}
}
private fun get10sRange(value: Float): String {
return when (value.toInt()) {
in 0..9 -> "0-9"
in 10..19 -> "10-19"
in 20..29 -> "20-29"
in 30..39 -> "30-39"
in 40..49 -> "40-49"
in 50..59 -> "50-59"
in 60..69 -> "60-69"
in 70..79 -> "70-79"
in 80..89 -> "80-89"
in 80..89 -> "80-89"
in 90..99 -> "90-99"
in 100..109 -> "100-109"
in 110..119 -> "110-119"
in 120..129 -> "120-129"
in 130..139 -> "130-139"
in 140..149 -> "140-149"
in 150..159 -> "150-159"
in 160..169 -> "160-169"
in 170..179 -> "170-179"
in 180..189 -> "180-189"
in 190..199 -> "190-199"
in 190..199 -> "190-199"
in 200..209 -> "200-209"
in 210..219 -> "210-219"
in 220..229 -> "220-229"
in 230..239 -> "230-239"
in 240..249 -> "240-249"
in 250..259 -> "250-259"
in 260..269 -> "260-269"
in 270..279 -> "270-279"
in 280..289 -> "280-289"
in 290..299 -> "290-299"
in 290..299 -> "290-299"
in 300..Int.MAX_VALUE -> "300+"
else -> recyclerView.context.getString(R.string.unknown)
val number = value.toInt()
return if (number < 10) "0-9"
else {
val hundred = number / 10
"${hundred}0-${hundred + 1}9"
}
}

View File

@ -242,7 +242,7 @@ class MangaDetailsController : BaseController,
}
presenter.onCreate()
fast_scroller.translationX = if (showScroll) 0f else 22f.dpToPx
fast_scroller.translationX = if (showScroll) 0f else 25f.dpToPx
recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
@ -275,7 +275,7 @@ class MangaDetailsController : BaseController,
} else if (fPosition <= 0 && showScroll) {
showScroll = false
scrollAnim?.cancel()
scrollAnim = fast_scroller.animate().setDuration(100).translationX(22f.dpToPx)
scrollAnim = fast_scroller.animate().setDuration(100).translationX(25f.dpToPx)
scrollAnim?.start()
}
}
@ -690,7 +690,8 @@ class MangaDetailsController : BaseController,
presenter.getNextUnreadChapter() != null && !presenter.isLockedFromSearch
menu.findItem(R.id.action_mark_all_as_unread).isVisible =
!presenter.allUnread() && !presenter.isLockedFromSearch
menu.findItem(R.id.action_remove_downloads).isVisible = !presenter.isLockedFromSearch
menu.findItem(R.id.action_remove_downloads).isVisible =
presenter.hasDownloads() && !presenter.isLockedFromSearch
menu.findItem(R.id.remove_non_bookmarked).isVisible =
presenter.hasBookmark() && !presenter.isLockedFromSearch
menu.findItem(R.id.action_mark_all_as_unread).isVisible = presenter.isTracked()

View File

@ -321,6 +321,7 @@ class MangaDetailsPresenter(
fun allUnread(): Boolean = chapters.none { it.read }
fun hasBookmark(): Boolean = chapters.any { it.bookmark }
fun hasDownloads(): Boolean = chapters.any { it.isDownloaded }
fun getUnreadChaptersSorted() =
chapters.filter { !it.read && it.status == Download.NOT_DOWNLOADED }.distinctBy { it.name }

View File

@ -28,7 +28,6 @@ import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.manga_details_controller.*
import kotlinx.android.synthetic.main.manga_header_item.*
import java.util.Locale
class MangaHeaderHolder(
private val view: View,
@ -137,15 +136,7 @@ class MangaHeaderHolder(
else expand()
}
manga_summary_label.text = itemView.context.getString(
R.string.about_this_, itemView.context.getString(
when {
manga.mangaType() == Manga.TYPE_MANHWA -> R.string.manhwa
manga.mangaType() == Manga.TYPE_MANHUA -> R.string.manhua
manga.mangaType() == Manga.TYPE_COMIC -> R.string.comic
manga.mangaType() == Manga.TYPE_WEBTOON -> R.string.webtoon
else -> R.string.manga
}
).toLowerCase(Locale.getDefault())
R.string.about_this_, manga.mangaType(itemView.context)
)
with(favorite_button) {
icon = ContextCompat.getDrawable(

View File

@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.History
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import java.util.Locale
class RemoveHistoryDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
where T : Controller, T : RemoveHistoryDialog.Listener {
@ -31,10 +30,7 @@ class RemoveHistoryDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
return MaterialDialog(activity).title(R.string.remove)
.message(R.string.this_will_remove_the_read_date_question).checkBoxPrompt(
text = activity.getString(
R.string.reset_all_chapters_for_this_,
(manga?.mangaType(activity) ?: activity.getString(R.string.manga)).toLowerCase(
Locale.ROOT
)
R.string.reset_all_chapters_for_this_, manga!!.mangaType(activity)
)
) {}.negativeButton(android.R.string.cancel).positiveButton(R.string.remove) {
onPositive(it.isCheckPromptChecked())

View File

@ -35,7 +35,7 @@
android:id="@+id/fast_scroller"
android:textColor="?android:attr/textColorPrimary"
app:iconColor="?android:attr/textColorPrimary"
android:layout_width="22dp"
android:layout_width="25dp"
android:layout_height="0dp"
android:elevation="10dp"
android:layout_gravity="end"