mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 00:51:49 +01:00
Minor cleanup
This commit is contained in:
parent
2f91c27df2
commit
8a064c118f
@ -9,6 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.databinding.MangaInfoHeaderBinding
|
import eu.kanade.tachiyomi.databinding.MangaInfoHeaderBinding
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
@ -26,8 +27,6 @@ import kotlinx.coroutines.flow.merge
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
import reactivecircus.flowbinding.android.view.longClicks
|
import reactivecircus.flowbinding.android.view.longClicks
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class MangaInfoHeaderAdapter(
|
class MangaInfoHeaderAdapter(
|
||||||
@ -38,6 +37,8 @@ class MangaInfoHeaderAdapter(
|
|||||||
RecyclerView.Adapter<MangaInfoHeaderAdapter.HeaderViewHolder>() {
|
RecyclerView.Adapter<MangaInfoHeaderAdapter.HeaderViewHolder>() {
|
||||||
|
|
||||||
private val trackManager: TrackManager by injectLazy()
|
private val trackManager: TrackManager by injectLazy()
|
||||||
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
|
private val sourceManager: SourceManager by injectLazy()
|
||||||
|
|
||||||
private var manga: Manga = controller.presenter.manga
|
private var manga: Manga = controller.presenter.manga
|
||||||
private var source: Source = controller.presenter.source
|
private var source: Source = controller.presenter.source
|
||||||
@ -260,25 +261,23 @@ class MangaInfoHeaderAdapter(
|
|||||||
val mangaSource = source?.toString()
|
val mangaSource = source?.toString()
|
||||||
with(binding.mangaSource) {
|
with(binding.mangaSource) {
|
||||||
if (mangaSource != null) {
|
if (mangaSource != null) {
|
||||||
val preferences = controller.presenter.preferences
|
|
||||||
val enabledLanguages = preferences.enabledLanguages().get()
|
val enabledLanguages = preferences.enabledLanguages().get()
|
||||||
.filterNot { it == "all" }
|
.filterNot { it == "all" }
|
||||||
|
|
||||||
text = if (enabledLanguages.size == 1) {
|
text = if (enabledLanguages.size == 1) {
|
||||||
// For edge cases where user disables a source they got manga of in their library.
|
// For edge cases where user disables a source they got manga of in their library.
|
||||||
if (source.lang !in enabledLanguages) {
|
if (source.lang !in enabledLanguages) {
|
||||||
source.toString()
|
mangaSource
|
||||||
} else {
|
} else {
|
||||||
// Hide the language tag when only one language is used.
|
// Hide the language tag when only one language is used.
|
||||||
source.name
|
source.name
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Display the language tag when multiple languages are used.
|
// Display the language tag when multiple languages are used.
|
||||||
source.toString()
|
mangaSource
|
||||||
}
|
}
|
||||||
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
val sourceManager = Injekt.get<SourceManager>()
|
|
||||||
controller.performSearch(sourceManager.getOrStub(source.id).name)
|
controller.performSearch(sourceManager.getOrStub(source.id).name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user