From 78de11a9e3d0b09698ad7605e798c2ab8a8c7606 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 7 Nov 2021 17:58:45 +0100 Subject: [PATCH] Fix SwipeRefresh initial position in MangaController (#6211) * Lower position of swipe refresh * Tweak existing code that sets swipe refresh position --- .../tachiyomi/ui/manga/MangaController.kt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 4792cc938..d1628f3cf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -18,6 +18,7 @@ import androidx.annotation.FloatRange import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.view.ActionMode import androidx.core.os.bundleOf +import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.doOnLayout import androidx.core.view.isVisible @@ -291,17 +292,13 @@ class MangaController : } } - binding.swipeRefresh.doOnLayout { swipeRefresh -> + ViewCompat.setOnApplyWindowInsetsListener(binding.swipeRefresh) { swipeRefresh, windowInsets -> swipeRefresh as SwipeRefreshLayout - swipeRefresh.setOnApplyWindowInsetsListener { _, windowInsets -> - val topStatusBarInset = WindowInsetsCompat.toWindowInsetsCompat(windowInsets) - .getInsets(WindowInsetsCompat.Type.statusBars()) - .top - swipeRefresh.isRefreshing = false - swipeRefresh.setProgressViewEndTarget(false, getMainAppBarHeight() + topStatusBarInset) - updateRefreshing() - windowInsets - } + val insets = windowInsets.getInsets(WindowInsetsCompat.Type.statusBars()) + swipeRefresh.isRefreshing = false + swipeRefresh.setProgressViewEndTarget(false, getMainAppBarHeight() + insets.top) + updateRefreshing() + windowInsets } }