瀏覽代碼

Minor cleanup

arkon 3 年之前
父節點
當前提交
8a064c118f
共有 1 個文件被更改,包括 5 次插入6 次删除
  1. 5 6
      app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt

+ 5 - 6
app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt

@@ -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 {