Back to project page Jaguar.
The source code is released under:
Apache License
If you think the Android project Jaguar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.richard.jaguar; /* w w w. ja va 2s. c om*/ import android.content.Context; import android.os.Build; import android.util.AttributeSet; import android.widget.ScrollView; /** * Created by u0165547 on 11/3/2014. */ public class ObservableScrollView extends ScrollView implements ObservableScrollable { // Edge-effects don't mix well with the translucent action bar in Android 2.X private boolean mDisableEdgeEffects = true; /* public interface ObservableScrollable { void setOnScrollChangedCallback(OnScrollChangedCallback callback); } public interface OnScrollChangedCallback { void onScroll(int l, int t); }*/ private OnScrollChangedCallback mOnScrollChangedListener; public ObservableScrollView(Context context) { super(context); } public ObservableScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public ObservableScrollView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); if (mOnScrollChangedListener != null) { mOnScrollChangedListener.onScroll(l, t); } } @Override protected float getTopFadingEdgeStrength() { // http://stackoverflow.com/a/6894270/244576 if (mDisableEdgeEffects && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { return 0.0f; } return super.getTopFadingEdgeStrength(); } @Override protected float getBottomFadingEdgeStrength() { // http://stackoverflow.com/a/6894270/244576 if (mDisableEdgeEffects && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { return 0.0f; } return super.getBottomFadingEdgeStrength(); } @Override public void setOnScrollChangedCallback(OnScrollChangedCallback callback) { mOnScrollChangedListener = callback; } }