From 8b9e9651d6c9ea6ed0cbf2446f050c602742c502 Mon Sep 17 00:00:00 2001 From: Jean-BaptisteC Date: Fri, 15 Mar 2024 19:44:42 +0100 Subject: [PATCH] Add auto hide on floating button Signed-off-by: Jean-BaptisteC --- .../downloader/DownloaderFragment.java | 14 ++++++ .../main/res/layout/fragment_downloader.xml | 47 ++++++++----------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/android/app/src/main/java/app/organicmaps/downloader/DownloaderFragment.java b/android/app/src/main/java/app/organicmaps/downloader/DownloaderFragment.java index f1114a9fc8..8fa3119ca8 100644 --- a/android/app/src/main/java/app/organicmaps/downloader/DownloaderFragment.java +++ b/android/app/src/main/java/app/organicmaps/downloader/DownloaderFragment.java @@ -1,6 +1,7 @@ package app.organicmaps.downloader; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.view.View; import android.view.WindowManager; @@ -19,6 +20,7 @@ import app.organicmaps.search.SearchEngine; import app.organicmaps.widget.PlaceholderView; import app.organicmaps.util.bottomsheet.MenuBottomSheetFragment; import app.organicmaps.util.bottomsheet.MenuBottomSheetItem; +import com.google.android.material.floatingactionbutton.FloatingActionButton; import java.util.ArrayList; import java.util.List; @@ -38,6 +40,8 @@ public class DownloaderFragment extends BaseMwmRecyclerFragment= Build.VERSION_CODES.M) + { + getRecyclerView().setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> { + if (scrollY > oldScrollY) + mFab.hide(); + else + mFab.show(); + }); + } mSubscriberSlot = MapManager.nativeSubscribe(new MapManager.StorageCallback() { @Override diff --git a/android/app/src/main/res/layout/fragment_downloader.xml b/android/app/src/main/res/layout/fragment_downloader.xml index 1ba2c6c5e8..b62de1d71d 100644 --- a/android/app/src/main/res/layout/fragment_downloader.xml +++ b/android/app/src/main/res/layout/fragment_downloader.xml @@ -1,5 +1,5 @@ - - -