Remove Related manga tab from details
This commit is contained in:
@@ -7,5 +7,5 @@ import org.koitharu.kotatsu.details.ui.DetailsViewModel
|
||||
val detailsModule
|
||||
get() = module {
|
||||
|
||||
viewModel { DetailsViewModel(get(), get(), get(), get(), get(), get(), get()) }
|
||||
viewModel { DetailsViewModel(get(), get(), get(), get(), get()) }
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import org.koitharu.kotatsu.browser.BrowserActivity
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
import org.koitharu.kotatsu.core.model.MangaSource
|
||||
import org.koitharu.kotatsu.download.DownloadService
|
||||
import org.koitharu.kotatsu.search.ui.global.GlobalSearchActivity
|
||||
import org.koitharu.kotatsu.utils.MangaShortcut
|
||||
import org.koitharu.kotatsu.utils.ShareHelper
|
||||
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||
@@ -164,6 +165,12 @@ class DetailsActivity : BaseActivity(), TabLayoutMediator.TabConfigurationStrate
|
||||
}
|
||||
true
|
||||
}
|
||||
R.id.action_related -> {
|
||||
manga?.let {
|
||||
startActivity(GlobalSearchActivity.newIntent(this, it.title))
|
||||
}
|
||||
true
|
||||
}
|
||||
R.id.action_shortcut -> {
|
||||
manga?.let {
|
||||
lifecycleScope.launch {
|
||||
|
||||
@@ -2,24 +2,20 @@ package org.koitharu.kotatsu.details.ui
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koitharu.kotatsu.base.domain.MangaDataRepository
|
||||
import org.koitharu.kotatsu.base.ui.BaseViewModel
|
||||
import org.koitharu.kotatsu.core.exceptions.MangaNotFoundException
|
||||
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
import org.koitharu.kotatsu.core.model.MangaHistory
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
||||
import org.koitharu.kotatsu.favourites.domain.OnFavouritesChangeListener
|
||||
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||
import org.koitharu.kotatsu.history.domain.OnHistoryChangeListener
|
||||
import org.koitharu.kotatsu.list.ui.MangaListViewModel
|
||||
import org.koitharu.kotatsu.local.domain.LocalMangaRepository
|
||||
import org.koitharu.kotatsu.search.domain.MangaSearchRepository
|
||||
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
||||
import org.koitharu.kotatsu.utils.SingleLiveEvent
|
||||
import org.koitharu.kotatsu.utils.ext.onFirst
|
||||
import org.koitharu.kotatsu.utils.ext.safe
|
||||
import java.io.IOException
|
||||
|
||||
@@ -28,12 +24,8 @@ class DetailsViewModel(
|
||||
private val favouritesRepository: FavouritesRepository,
|
||||
private val localMangaRepository: LocalMangaRepository,
|
||||
private val trackingRepository: TrackingRepository,
|
||||
private val searchRepository: MangaSearchRepository,
|
||||
private val mangaDataRepository: MangaDataRepository,
|
||||
settings: AppSettings
|
||||
) : MangaListViewModel(settings), OnHistoryChangeListener, OnFavouritesChangeListener {
|
||||
|
||||
override val content = MutableLiveData<List<Any>>()
|
||||
private val mangaDataRepository: MangaDataRepository
|
||||
) : BaseViewModel(), OnHistoryChangeListener, OnFavouritesChangeListener {
|
||||
|
||||
val mangaData = MutableLiveData<Manga>()
|
||||
val newChapters = MutableLiveData<Int>(0)
|
||||
@@ -96,30 +88,6 @@ class DetailsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun loadRelated() {
|
||||
val manga = mangaData.value ?: return
|
||||
searchRepository.globalSearch(manga.title)
|
||||
.map { list ->
|
||||
list.filter { x -> x.id != manga.id }
|
||||
}.filterNot { x -> x.isEmpty() }
|
||||
.flowOn(Dispatchers.IO)
|
||||
.catch { e ->
|
||||
if (e is IOException) {
|
||||
onError.call(e)
|
||||
}
|
||||
}
|
||||
.onEmpty {
|
||||
content.value = emptyList()
|
||||
isLoading.value = false
|
||||
}.onCompletion {
|
||||
// TODO
|
||||
}.onFirst {
|
||||
isLoading.value = false
|
||||
}.onEach {
|
||||
content.value = content.value.orEmpty() + it
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHistoryChanged() {
|
||||
loadHistory(mangaData.value ?: return)
|
||||
}
|
||||
|
||||
@@ -6,12 +6,11 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
|
||||
class MangaDetailsAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) {
|
||||
|
||||
override fun getItemCount() = 3
|
||||
override fun getItemCount() = 2
|
||||
|
||||
override fun createFragment(position: Int): Fragment = when (position) {
|
||||
0 -> DetailsFragment()
|
||||
1 -> ChaptersFragment()
|
||||
2 -> RelatedMangaFragment()
|
||||
else -> throw IndexOutOfBoundsException("No fragment for position $position")
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.koitharu.kotatsu.details.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import org.koin.android.viewmodel.ext.android.sharedViewModel
|
||||
import org.koitharu.kotatsu.list.ui.MangaListFragment
|
||||
|
||||
class RelatedMangaFragment : MangaListFragment() {
|
||||
|
||||
override val viewModel by sharedViewModel<DetailsViewModel>()
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
isSwipeRefreshEnabled = false
|
||||
}
|
||||
|
||||
override fun onRequestMoreItems(offset: Int) {
|
||||
if (offset == 0) {
|
||||
viewModel.loadRelated()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class HistoryListViewModel(
|
||||
repository.observeAll(),
|
||||
createListModeFlow()
|
||||
) { list, mode ->
|
||||
when(mode) {
|
||||
when (mode) {
|
||||
ListMode.LIST -> list.map { it.toListModel() }
|
||||
ListMode.DETAILED_LIST -> list.map { it.toListDetailedModel() }
|
||||
ListMode.GRID -> list.map { it.toGridModel() }
|
||||
|
||||
@@ -271,7 +271,7 @@ abstract class MangaListFragment : BaseFragment(R.layout.fragment_list),
|
||||
|
||||
override fun getSpanSize(position: Int): Int {
|
||||
val total = (recyclerView.layoutManager as? GridLayoutManager)?.spanCount ?: return 1
|
||||
return when(adapter?.getItemViewType(position)) {
|
||||
return when (adapter?.getItemViewType(position)) {
|
||||
MangaListAdapter.ITEM_TYPE_PROGRESS -> total
|
||||
else -> 1
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ class MangaListAdapter(
|
||||
|
||||
init {
|
||||
delegatesManager.addDelegate(ITEM_TYPE_MANGA_LIST, mangaListItemAD(coil, clickListener))
|
||||
.addDelegate(ITEM_TYPE_MANGA_LIST_DETAILED, mangaListDetailedItemAD(coil, clickListener))
|
||||
.addDelegate(
|
||||
ITEM_TYPE_MANGA_LIST_DETAILED,
|
||||
mangaListDetailedItemAD(coil, clickListener)
|
||||
)
|
||||
.addDelegate(ITEM_TYPE_MANGA_GRID, mangaGridItemAD(coil, clickListener))
|
||||
.addDelegate(ITEM_TYPE_PROGRESS, indeterminateProgressAD())
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class LocalListViewModel(
|
||||
private val mangaList = MutableStateFlow<List<Manga>>(emptyList())
|
||||
|
||||
override val content = combine(mangaList, createListModeFlow()) { list, mode ->
|
||||
when(mode) {
|
||||
when (mode) {
|
||||
ListMode.LIST -> list.map { it.toListModel() }
|
||||
ListMode.DETAILED_LIST -> list.map { it.toListDetailedModel() }
|
||||
ListMode.GRID -> list.map { it.toGridModel() }
|
||||
|
||||
@@ -33,7 +33,7 @@ class RemoteListViewModel(
|
||||
private var loadingJob: Job? = null
|
||||
|
||||
override val content = combine(mangaList.drop(1), createListModeFlow()) { list, mode ->
|
||||
when(mode) {
|
||||
when (mode) {
|
||||
ListMode.LIST -> list.map { it.toListModel() }
|
||||
ListMode.DETAILED_LIST -> list.map { it.toListDetailedModel() }
|
||||
ListMode.GRID -> list.map { it.toGridModel() }
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
android:justificationMode="inter_word"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:padding="12dp"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/imageView_cover"
|
||||
app:layout_constraintTop_toBottomOf="@id/divider_top"
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
android:justificationMode="inter_word"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:padding="12dp"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/chips_tags"
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
android:visible="false"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item android:id="@+id/action_related"
|
||||
android:title="@string/related"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_browser"
|
||||
android:title="@string/open_in_browser"
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<ListPreference
|
||||
android:key="list_mode_2"
|
||||
android:entries="@array/list_modes"
|
||||
android:key="list_mode_2"
|
||||
android:title="@string/list_mode"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
app:allowDividerAbove="true"
|
||||
app:iconSpaceReserved="false" />
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SeekBarPreference
|
||||
android:key="grid_size"
|
||||
|
||||
Reference in New Issue
Block a user