From: Damyan Ivanov Date: Thu, 13 Dec 2018 20:59:51 +0000 (+0000) Subject: hide new transaction fab on scroll X-Git-Tag: v0.3~247 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=290fdc0c96a468079241e0fb6a90d7ad527f4783;p=mobile-ledger.git hide new transaction fab on scroll --- 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);