mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 00:51:47 +01:00
light Manga details refactoring
This commit is contained in:
parent
a73c847e3f
commit
1aebd3aced
@ -54,7 +54,7 @@ interface Manga : SManga {
|
|||||||
TYPE_MANHUA -> R.string.manhua
|
TYPE_MANHUA -> R.string.manhua
|
||||||
TYPE_COMIC -> R.string.comic
|
TYPE_COMIC -> R.string.comic
|
||||||
else -> R.string.manga
|
else -> R.string.manga
|
||||||
})
|
}).toLowerCase(Locale.getDefault())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,58 +111,20 @@ class MangaDetailsAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun get100sRange(value: Float): String {
|
private fun get100sRange(value: Float): String {
|
||||||
return when (value.toInt()) {
|
val number = value.toInt()
|
||||||
in 0..99 -> "0-99"
|
return if (number < 100) "0-99"
|
||||||
in 100..199 -> "100-199"
|
else {
|
||||||
in 200..299 -> "200-299"
|
val hundred = number / 100
|
||||||
in 300..399 -> "300-399"
|
"${hundred}00-${hundred}99"
|
||||||
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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun get10sRange(value: Float): String {
|
private fun get10sRange(value: Float): String {
|
||||||
return when (value.toInt()) {
|
val number = value.toInt()
|
||||||
in 0..9 -> "0-9"
|
return if (number < 10) "0-9"
|
||||||
in 10..19 -> "10-19"
|
else {
|
||||||
in 20..29 -> "20-29"
|
val hundred = number / 10
|
||||||
in 30..39 -> "30-39"
|
"${hundred}0-${hundred + 1}9"
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ class MangaDetailsController : BaseController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
presenter.onCreate()
|
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() {
|
recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
@ -275,7 +275,7 @@ class MangaDetailsController : BaseController,
|
|||||||
} else if (fPosition <= 0 && showScroll) {
|
} else if (fPosition <= 0 && showScroll) {
|
||||||
showScroll = false
|
showScroll = false
|
||||||
scrollAnim?.cancel()
|
scrollAnim?.cancel()
|
||||||
scrollAnim = fast_scroller.animate().setDuration(100).translationX(22f.dpToPx)
|
scrollAnim = fast_scroller.animate().setDuration(100).translationX(25f.dpToPx)
|
||||||
scrollAnim?.start()
|
scrollAnim?.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -690,7 +690,8 @@ class MangaDetailsController : BaseController,
|
|||||||
presenter.getNextUnreadChapter() != null && !presenter.isLockedFromSearch
|
presenter.getNextUnreadChapter() != null && !presenter.isLockedFromSearch
|
||||||
menu.findItem(R.id.action_mark_all_as_unread).isVisible =
|
menu.findItem(R.id.action_mark_all_as_unread).isVisible =
|
||||||
!presenter.allUnread() && !presenter.isLockedFromSearch
|
!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 =
|
menu.findItem(R.id.remove_non_bookmarked).isVisible =
|
||||||
presenter.hasBookmark() && !presenter.isLockedFromSearch
|
presenter.hasBookmark() && !presenter.isLockedFromSearch
|
||||||
menu.findItem(R.id.action_mark_all_as_unread).isVisible = presenter.isTracked()
|
menu.findItem(R.id.action_mark_all_as_unread).isVisible = presenter.isTracked()
|
||||||
|
@ -321,6 +321,7 @@ class MangaDetailsPresenter(
|
|||||||
|
|
||||||
fun allUnread(): Boolean = chapters.none { it.read }
|
fun allUnread(): Boolean = chapters.none { it.read }
|
||||||
fun hasBookmark(): Boolean = chapters.any { it.bookmark }
|
fun hasBookmark(): Boolean = chapters.any { it.bookmark }
|
||||||
|
fun hasDownloads(): Boolean = chapters.any { it.isDownloaded }
|
||||||
|
|
||||||
fun getUnreadChaptersSorted() =
|
fun getUnreadChaptersSorted() =
|
||||||
chapters.filter { !it.read && it.status == Download.NOT_DOWNLOADED }.distinctBy { it.name }
|
chapters.filter { !it.read && it.status == Download.NOT_DOWNLOADED }.distinctBy { it.name }
|
||||||
|
@ -28,7 +28,6 @@ import eu.kanade.tachiyomi.util.view.visible
|
|||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import kotlinx.android.synthetic.main.manga_details_controller.*
|
import kotlinx.android.synthetic.main.manga_details_controller.*
|
||||||
import kotlinx.android.synthetic.main.manga_header_item.*
|
import kotlinx.android.synthetic.main.manga_header_item.*
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
class MangaHeaderHolder(
|
class MangaHeaderHolder(
|
||||||
private val view: View,
|
private val view: View,
|
||||||
@ -137,15 +136,7 @@ class MangaHeaderHolder(
|
|||||||
else expand()
|
else expand()
|
||||||
}
|
}
|
||||||
manga_summary_label.text = itemView.context.getString(
|
manga_summary_label.text = itemView.context.getString(
|
||||||
R.string.about_this_, itemView.context.getString(
|
R.string.about_this_, manga.mangaType(itemView.context)
|
||||||
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())
|
|
||||||
)
|
)
|
||||||
with(favorite_button) {
|
with(favorite_button) {
|
||||||
icon = ContextCompat.getDrawable(
|
icon = ContextCompat.getDrawable(
|
||||||
|
@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.models.History
|
import eu.kanade.tachiyomi.data.database.models.History
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
class RemoveHistoryDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
class RemoveHistoryDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||||
where T : Controller, T : RemoveHistoryDialog.Listener {
|
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)
|
return MaterialDialog(activity).title(R.string.remove)
|
||||||
.message(R.string.this_will_remove_the_read_date_question).checkBoxPrompt(
|
.message(R.string.this_will_remove_the_read_date_question).checkBoxPrompt(
|
||||||
text = activity.getString(
|
text = activity.getString(
|
||||||
R.string.reset_all_chapters_for_this_,
|
R.string.reset_all_chapters_for_this_, manga!!.mangaType(activity)
|
||||||
(manga?.mangaType(activity) ?: activity.getString(R.string.manga)).toLowerCase(
|
|
||||||
Locale.ROOT
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
) {}.negativeButton(android.R.string.cancel).positiveButton(R.string.remove) {
|
) {}.negativeButton(android.R.string.cancel).positiveButton(R.string.remove) {
|
||||||
onPositive(it.isCheckPromptChecked())
|
onPositive(it.isCheckPromptChecked())
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:id="@+id/fast_scroller"
|
android:id="@+id/fast_scroller"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
app:iconColor="?android:attr/textColorPrimary"
|
app:iconColor="?android:attr/textColorPrimary"
|
||||||
android:layout_width="22dp"
|
android:layout_width="25dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:elevation="10dp"
|
android:elevation="10dp"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
|
Loading…
Reference in New Issue
Block a user