From 290fdc0c96a468079241e0fb6a90d7ad527f4783 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 13 Dec 2018 20:59:51 +0000 Subject: [PATCH] hide new transaction fab on scroll --- .../main/java/net/ktnx/mobileledger/AccountSummary.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java index b6b3cfd0..77a60074 100644 --- a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java +++ b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java @@ -7,6 +7,8 @@ import android.content.pm.PackageInfo; import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.annotation.NonNull; +import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; @@ -97,6 +99,13 @@ public class AccountSummary extends AppCompatActivity { } })); + root.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { + if (dy < 0) ((FloatingActionButton) findViewById(R.id.btn_add_transaction)).show(); + if (dy > 0) ((FloatingActionButton) findViewById(R.id.btn_add_transaction)).hide(); + } + }); ((SwipeRefreshLayout) findViewById(R.id.account_swiper)).setOnRefreshListener(() -> { Log.d("ui", "refreshing accounts via swipe"); update_accounts(true); -- 2.39.5