Added option to hide action bar on scrolling down

This commit is contained in:
M66B
2020-03-04 11:14:20 +01:00
parent f40e4ec17d
commit a15a10a8a1
6 changed files with 114 additions and 3 deletions

View File

@@ -155,9 +155,35 @@ public class FragmentFolders extends FragmentBase {
});
rvFolder.setHasFixedSize(false);
LinearLayoutManager llm = new LinearLayoutManager(getContext());
LinearLayoutManager llm = new LinearLayoutManager(getContext()) {
@Override
public void onScrollStateChanged(int state) {
super.onScrollStateChanged(state);
try {
int y = rvFolder.computeVerticalScrollOffset();
Log.i("Scroll state=" + state + " y=" + y);
setActionBar(y == 0);
} catch (Throwable ex) {
Log.w(ex);
}
}
};
rvFolder.setLayoutManager(llm);
rvFolder.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
try {
int y = rvFolder.computeVerticalScrollOffset();
Log.i("Layout completed y=" + y);
setActionBar(y == 0);
} catch (Throwable ex) {
Log.w(ex);
}
}
});
if (!cards) {
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) {
@Override