|
|
|
@ -29,7 +29,7 @@ import org.koitharu.kotatsu.parsers.model.MangaSource
|
|
|
|
import org.koitharu.kotatsu.search.domain.SearchKind
|
|
|
|
import org.koitharu.kotatsu.search.domain.SearchKind
|
|
|
|
|
|
|
|
|
|
|
|
@AndroidEntryPoint
|
|
|
|
@AndroidEntryPoint
|
|
|
|
class RemoteListFragment : MangaListFragment(), FilterCoordinator.Owner {
|
|
|
|
class RemoteListFragment : MangaListFragment(), FilterCoordinator.Owner, View.OnClickListener {
|
|
|
|
|
|
|
|
|
|
|
|
override val viewModel by viewModels<RemoteListViewModel>()
|
|
|
|
override val viewModel by viewModels<RemoteListViewModel>()
|
|
|
|
|
|
|
|
|
|
|
|
@ -42,6 +42,7 @@ class RemoteListFragment : MangaListFragment(), FilterCoordinator.Owner {
|
|
|
|
addMenuProvider(MangaSearchMenuProvider(filterCoordinator, viewModel))
|
|
|
|
addMenuProvider(MangaSearchMenuProvider(filterCoordinator, viewModel))
|
|
|
|
viewModel.isRandomLoading.observe(viewLifecycleOwner, MenuInvalidator(requireActivity()))
|
|
|
|
viewModel.isRandomLoading.observe(viewLifecycleOwner, MenuInvalidator(requireActivity()))
|
|
|
|
viewModel.onOpenManga.observeEvent(viewLifecycleOwner) { router.openDetails(it) }
|
|
|
|
viewModel.onOpenManga.observeEvent(viewLifecycleOwner) { router.openDetails(it) }
|
|
|
|
|
|
|
|
viewModel.onSourceBroken.observeEvent(viewLifecycleOwner) { showSourceBrokenWarning() }
|
|
|
|
filterCoordinator.observe().distinctUntilChangedBy { it.listFilter.isEmpty() }
|
|
|
|
filterCoordinator.observe().distinctUntilChangedBy { it.listFilter.isEmpty() }
|
|
|
|
.drop(1)
|
|
|
|
.drop(1)
|
|
|
|
.observe(viewLifecycleOwner) {
|
|
|
|
.observe(viewLifecycleOwner) {
|
|
|
|
@ -87,6 +88,8 @@ class RemoteListFragment : MangaListFragment(), FilterCoordinator.Owner {
|
|
|
|
openInBrowser(error.getCauseUrl())
|
|
|
|
openInBrowser(error.getCauseUrl())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onClick(v: View?) = Unit // from Snackbar, do nothing
|
|
|
|
|
|
|
|
|
|
|
|
private fun openInBrowser(url: String?) {
|
|
|
|
private fun openInBrowser(url: String?) {
|
|
|
|
if (url?.isHttpUrl() == true) {
|
|
|
|
if (url?.isHttpUrl() == true) {
|
|
|
|
router.openBrowser(
|
|
|
|
router.openBrowser(
|
|
|
|
@ -100,6 +103,16 @@ class RemoteListFragment : MangaListFragment(), FilterCoordinator.Owner {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun showSourceBrokenWarning() {
|
|
|
|
|
|
|
|
val snackbar = Snackbar.make(
|
|
|
|
|
|
|
|
viewBinding?.recyclerView ?: return,
|
|
|
|
|
|
|
|
R.string.source_broken_warning,
|
|
|
|
|
|
|
|
Snackbar.LENGTH_INDEFINITE,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
snackbar.setAction(R.string.got_it, this)
|
|
|
|
|
|
|
|
snackbar.show()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private inner class RemoteListMenuProvider : MenuProvider {
|
|
|
|
private inner class RemoteListMenuProvider : MenuProvider {
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
|
|
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
|
|
|
|