package android.support.v4.view;
import android.view.animation.*;
import android.support.v4.widget.*;
import android.graphics.drawable.*;
import android.widget.*;
import java.lang.reflect.*;
import android.content.*;
import java.util.*;
import android.util.*;
import android.view.accessibility.*;
import android.graphics.*;
import android.database.*;
import android.content.res.*;
import android.support.v4.view.accessibility.*;
import android.view.*;
import android.os.*;
import android.support.v4.os.*;
public class ViewPager extends ViewGroup
{
private static final int CLOSE_ENOUGH = 2;
private static final Comparator<ItemInfo> COMPARATOR;
private static final boolean DEBUG = false;
private static final int DEFAULT_GUTTER_SIZE = 16;
private static final int DEFAULT_OFFSCREEN_PAGES = 1;
private static final int DRAW_ORDER_DEFAULT = 0;
private static final int DRAW_ORDER_FORWARD = 1;
private static final int DRAW_ORDER_REVERSE = 2;
private static final int INVALID_POINTER = -1;
private static final int[] LAYOUT_ATTRS;
private static final int MAX_SETTLE_DURATION = 600;
private static final int MIN_DISTANCE_FOR_FLING = 25;
private static final int MIN_FLING_VELOCITY = 400;
public static final int SCROLL_STATE_DRAGGING = 1;
public static final int SCROLL_STATE_IDLE = 0;
public static final int SCROLL_STATE_SETTLING = 2;
private static final String TAG = "ViewPager";
private static final boolean USE_CACHE;
private static final Interpolator sInterpolator;
private static final ViewPositionComparator sPositionComparator;
private int mActivePointerId;
private PagerAdapter mAdapter;
private OnAdapterChangeListener mAdapterChangeListener;
private int mBottomPageBounds;
private boolean mCalledSuper;
private int mChildHeightMeasureSpec;
private int mChildWidthMeasureSpec;
private int mCloseEnough;
private int mCurItem;
private int mDecorChildCount;
private int mDefaultGutterSize;
private int mDrawingOrder;
private ArrayList<View> mDrawingOrderedChildren;
private final Runnable mEndScrollRunnable;
private int mExpectedAdapterCount;
private long mFakeDragBeginTime;
private boolean mFakeDragging;
private boolean mFirstLayout;
private float mFirstOffset;
private int mFlingDistance;
private int mGutterSize;
private boolean mIgnoreGutter;
private boolean mInLayout;
private float mInitialMotionX;
private float mInitialMotionY;
private OnPageChangeListener mInternalPageChangeListener;
private boolean mIsBeingDragged;
private boolean mIsUnableToDrag;
private final ArrayList<ItemInfo> mItems;
private float mLastMotionX;
private float mLastMotionY;
private float mLastOffset;
private EdgeEffectCompat mLeftEdge;
private Drawable mMarginDrawable;
private int mMaximumVelocity;
private int mMinimumVelocity;
private boolean mNeedCalculatePageOffsets;
private PagerObserver mObserver;
private int mOffscreenPageLimit;
private OnPageChangeListener mOnPageChangeListener;
private int mPageMargin;
private PageTransformer mPageTransformer;
private boolean mPopulatePending;
private Parcelable mRestoredAdapterState;
private ClassLoader mRestoredClassLoader;
private int mRestoredCurItem;
private EdgeEffectCompat mRightEdge;
private int mScrollState;
private Scroller mScroller;
private boolean mScrollingCacheEnabled;
private Method mSetChildrenDrawingOrderEnabled;
private final ItemInfo mTempItem;
private final Rect mTempRect;
private int mTopPageBounds;
private int mTouchSlop;
private VelocityTracker mVelocityTracker;
static {
LAYOUT_ATTRS = new int[] { 16842931 };
COMPARATOR = new Comparator<ItemInfo>() {
@Override
public int compare(final ItemInfo itemInfo, final ItemInfo itemInfo2) {
return itemInfo.position - itemInfo2.position;
}
};
sInterpolator = (Interpolator)new Interpolator() {
public float getInterpolation(final float n) {
final float n2 = n - 1.0f;
return 1.0f + n2 * (n2 * (n2 * (n2 * n2)));
}
};
sPositionComparator = new ViewPositionComparator();
}
public ViewPager(final Context context) {
super(context);
this.mItems = new ArrayList<ItemInfo>();
this.mTempItem = new ItemInfo();
this.mTempRect = new Rect();
this.mRestoredCurItem = -1;
this.mRestoredAdapterState = null;
this.mRestoredClassLoader = null;
this.mFirstOffset = -3.4028235E38f;
this.mLastOffset = Float.MAX_VALUE;
this.mOffscreenPageLimit = 1;
this.mActivePointerId = -1;
this.mFirstLayout = true;
this.mNeedCalculatePageOffsets = false;
this.mEndScrollRunnable = new Runnable() {
@Override
public void run() {
ViewPager.this.setScrollState(0);
ViewPager.this.populate();
}
};
this.mScrollState = 0;
this.initViewPager();
}
public ViewPager(final Context context, final AttributeSet set) {
super(context, set);
this.mItems = new ArrayList<ItemInfo>();
this.mTempItem = new ItemInfo();
this.mTempRect = new Rect();
this.mRestoredCurItem = -1;
this.mRestoredAdapterState = null;
this.mRestoredClassLoader = null;
this.mFirstOffset = -3.4028235E38f;
this.mLastOffset = Float.MAX_VALUE;
this.mOffscreenPageLimit = 1;
this.mActivePointerId = -1;
this.mFirstLayout = true;
this.mNeedCalculatePageOffsets = false;
this.mEndScrollRunnable = new Runnable() {
@Override
public void run() {
ViewPager.this.setScrollState(0);
ViewPager.this.populate();
}
};
this.mScrollState = 0;
this.initViewPager();
}
private void calculatePageOffsets(final ItemInfo itemInfo, final int n, final ItemInfo itemInfo2) {
final int count = this.mAdapter.getCount();
final int clientWidth = this.getClientWidth();
float n2;
if (clientWidth > 0) {
n2 = this.mPageMargin / clientWidth;
}
else {
n2 = 0.0f;
}
if (itemInfo2 != null) {
final int position = itemInfo2.position;
if (position < itemInfo.position) {
int n3 = 0;
float offset = n2 + (itemInfo2.offset + itemInfo2.widthFactor);
for (int i = position + 1; i <= itemInfo.position && n3 < this.mItems.size(); ++i) {
ItemInfo itemInfo3;
for (itemInfo3 = this.mItems.get(n3); i > itemInfo3.position && n3 < -1 + this.mItems.size(); ++n3, itemInfo3 = this.mItems.get(n3)) {}
while (i < itemInfo3.position) {
offset += n2 + this.mAdapter.getPageWidth(i);
++i;
}
itemInfo3.offset = offset;
offset += n2 + itemInfo3.widthFactor;
}
}
else if (position > itemInfo.position) {
int n4 = -1 + this.mItems.size();
float offset2 = itemInfo2.offset;
for (int j = position - 1; j >= itemInfo.position && n4 >= 0; --j) {
ItemInfo itemInfo4;
for (itemInfo4 = this.mItems.get(n4); j < itemInfo4.position && n4 > 0; --n4, itemInfo4 = this.mItems.get(n4)) {}
while (j > itemInfo4.position) {
offset2 -= n2 + this.mAdapter.getPageWidth(j);
--j;
}
offset2 -= n2 + itemInfo4.widthFactor;
itemI