mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-22 23:09:13 +00:00
Fix hidden FAB when list changes
This commit is contained in:
parent
57ef52d6ff
commit
7d063104dd
4 changed files with 32 additions and 12 deletions
|
@ -18,6 +18,26 @@ public class FabScrollHelper {
|
||||||
|
|
||||||
public void onScroll(int dx, int dy) {
|
public void onScroll(int dx, int dy) {
|
||||||
if (dy > 0 && _fabMenu.getVisibility() == View.VISIBLE && !_isAnimating) {
|
if (dy > 0 && _fabMenu.getVisibility() == View.VISIBLE && !_isAnimating) {
|
||||||
|
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(0)
|
||||||
|
.setInterpolator(new DecelerateInterpolator(2))
|
||||||
|
.setListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
_isAnimating = false;
|
||||||
|
super.onAnimationEnd(animation);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
} else {
|
||||||
_isAnimating = true;
|
_isAnimating = true;
|
||||||
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) _fabMenu.getLayoutParams();
|
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) _fabMenu.getLayoutParams();
|
||||||
int fabBottomMargin = lp.bottomMargin;
|
int fabBottomMargin = lp.bottomMargin;
|
||||||
|
@ -32,18 +52,7 @@ public class FabScrollHelper {
|
||||||
super.onAnimationEnd(animation);
|
super.onAnimationEnd(animation);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
} else if (dy < 0 && _fabMenu.getVisibility() != View.VISIBLE && !_isAnimating) {
|
|
||||||
_fabMenu.setVisibility(View.VISIBLE);
|
|
||||||
_fabMenu.animate()
|
|
||||||
.translationY(0)
|
|
||||||
.setInterpolator(new DecelerateInterpolator(2))
|
|
||||||
.setListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
_isAnimating = false;
|
|
||||||
super.onAnimationEnd(animation);
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,6 +743,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
_fabScrollHelper.onScroll(dx, dy);
|
_fabScrollHelper.onScroll(dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onListChange() { _fabScrollHelper.setVisible(true); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocked() {
|
public void onLocked() {
|
||||||
if (_actionMode != null) {
|
if (_actionMode != null) {
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_view.onListChange();
|
||||||
checkPeriodUniformity();
|
checkPeriodUniformity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +149,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_view.onListChange();
|
||||||
checkPeriodUniformity();
|
checkPeriodUniformity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +275,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
Collections.sort(_shownEntries, comparator);
|
Collections.sort(_shownEntries, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_view.onListChange();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,5 +563,6 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
void onPeriodUniformityChanged(boolean uniform, int period);
|
void onPeriodUniformityChanged(boolean uniform, int period);
|
||||||
void onSelect(VaultEntry entry);
|
void onSelect(VaultEntry entry);
|
||||||
void onDeselect(VaultEntry entry);
|
void onDeselect(VaultEntry entry);
|
||||||
|
void onListChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,6 +236,9 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onListChange() { _listener.onListChange(); }
|
||||||
|
|
||||||
public void setCodeGroupSize(int codeGrouping) {
|
public void setCodeGroupSize(int codeGrouping) {
|
||||||
_adapter.setCodeGroupSize(codeGrouping);
|
_adapter.setCodeGroupSize(codeGrouping);
|
||||||
}
|
}
|
||||||
|
@ -339,6 +342,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
void onScroll(int dx, int dy);
|
void onScroll(int dx, int dy);
|
||||||
void onSelect(VaultEntry entry);
|
void onSelect(VaultEntry entry);
|
||||||
void onDeselect(VaultEntry entry);
|
void onDeselect(VaultEntry entry);
|
||||||
|
void onListChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration {
|
private class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration {
|
||||||
|
|
Loading…
Add table
Reference in a new issue