Android Open Source - FillingEffect Observable Scroll View






From Project

Back to project page FillingEffect.

License

The source code is released under:

GNU General Public License

If you think the Android project FillingEffect 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 it.federico.com.fillingeffect.views;
/* w w w.ja  va2 s  .  c om*/
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;
import it.federico.com.fillingeffect.listener.ScrollViewListener;


public class ObservableScrollView extends ScrollView {

  private ScrollViewListener mScrollViewListener = null;
  private boolean mIsEnabled = true;

  public ObservableScrollView(Context context) {
    super(context);
  }

  public ObservableScrollView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
  }

  public ObservableScrollView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public void setScrollViewListener(ScrollViewListener scrollViewListener) {
    this.mScrollViewListener = scrollViewListener;
  }

  public boolean isEnabled() {
    return mIsEnabled;
  }

  public void setEnabled(boolean isEnabled) {
    this.mIsEnabled = isEnabled;
  }

  @Override
  protected void onScrollChanged(int x, int y, int oldx, int oldy) {
    super.onScrollChanged(x, y, oldx, oldy);

    if (mScrollViewListener != null) {
      mScrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
    }
  }

  @Override
  public boolean onTouchEvent(MotionEvent ev) {
    if (mIsEnabled) {
      if (ev.getAction() == MotionEvent.ACTION_UP) {
        if (mScrollViewListener != null) {
          mScrollViewListener.onEndScroll(this);
          return false;
        }
      }
      return super.onTouchEvent(ev);
    } else {
      return false;
    }
  }

}




Java Source Code List

it.federico.com.fillingeffect.ActivityMain.java
it.federico.com.fillingeffect.FragmentMain.java
it.federico.com.fillingeffect.listener.ScrollViewListener.java
it.federico.com.fillingeffect.views.BottomCropImage.java
it.federico.com.fillingeffect.views.ObservableScrollView.java
it.federico.com.fillingeffect.views.Scroller.java