mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-27 11:28:23 +01:00
Minor cleanup
This commit is contained in:
parent
a72098b862
commit
b9fd01315b
@ -33,8 +33,7 @@ import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
import eu.kanade.tachiyomi.util.view.onAnimationsFinished
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
* This controller shows and manages the different catalogues enabled by the user.
|
||||
@ -48,11 +47,8 @@ class SourceController :
|
||||
FlexibleAdapter.OnItemLongClickListener,
|
||||
SourceAdapter.OnSourceClickListener {
|
||||
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
/**
|
||||
* Adapter containing sources.
|
||||
*/
|
||||
private var adapter: SourceAdapter? = null
|
||||
|
||||
init {
|
||||
@ -128,18 +124,10 @@ class SourceController :
|
||||
val isPinned = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false
|
||||
|
||||
val items = mutableListOf(
|
||||
Pair(
|
||||
activity.getString(if (isPinned) R.string.action_unpin else R.string.action_pin),
|
||||
{ toggleSourcePin(item.source) }
|
||||
)
|
||||
activity.getString(if (isPinned) R.string.action_unpin else R.string.action_pin) to { toggleSourcePin(item.source) }
|
||||
)
|
||||
if (item.source !is LocalSource) {
|
||||
items.add(
|
||||
Pair(
|
||||
activity.getString(R.string.action_disable),
|
||||
{ disableSource(item.source) }
|
||||
)
|
||||
)
|
||||
items.add(activity.getString(R.string.action_disable) to { disableSource(item.source) })
|
||||
}
|
||||
|
||||
SourceOptionsDialog(item.source.toString(), items).showDialog(router)
|
||||
|
@ -11,8 +11,6 @@ import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.TreeMap
|
||||
@ -20,9 +18,6 @@ import java.util.TreeMap
|
||||
/**
|
||||
* Presenter of [SourceController]
|
||||
* Function calls should be done from here. UI calls should be done from the controller.
|
||||
*
|
||||
* @param sourceManager manages the different sources.
|
||||
* @param preferences application preferences.
|
||||
*/
|
||||
class SourcePresenter(
|
||||
val sourceManager: SourceManager = Injekt.get(),
|
||||
@ -31,17 +26,10 @@ class SourcePresenter(
|
||||
|
||||
var sources = getEnabledSources()
|
||||
|
||||
/**
|
||||
* Subscription for retrieving enabled sources.
|
||||
*/
|
||||
private var sourceSubscription: Subscription? = null
|
||||
|
||||
/**
|
||||
* Unsubscribe and create a new subscription to fetch enabled sources.
|
||||
*/
|
||||
private fun loadSources() {
|
||||
sourceSubscription?.unsubscribe()
|
||||
|
||||
val pinnedSources = mutableListOf<SourceItem>()
|
||||
val pinnedSourceIds = preferences.pinnedSources().get()
|
||||
|
||||
@ -53,7 +41,7 @@ class SourcePresenter(
|
||||
else -> d1.compareTo(d2)
|
||||
}
|
||||
}
|
||||
val byLang = sources.groupByTo(map, { it.lang })
|
||||
val byLang = sources.groupByTo(map) { it.lang }
|
||||
var sourceItems = byLang.flatMap {
|
||||
val langItem = LangItem(it.key)
|
||||
it.value.map { source ->
|
||||
@ -70,8 +58,7 @@ class SourcePresenter(
|
||||
sourceItems = pinnedSources + sourceItems
|
||||
}
|
||||
|
||||
sourceSubscription = Observable.just(sourceItems)
|
||||
.subscribeLatestCache(SourceController::setSources)
|
||||
view?.setSources(sourceItems)
|
||||
}
|
||||
|
||||
private fun loadLastUsedSource() {
|
||||
|
@ -552,7 +552,7 @@ class LibraryController(
|
||||
val common = presenter.getCommonCategories(mangas)
|
||||
// Get indexes of the mix categories to preselect.
|
||||
val mix = presenter.getMixCategories(mangas)
|
||||
var preselected = categories.map {
|
||||
val preselected = categories.map {
|
||||
when (it) {
|
||||
in common -> QuadStateTextView.State.CHECKED.ordinal
|
||||
in mix -> QuadStateTextView.State.INDETERMINATE.ordinal
|
||||
|
Loading…
Reference in New Issue
Block a user