Android Open Source - DynamicViewPager Lockable View Pager






From Project

Back to project page DynamicViewPager.

License

The source code is released under:

Apache License

If you think the Android project DynamicViewPager 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 de.wackernagel.android.dynamicviewpager.view;
/*  ww  w.j a  v a 2s.c  om*/
import de.wackernagel.android.dynamicviewpager.Lockable;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class LockableViewPager extends ViewPager implements Lockable {
  private boolean locked;
  
  public LockableViewPager( final Context context ) {
    super(context);
    unlockSwiping();
  }
  
  public LockableViewPager( final Context context, final AttributeSet attrs ) {
    super(context, attrs);
    unlockSwiping();
  }
  
  @Override
  public boolean onTouchEvent( MotionEvent event )
  {
    if( !isLocked() ) {
      return super.onTouchEvent( event );
    }
    return false;
  }

  @Override
  public boolean onInterceptTouchEvent( MotionEvent event )
  {
    if( !isLocked() ) {
      return super.onInterceptTouchEvent( event );
    }
    return false;
  }

  @Override
  public void lockSwiping() {
    this.locked = true;
  }

  @Override
  public void unlockSwiping() {
    this.locked = false;
  }

  @Override
  public void toggleLock() {
    this.locked = !isLocked();
  }

  @Override
  public boolean isLocked() {
    return locked;
  }
}




Java Source Code List

de.wackernagel.android.dynamicviewpager.Lockable.java
de.wackernagel.android.dynamicviewpager.adapter.DynamicTabFragmentPagerAdapter.java
de.wackernagel.android.dynamicviewpager.view.LockableViewPager.java
de.wackernagel.dynamicviewpager.MainActivity.java
de.wackernagel.dynamicviewpager.SimpleFragment.java