Skip to content

Commit

Permalink
Fast Scroller Creation #2 Part 2
Browse files Browse the repository at this point in the history
*Only show Fast Scroller when there are enough notes to scroll.
  • Loading branch information
rayliverified committed Feb 23, 2018
1 parent 6764f93 commit e7e5dc2
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions app/src/main/java/stream/rocketnotes/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,28 +161,31 @@ private void InitializeRecyclerView() {
mRecyclerView.setLayoutManager(mStaggeredLayoutManager);
mRecyclerView.setAdapter(mAdapter);

//Create FastScroller.
FastScroller fastScroller = findViewById(R.id.fast_scroller);
fastScroller.setAutoHideEnabled(true); //true is the default value
fastScroller.setAutoHideDelayInMillis(500L); //1000ms is the default value
fastScroller.setIgnoreTouchesOutsideHandle(false); //false is the default value
//0 pixel is the default value. When > 0 it mimics the fling gesture
fastScroller.setMinimumScrollThreshold(100);
fastScroller.setBubbleAndHandleColor(ContextCompat.getColor(mContext, R.color.colorPrimary));
fastScroller.addOnScrollStateChangeListener(new FastScroller.OnScrollStateChangeListener() {
@Override
public void onFastScrollerStateChange(boolean scrolling) {
if (scrolling)
{
mFAB.hide();
}
else
{
mFAB.show();
if (myItems.size() >= 20)
{
//Create FastScroller.
FastScroller fastScroller = findViewById(R.id.fast_scroller);
fastScroller.setAutoHideEnabled(true); //true is the default value
fastScroller.setAutoHideDelayInMillis(500L); //1000ms is the default value
fastScroller.setIgnoreTouchesOutsideHandle(false); //false is the default value
//0 pixel is the default value. When > 0 it mimics the fling gesture
fastScroller.setMinimumScrollThreshold(100);
fastScroller.setBubbleAndHandleColor(ContextCompat.getColor(mContext, R.color.colorPrimary));
fastScroller.addOnScrollStateChangeListener(new FastScroller.OnScrollStateChangeListener() {
@Override
public void onFastScrollerStateChange(boolean scrolling) {
if (scrolling)
{
mFAB.hide();
}
else
{
mFAB.show();
}
}
}
});
mAdapter.setFastScroller(fastScroller);
});
mAdapter.setFastScroller(fastScroller);
}
}

private void SetupSearchBar() {
Expand Down

0 comments on commit e7e5dc2

Please sign in to comment.