Minor cleanup

This commit is contained in:
Jobobby04 2022-06-19 21:54:11 -04:00
parent ea712646fc
commit f808cbfa69
2 changed files with 15 additions and 25 deletions

View File

@ -10,7 +10,6 @@ import android.view.View
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.core.os.bundleOf
import com.bluelinelabs.conductor.Controller
import eu.kanade.domain.source.model.Source
import eu.kanade.presentation.browse.SourcesScreen
@ -62,16 +61,7 @@ class SourcesController(bundle: Bundle? = null) : SearchableComposeController<So
presenter = presenter,
onClickItem = { source ->
when {
mode == Mode.SMART_SEARCH -> {
router.pushController(
SmartSearchController(
bundleOf(
SmartSearchController.ARG_SOURCE_ID to source.id,
SmartSearchController.ARG_SMART_SEARCH_CONFIG to smartSearchConfig,
),
),
)
}
mode == Mode.SMART_SEARCH -> router.pushController(SmartSearchController(source.id, smartSearchConfig!!))
preferences.useNewSourceNavigation().get() -> openSource(source, SourceFeedController(source.id))
else -> openSource(source, BrowseSourceController(source))
}

View File

@ -3,6 +3,7 @@ package exh.ui.smartsearch
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.core.os.bundleOf
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.EhSmartSearchBinding
import eu.kanade.tachiyomi.source.CatalogueSource
@ -17,29 +18,28 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.injectLazy
class SmartSearchController(bundle: Bundle? = null) : NucleusController<EhSmartSearchBinding, SmartSearchPresenter>() {
class SmartSearchController(bundle: Bundle) : NucleusController<EhSmartSearchBinding, SmartSearchPresenter>() {
private val sourceManager: SourceManager by injectLazy()
private val source = sourceManager.get(bundle?.getLong(ARG_SOURCE_ID, -1) ?: -1) as? CatalogueSource
private val smartSearchConfig: SourcesController.SmartSearchConfig? = bundle?.getParcelable(
ARG_SMART_SEARCH_CONFIG,
private val source = sourceManager.get(bundle.getLong(ARG_SOURCE_ID, -1)) as CatalogueSource
private val smartSearchConfig: SourcesController.SmartSearchConfig = bundle.getParcelable(ARG_SMART_SEARCH_CONFIG)!!
constructor(sourceId: Long, smartSearchConfig: SourcesController.SmartSearchConfig) : this(
bundleOf(
ARG_SOURCE_ID to sourceId,
ARG_SMART_SEARCH_CONFIG to smartSearchConfig,
),
)
override fun getTitle() = source?.name.orEmpty()
override fun getTitle() = source.name
override fun createPresenter() = SmartSearchPresenter(source!!, smartSearchConfig!!)
override fun createPresenter() = SmartSearchPresenter(source, smartSearchConfig)
override fun createBinding(inflater: LayoutInflater) = EhSmartSearchBinding.inflate(inflater)
override fun onViewCreated(view: View) {
super.onViewCreated(view)
if (source == null || smartSearchConfig == null) {
router.popCurrentController()
applicationContext?.toast("Missing data!")
return
}
presenter.smartSearchFlow
.onEach { results ->
if (results is SmartSearchPresenter.SearchResults.Found) {
@ -63,7 +63,7 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<EhSmartS
}
companion object {
const val ARG_SOURCE_ID = "SOURCE_ID"
const val ARG_SMART_SEARCH_CONFIG = "SMART_SEARCH_CONFIG"
private const val ARG_SOURCE_ID = "SOURCE_ID"
private const val ARG_SMART_SEARCH_CONFIG = "SMART_SEARCH_CONFIG"
}
}