diff --git a/app/src/main/java/com/beemdevelopment/aegis/helpers/FabScrollHelper.java b/app/src/main/java/com/beemdevelopment/aegis/helpers/FabScrollHelper.java index b703ba01..8f646da8 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/helpers/FabScrollHelper.java +++ b/app/src/main/java/com/beemdevelopment/aegis/helpers/FabScrollHelper.java @@ -18,32 +18,41 @@ public class FabScrollHelper { public void onScroll(int dx, int dy) { if (dy > 0 && _fabMenu.getVisibility() == View.VISIBLE && !_isAnimating) { - _isAnimating = true; - CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) _fabMenu.getLayoutParams(); - int fabBottomMargin = lp.bottomMargin; + setVisible(false); + } else if (dy < 0 && _fabMenu.getVisibility() != View.VISIBLE && !_isAnimating) { + setVisible(true); + } + } + + public void setVisible(boolean visible) { + if (visible) { + _fabMenu.setVisibility(View.VISIBLE); _fabMenu.animate() - .translationY(_fabMenu.getHeight() + fabBottomMargin) - .setInterpolator(new AccelerateInterpolator(2)) + .translationY(0) + .setInterpolator(new DecelerateInterpolator(2)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { _isAnimating = false; - _fabMenu.setVisibility(View.INVISIBLE); super.onAnimationEnd(animation); } }).start(); - } else if (dy < 0 && _fabMenu.getVisibility() != View.VISIBLE && !_isAnimating) { - _fabMenu.setVisibility(View.VISIBLE); + } else { + _isAnimating = true; + CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) _fabMenu.getLayoutParams(); + int fabBottomMargin = lp.bottomMargin; _fabMenu.animate() - .translationY(0) - .setInterpolator(new DecelerateInterpolator(2)) + .translationY(_fabMenu.getHeight() + fabBottomMargin) + .setInterpolator(new AccelerateInterpolator(2)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { _isAnimating = false; + _fabMenu.setVisibility(View.INVISIBLE); super.onAnimationEnd(animation); } }).start(); } + } } diff --git a/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java b/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java index 88f0b8e9..9e02876f 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java +++ b/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java @@ -743,6 +743,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene _fabScrollHelper.onScroll(dx, dy); } + @Override + public void onListChange() { _fabScrollHelper.setVisible(true); } + @Override public void onLocked() { if (_actionMode != null) { diff --git a/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryAdapter.java b/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryAdapter.java index 4f386063..76f10b02 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryAdapter.java +++ b/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryAdapter.java @@ -132,6 +132,7 @@ public class EntryAdapter extends RecyclerView.Adapter implements I } } + _view.onListChange(); checkPeriodUniformity(); } @@ -150,6 +151,7 @@ public class EntryAdapter extends RecyclerView.Adapter implements I notifyItemRemoved(position); } + _view.onListChange(); checkPeriodUniformity(); } @@ -275,6 +277,7 @@ public class EntryAdapter extends RecyclerView.Adapter implements I Collections.sort(_shownEntries, comparator); } + _view.onListChange(); notifyDataSetChanged(); } @@ -612,5 +615,6 @@ public class EntryAdapter extends RecyclerView.Adapter implements I void onPeriodUniformityChanged(boolean uniform, int period); void onSelect(VaultEntry entry); void onDeselect(VaultEntry entry); + void onListChange(); } } diff --git a/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryListView.java b/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryListView.java index 50f990c0..290a498e 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryListView.java +++ b/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryListView.java @@ -245,6 +245,9 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener { } } + @Override + public void onListChange() { _listener.onListChange(); } + public void setCodeGroupSize(int codeGrouping) { _adapter.setCodeGroupSize(codeGrouping); } @@ -348,6 +351,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener { void onScroll(int dx, int dy); void onSelect(VaultEntry entry); void onDeselect(VaultEntry entry); + void onListChange(); } private class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration {