Android Open Source - FloatingActionButton Scroll View Scroll Detector






From Project

Back to project page FloatingActionButton.

License

The source code is released under:

MIT License

If you think the Android project FloatingActionButton listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.melnykov.fab;
/*from  www  . ja  va  2 s  .  c  om*/
import android.widget.ScrollView;

abstract class ScrollViewScrollDetector implements ObservableScrollView.OnScrollChangedListener {
    private int mLastScrollY;
    private int mScrollThreshold;

    abstract void onScrollUp();

    abstract void onScrollDown();

    @Override
    public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
        boolean isSignificantDelta = Math.abs(t - mLastScrollY) > mScrollThreshold;
        if (isSignificantDelta) {
            if (t > mLastScrollY) {
                onScrollUp();
            } else {
                onScrollDown();
            }
        }
        mLastScrollY = t;
    }

    public void setScrollThreshold(int scrollThreshold) {
        mScrollThreshold = scrollThreshold;
    }
}




Java Source Code List

com.melnykov.fab.AbsListViewScrollDetector.java
com.melnykov.fab.FloatingActionButton.java
com.melnykov.fab.ObservableScrollView.java
com.melnykov.fab.RecyclerViewScrollDetector.java
com.melnykov.fab.ScrollDirectionListener.java
com.melnykov.fab.ScrollViewScrollDetector.java
com.melnykov.fab.sample.DividerItemDecoration.java
com.melnykov.fab.sample.ListViewAdapter.java
com.melnykov.fab.sample.MainActivity.java
com.melnykov.fab.sample.RecyclerViewAdapter.java