finish off recommendations
(cherry picked from commit 6473bcd32242abf8ba50b3ac76562ae6b931d0cd) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt
This commit is contained in:
parent
4c5e99142f
commit
f0b821b122
@ -284,7 +284,7 @@ class SourceController(bundle: Bundle? = null) :
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
data class SmartSearchConfig(val origTitle: String, val origMangaId: Long) : Parcelable
|
||||
data class SmartSearchConfig(val origTitle: String, val origMangaId: Long? = null) : Parcelable
|
||||
|
||||
enum class Mode {
|
||||
CATALOGUE,
|
||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.browse.source.browse
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
@ -360,7 +361,6 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
inflater.inflate(R.menu.source_browse, menu)
|
||||
|
||||
if (mode == Mode.RECOMMENDS) {
|
||||
menu.findItem(R.id.action_set_filter).isVisible = false
|
||||
menu.findItem(R.id.action_search).isVisible = false
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
super.onPrepareOptionsMenu(menu)
|
||||
|
||||
val isHttpSource = presenter.source is HttpSource
|
||||
menu.findItem(R.id.action_open_in_web_view).isVisible = isHttpSource && mode == Mode.CATALOGUE
|
||||
menu.findItem(R.id.action_open_in_web_view).isVisible = isHttpSource
|
||||
|
||||
val isLocalSource = presenter.source is LocalSource
|
||||
menu.findItem(R.id.action_local_source_help).isVisible = isLocalSource && mode == Mode.CATALOGUE
|
||||
@ -473,11 +473,16 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
*/
|
||||
fun onAddPageError(error: Throwable) {
|
||||
XLog.w("> Failed to load next catalogue page!", error)
|
||||
XLog.w(
|
||||
"> (source.id: %s, source.name: %s)",
|
||||
presenter.source.id,
|
||||
presenter.source.name
|
||||
)
|
||||
|
||||
if (mode == Mode.CATALOGUE) {
|
||||
XLog.w(
|
||||
"> (source.id: %s, source.name: %s)",
|
||||
presenter.source.id,
|
||||
presenter.source.name
|
||||
)
|
||||
} else {
|
||||
XLog.w("> Recommendations")
|
||||
}
|
||||
|
||||
val adapter = adapter ?: return
|
||||
adapter.onLoadMoreComplete(null)
|
||||
@ -497,6 +502,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
}
|
||||
|
||||
if (adapter.isEmpty) {
|
||||
Log.d("Adapter", "empty")
|
||||
val actions = emptyList<EmptyView.Action>().toMutableList()
|
||||
|
||||
if (presenter.source is LocalSource && mode == Mode.CATALOGUE) {
|
||||
@ -640,16 +646,33 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
*/
|
||||
override fun onItemClick(view: View, position: Int): Boolean {
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return false
|
||||
router.pushController(
|
||||
MangaController(
|
||||
item.manga, true,
|
||||
args.getParcelable(SMART_SEARCH_CONFIG_KEY)
|
||||
).withFadeTransaction()
|
||||
)
|
||||
|
||||
when (mode) {
|
||||
Mode.CATALOGUE -> router.pushController(
|
||||
MangaController(
|
||||
item.manga,
|
||||
true,
|
||||
args.getParcelable(SMART_SEARCH_CONFIG_KEY)
|
||||
).withFadeTransaction()
|
||||
)
|
||||
Mode.RECOMMENDS -> openSmartSearch(item.manga.title)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// AZ -->
|
||||
private fun openSmartSearch(title: String) {
|
||||
val smartSearchConfig = SourceController.SmartSearchConfig(title)
|
||||
router.pushController(
|
||||
SourceController(
|
||||
Bundle().apply {
|
||||
putParcelable(SourceController.SMART_SEARCH_CONFIG, smartSearchConfig)
|
||||
}
|
||||
).withFadeTransaction()
|
||||
)
|
||||
}
|
||||
|
||||
// AZ <--
|
||||
/**
|
||||
* Called when a manga is long clicked.
|
||||
*
|
||||
@ -660,6 +683,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
* @param position the position of the element clicked.
|
||||
*/
|
||||
override fun onItemLongClick(position: Int) {
|
||||
if (mode == Mode.RECOMMENDS) { return }
|
||||
val activity = activity ?: return
|
||||
val manga = (adapter?.getItem(position) as? SourceItem?)?.manga ?: return
|
||||
|
||||
|
@ -154,7 +154,9 @@ open class BrowseSourcePresenter(
|
||||
subscribeToMangaInitializer()
|
||||
|
||||
// Create a new pager.
|
||||
pager = if (recommends) RecommendsPager(searchQuery!!) else createPager(query, filters)
|
||||
pager = if (recommends) RecommendsPager(
|
||||
query
|
||||
) else createPager(query, filters)
|
||||
|
||||
val sourceId = source.id
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package eu.kanade.tachiyomi.ui.source.browse
|
||||
package eu.kanade.tachiyomi.ui.browse.source.browse
|
||||
|
||||
import android.util.Log
|
||||
import com.github.salomonbrys.kotson.array
|
||||
@ -82,11 +82,7 @@ open class RecommendsPager(val title: String) : Pager() {
|
||||
}.map {
|
||||
MangasPage(it, false)
|
||||
}.doOnNext {
|
||||
if (it.mangas.isNotEmpty()) {
|
||||
onPageReceived(it)
|
||||
} else {
|
||||
throw NoResultsException()
|
||||
}
|
||||
onPageReceived(it)
|
||||
}
|
||||
}
|
||||
companion object {
|
@ -227,7 +227,7 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||
.launchIn(scope)
|
||||
}
|
||||
smartSearchConfig?.let { smartSearchConfig ->
|
||||
binding.mergeBtn.visible()
|
||||
if (smartSearchConfig.origMangaId != null) { binding.mergeBtn.visible() }
|
||||
binding.mergeBtn.clicks()
|
||||
.onEach {
|
||||
// Init presenter here to avoid threading issues
|
||||
@ -236,7 +236,7 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||
launch {
|
||||
try {
|
||||
val mergedManga = withContext(Dispatchers.IO + NonCancellable) {
|
||||
presenter.smartSearchMerge(presenter.manga, smartSearchConfig.origMangaId)
|
||||
presenter.smartSearchMerge(presenter.manga, smartSearchConfig.origMangaId!!)
|
||||
}
|
||||
|
||||
parentController?.router?.pushController(
|
||||
|
Loading…
x
Reference in New Issue
Block a user