Open merged manga in webview properly
This commit is contained in:
parent
d70a8848ec
commit
b0bcad861f
@ -652,17 +652,34 @@ class MangaController :
|
||||
mangaInfoAdapter?.setTrackingCount(trackCount)
|
||||
}
|
||||
|
||||
fun openMangaInWebView() {
|
||||
val source = presenter.source as? HttpSource ?: return
|
||||
// SY -->
|
||||
fun openMergedMangaWebview() {
|
||||
val sourceManager: SourceManager = Injekt.get()
|
||||
val mergedManga = presenter.mergedManga.filterNot { it.source == MERGED_SOURCE_ID }
|
||||
val sources = mergedManga.map { sourceManager.getOrStub(it.source) }
|
||||
MaterialDialog(activity!!)
|
||||
.title(R.string.action_open_in_web_view)
|
||||
.listItemsSingleChoice(
|
||||
items = mergedManga.mapIndexed { index, _ -> sources[index].toString() }
|
||||
) { _, index, _ ->
|
||||
openMangaInWebView(mergedManga[index], sources[index] as? HttpSource)
|
||||
}
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.show()
|
||||
}
|
||||
// SY <--
|
||||
|
||||
fun openMangaInWebView(manga: Manga = presenter.manga, source: HttpSource? = presenter.source as? HttpSource) {
|
||||
source ?: return
|
||||
|
||||
val url = try {
|
||||
source.mangaDetailsRequest(presenter.manga).url.toString()
|
||||
source.mangaDetailsRequest(manga).url.toString()
|
||||
} catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
|
||||
val activity = activity ?: return
|
||||
val intent = WebViewActivity.newIntent(activity, url, source.id, presenter.manga.title)
|
||||
val intent = WebViewActivity.newIntent(activity, url, source.id, manga.title)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,8 @@ class MangaPresenter(
|
||||
|
||||
var meta: RaisedSearchMetadata? = null
|
||||
|
||||
private var mergedManga = emptyList<Manga>()
|
||||
var mergedManga = emptyList<Manga>()
|
||||
private set
|
||||
|
||||
var dedupe: Boolean = true
|
||||
|
||||
|
@ -136,7 +136,11 @@ class MangaInfoHeaderAdapter(
|
||||
if (controller.presenter.source is HttpSource) {
|
||||
binding.btnWebview.isVisible = true
|
||||
binding.btnWebview.clicks()
|
||||
.onEach { controller.openMangaInWebView() }
|
||||
.onEach {
|
||||
if (controller.presenter.source.id == MERGED_SOURCE_ID) {
|
||||
controller.openMergedMangaWebview()
|
||||
} else controller.openMangaInWebView()
|
||||
}
|
||||
.launchIn(controller.viewScope)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user