Skip to content
This repository has been archived by the owner on Apr 19, 2018. It is now read-only.

Updated deprecated calls #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 22 additions & 26 deletions library/src/com/viewpagerindicator/CirclePageIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewConfigurationCompat;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
Expand Down Expand Up @@ -104,13 +102,13 @@ public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {

Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
setBackgroundDrawable(background);
}

a.recycle();

final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
mTouchSlop = configuration.getScaledPagingTouchSlop();
}


Expand Down Expand Up @@ -286,16 +284,16 @@ public boolean onTouchEvent(android.view.MotionEvent ev) {
return false;
}

final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
final int action = ev.getAction() & MotionEvent.ACTION_MASK;
switch (action) {
case MotionEvent.ACTION_DOWN:
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
mActivePointerId = ev.getPointerId(0);
mLastMotionX = ev.getX();
break;

case MotionEvent.ACTION_MOVE: {
final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
final float x = MotionEventCompat.getX(ev, activePointerIndex);
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
final float x = ev.getX(activePointerIndex);
final float deltaX = x - mLastMotionX;

if (!mIsDragging) {
Expand Down Expand Up @@ -340,21 +338,21 @@ public boolean onTouchEvent(android.view.MotionEvent ev) {
if (mViewPager.isFakeDragging()) mViewPager.endFakeDrag();
break;

case MotionEventCompat.ACTION_POINTER_DOWN: {
final int index = MotionEventCompat.getActionIndex(ev);
mLastMotionX = MotionEventCompat.getX(ev, index);
mActivePointerId = MotionEventCompat.getPointerId(ev, index);
case MotionEvent.ACTION_POINTER_DOWN: {
final int index = ev.getActionIndex();
mLastMotionX = ev.getX(index);
mActivePointerId = ev.getPointerId(index);
break;
}

case MotionEventCompat.ACTION_POINTER_UP:
final int pointerIndex = MotionEventCompat.getActionIndex(ev);
final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
case MotionEvent.ACTION_POINTER_UP:
final int pointerIndex = ev.getActionIndex();
final int pointerId = ev.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
mActivePointerId = ev.getPointerId(newPointerIndex);
}
mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
mLastMotionX = ev.getX(ev.findPointerIndex(mActivePointerId));
break;
}

Expand All @@ -367,13 +365,13 @@ public void setViewPager(ViewPager view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
mViewPager.addOnPageChangeListener(null);
}
if (view.getAdapter() == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
mViewPager.setOnPageChangeListener(this);
mViewPager.addOnPageChangeListener(this);
invalidate();
}

Expand Down Expand Up @@ -453,8 +451,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
/**
* Determines the width of this view
*
* @param measureSpec
* A measureSpec packed into an int
* @param measureSpec A measureSpec packed into an int
* @return The width of the view, honoring constraints from measureSpec
*/
private int measureLong(int measureSpec) {
Expand All @@ -468,7 +465,7 @@ private int measureLong(int measureSpec) {
} else {
//Calculate the width according the views count
final int count = mViewPager.getAdapter().getCount();
result = (int)(getPaddingLeft() + getPaddingRight()
result = (int) (getPaddingLeft() + getPaddingRight()
+ (count * 2 * mRadius) + (count - 1) * mRadius + 1);
//Respect AT_MOST value if that was what is called for by measureSpec
if (specMode == MeasureSpec.AT_MOST) {
Expand All @@ -481,8 +478,7 @@ private int measureLong(int measureSpec) {
/**
* Determines the height of this view
*
* @param measureSpec
* A measureSpec packed into an int
* @param measureSpec A measureSpec packed into an int
* @return The height of the view, honoring constraints from measureSpec
*/
private int measureShort(int measureSpec) {
Expand All @@ -495,7 +491,7 @@ private int measureShort(int measureSpec) {
result = specSize;
} else {
//Measure the height
result = (int)(2 * mRadius + getPaddingTop() + getPaddingBottom() + 1);
result = (int) (2 * mRadius + getPaddingTop() + getPaddingBottom() + 1);
//Respect AT_MOST value if that was what is called for by measureSpec
if (specMode == MeasureSpec.AT_MOST) {
result = Math.min(result, specSize);
Expand All @@ -506,7 +502,7 @@ private int measureShort(int measureSpec) {

@Override
public void onRestoreInstanceState(Parcelable state) {
SavedState savedState = (SavedState)state;
SavedState savedState = (SavedState) state;
super.onRestoreInstanceState(savedState.getSuperState());
mCurrentPage = savedState.currentPage;
mSnapPage = savedState.currentPage;
Expand Down
4 changes: 2 additions & 2 deletions library/src/com/viewpagerindicator/IconPageIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ public void setViewPager(ViewPager view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
mViewPager.addOnPageChangeListener(null);
}
PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
view.addOnPageChangeListener(this);
notifyDataSetChanged();
}

Expand Down
41 changes: 19 additions & 22 deletions library/src/com/viewpagerindicator/LinePageIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewConfigurationCompat;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
Expand Down Expand Up @@ -88,13 +85,13 @@ public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {

Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
setBackgroundDrawable(background);
}

a.recycle();

final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
mTouchSlop = configuration.getScaledPagingTouchSlop();
}


Expand Down Expand Up @@ -198,16 +195,16 @@ public boolean onTouchEvent(android.view.MotionEvent ev) {
return false;
}

final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
final int action = ev.getAction() & MotionEvent.ACTION_MASK;
switch (action) {
case MotionEvent.ACTION_DOWN:
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
mActivePointerId = ev.getPointerId(0);
mLastMotionX = ev.getX();
break;

case MotionEvent.ACTION_MOVE: {
final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
final float x = MotionEventCompat.getX(ev, activePointerIndex);
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
final float x = ev.getX(activePointerIndex);
final float deltaX = x - mLastMotionX;

if (!mIsDragging) {
Expand Down Expand Up @@ -252,21 +249,21 @@ public boolean onTouchEvent(android.view.MotionEvent ev) {
if (mViewPager.isFakeDragging()) mViewPager.endFakeDrag();
break;

case MotionEventCompat.ACTION_POINTER_DOWN: {
final int index = MotionEventCompat.getActionIndex(ev);
mLastMotionX = MotionEventCompat.getX(ev, index);
mActivePointerId = MotionEventCompat.getPointerId(ev, index);
case MotionEvent.ACTION_POINTER_DOWN: {
final int index = ev.getActionIndex();
mLastMotionX = ev.getX(index);
mActivePointerId = ev.getPointerId(index);
break;
}

case MotionEventCompat.ACTION_POINTER_UP:
final int pointerIndex = MotionEventCompat.getActionIndex(ev);
final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
case MotionEvent.ACTION_POINTER_UP:
final int pointerIndex = ev.getActionIndex();
final int pointerId = ev.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
mActivePointerId = ev.getPointerId(newPointerIndex);
}
mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
mLastMotionX = ev.getX(ev.findPointerIndex(mActivePointerId));
break;
}

Expand All @@ -280,13 +277,13 @@ public void setViewPager(ViewPager viewPager) {
}
if (mViewPager != null) {
//Clear us from the old pager.
mViewPager.setOnPageChangeListener(null);
mViewPager.addOnPageChangeListener(null);
}
if (viewPager.getAdapter() == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = viewPager;
mViewPager.setOnPageChangeListener(this);
mViewPager.addOnPageChangeListener(this);
invalidate();
}

Expand Down Expand Up @@ -369,7 +366,7 @@ private int measureWidth(int measureSpec) {
result = Math.min(result, specSize);
}
}
return (int)FloatMath.ceil(result);
return (int)Math.ceil(result);
}

/**
Expand All @@ -395,7 +392,7 @@ private int measureHeight(int measureSpec) {
result = Math.min(result, specSize);
}
}
return (int)FloatMath.ceil(result);
return (int)Math.ceil(result);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions library/src/com/viewpagerindicator/TabPageIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ public void setViewPager(ViewPager view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
mViewPager.addOnPageChangeListener(null);
}
final PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
view.addOnPageChangeListener(this);
notifyDataSetChanged();
}

Expand Down
Loading