diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt index 05dd66798e..87c2a8b86b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt @@ -160,6 +160,9 @@ class CatalogueController : NucleusController(), if (state == BottomSheetBehavior.STATE_COLLAPSED) 1f else 0f showingExtenions = state == BottomSheetBehavior.STATE_EXPANDED setTitle() + if (state == BottomSheetBehavior.STATE_EXPANDED) + ext_bottom_sheet.fetchOnlineExtensionsIfNeeded() + else ext_bottom_sheet.shouldCallApi = true activity?.invalidateOptionsMenu() } @@ -177,6 +180,7 @@ class CatalogueController : NucleusController(), fun showExtensions() { ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED + ext_bottom_sheet.fetchOnlineExtensionsIfNeeded() } fun toggleExtensions() { @@ -184,6 +188,7 @@ class CatalogueController : NucleusController(), ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED } else { ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED + ext_bottom_sheet.fetchOnlineExtensionsIfNeeded() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt index 807c6baac9..172d8d8d65 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt @@ -38,7 +38,7 @@ open class ExtensionBottomPresenter( private var currentDownloads = hashMapOf() fun onCreate() { - extensionManager.findAvailableExtensions() + // extensionManager.findAvailableExtensions() bindToExtensionsObservable() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomSheet.kt index 7802e9c166..f7845d8ce3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomSheet.kt @@ -31,7 +31,9 @@ ExtensionAdapter.OnButtonClickListener, ExtensionTrustDialog.Listener { var sheetBehavior: BottomSheetBehavior<*>? = null - lateinit var autoCheckItem: AutoCheckItem + private lateinit var autoCheckItem: AutoCheckItem + + var shouldCallApi = true /** * Adapter containing the list of manga from the catalogue. @@ -71,6 +73,7 @@ ExtensionAdapter.OnButtonClickListener, sheet_layout.setOnClickListener { if (sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED) { sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED + fetchOnlineExtensionsIfNeeded() } else { sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED } @@ -78,6 +81,13 @@ ExtensionAdapter.OnButtonClickListener, presenter.getExtensionUpdateCount() } + fun fetchOnlineExtensionsIfNeeded() { + if (shouldCallApi) { + presenter.findAvailableExtensions() + shouldCallApi = false + } + } + fun updateExtTitle() { val extCount = presenter.getExtensionUpdateCount() title_text.text = if (extCount == 0) context.getString(R.string.label_extensions)