]> git.ktnx.net Git - mobile-ledger.git/commitdiff
hide new transaction fab on scroll
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 13 Dec 2018 20:59:51 +0000 (20:59 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 13 Dec 2018 20:59:51 +0000 (20:59 +0000)
app/src/main/java/net/ktnx/mobileledger/AccountSummary.java

index b6b3cfd09dfb7b4a5359c901836fdf1cc4eb1602..77a60074164a85fdad88c2e49d92de395b8a585b 100644 (file)
@@ -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);