Java Code Examples for androidx.viewpager.widget.PagerAdapter#POSITION_NONE

The following examples show how to use androidx.viewpager.widget.PagerAdapter#POSITION_NONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FragmentArrayStatePagerAdapter.java    From assembly-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public int getItemPosition(@NonNull Object object) {
    if (notifyNumberPool != null && notifyNumberPool.get(object.hashCode()) != notifyNumber) {
        notifyNumberPool.put(object.hashCode(), notifyNumber);
        return PagerAdapter.POSITION_NONE;
    }
    return super.getItemPosition(object);
}
 
Example 2
Source File: AssemblyFragmentPagerAdapter.java    From assembly-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public int getItemPosition(@NonNull Object object) {
    if (notifyNumberPool != null && notifyNumberPool.get(object.hashCode()) != notifyNumber) {
        notifyNumberPool.put(object.hashCode(), notifyNumber);
        return PagerAdapter.POSITION_NONE;
    }
    return super.getItemPosition(object);
}
 
Example 3
Source File: FragmentArrayPagerAdapter.java    From assembly-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public int getItemPosition(@NonNull Object object) {
    if (notifyNumberPool != null && notifyNumberPool.get(object.hashCode()) != notifyNumber) {
        notifyNumberPool.put(object.hashCode(), notifyNumber);
        return PagerAdapter.POSITION_NONE;
    }
    return super.getItemPosition(object);
}
 
Example 4
Source File: AssemblyPagerAdapter.java    From assembly-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public int getItemPosition(@NonNull Object object) {
    if (notifyNumberPool != null && notifyNumberPool.get(object.hashCode()) != notifyNumber) {
        notifyNumberPool.put(object.hashCode(), notifyNumber);
        return PagerAdapter.POSITION_NONE;
    }
    return super.getItemPosition(object);
}
 
Example 5
Source File: AssemblyFragmentStatePagerAdapter.java    From assembly-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public int getItemPosition(@NonNull Object object) {
    if (notifyNumberPool != null && notifyNumberPool.get(object.hashCode()) != notifyNumber) {
        notifyNumberPool.put(object.hashCode(), notifyNumber);
        return PagerAdapter.POSITION_NONE;
    }
    return super.getItemPosition(object);
}
 
Example 6
Source File: ArrayPagerAdapter.java    From assembly-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public int getItemPosition(@NonNull Object object) {
    if (notifyNumberPool != null && notifyNumberPool.get(object.hashCode()) != notifyNumber) {
        notifyNumberPool.put(object.hashCode(), notifyNumber);
        return PagerAdapter.POSITION_NONE;
    }
    return super.getItemPosition(object);
}
 
Example 7
Source File: TabStripHelper.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
boolean performClick() {
    boolean result = false;
    if (mClickable) {
        if (mClickPosition != PagerAdapter.POSITION_NONE) {
            final int position = mClickPosition;
            mClickPosition = PagerAdapter.POSITION_NONE;
            if (mView instanceof TabStripView)
                result = ((TabStripView) mView).performClick(position, mClickSmoothScroll);
            else if (mView instanceof TabStripViewGroup)
                result = ((TabStripViewGroup) mView).performClick(position, mClickSmoothScroll);
        }
    }
    if (mDoubleClickable) {
        if (mDoubleClicked) {
            final int first = mFirstPosition;
            final int second = mSecondPosition;
            mDoubleClicked = false;
            mFirstPosition = PagerAdapter.POSITION_NONE;
            mSecondPosition = PagerAdapter.POSITION_NONE;
            if (mView instanceof TabStripView)
                ((TabStripView) mView).performDoubleClick(first, second, mClickSmoothScroll);
            else if (mView instanceof TabStripViewGroup)
                ((TabStripViewGroup) mView).performDoubleClick(first, second, mClickSmoothScroll);
        }
    }
    return result;
}
 
Example 8
Source File: ScreenSlidePagerAdapter.java    From ScrollGalleryView with MIT License 4 votes vote down vote up
@Override
public int getItemPosition(Object object) {
    return PagerAdapter.POSITION_NONE;
}
 
Example 9
Source File: TagTabStrip.java    From ProjectX with Apache License 2.0 4 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    final int count = mCount;
    final int position = mPosition;
    final float offset = mOffset;
    final int anotherPosition = mOffset == 0 ? PagerAdapter.POSITION_NONE : mPosition + 1;
    final Drawable selected = mSelected;
    final Drawable normal = mNormal;
    selected.setBounds(0, 0, selected.getIntrinsicWidth(), selected.getIntrinsicHeight());
    normal.setBounds(0, 0, normal.getIntrinsicWidth(), normal.getIntrinsicHeight());
    canvas.save();
    canvas.translate(mFirstCenterX, mFirstCenterY);
    float dx;
    float dy;
    float scale;
    for (int i = 0; i < count; i++) {
        if (i == position) {
            if (offset == 0) {
                scale = mScale;
                dx = selected.getIntrinsicWidth() * 0.5f;
                dy = selected.getIntrinsicHeight() * 0.5f;
                selected.setAlpha(255);
                canvas.save();
                canvas.translate(-dx, -dy);
                canvas.scale(scale, scale, dx, dy);
                selected.draw(canvas);
                canvas.restore();
            } else {
                scale = 1 + (mScale - 1) * (1 - offset);
                dx = normal.getIntrinsicWidth() * 0.5f;
                dy = normal.getIntrinsicHeight() * 0.5f;
                normal.setAlpha((int) Math.ceil(0xFF * offset));
                canvas.save();
                canvas.translate(-dx, -dy);
                canvas.scale(scale, scale, dx, dy);
                normal.draw(canvas);
                canvas.restore();
                dx = selected.getIntrinsicWidth() * 0.5f;
                dy = selected.getIntrinsicHeight() * 0.5f;
                selected.setAlpha((int) Math.ceil(0xFF * (1 - offset)));
                canvas.save();
                canvas.translate(-dx, -dy);
                canvas.scale(scale, scale, dx, dy);
                selected.draw(canvas);
                canvas.restore();
            }
        } else if (i == anotherPosition) {
            scale = 1 + (mScale - 1) * offset;
            dx = normal.getIntrinsicWidth() * 0.5f;
            dy = normal.getIntrinsicHeight() * 0.5f;
            normal.setAlpha((int) Math.ceil(0xFF * (1 - offset)));
            canvas.save();
            canvas.translate(-dx, -dy);
            canvas.scale(scale, scale, dx, dy);
            normal.draw(canvas);
            canvas.restore();
            dx = selected.getIntrinsicWidth() * 0.5f;
            dy = selected.getIntrinsicHeight() * 0.5f;
            selected.setAlpha((int) Math.ceil(0xFF * offset));
            canvas.save();
            canvas.translate(-dx, -dy);
            canvas.scale(scale, scale, dx, dy);
            selected.draw(canvas);
            canvas.restore();
        } else {
            dx = normal.getIntrinsicWidth() * 0.5f;
            dy = normal.getIntrinsicHeight() * 0.5f;
            normal.setAlpha(255);
            canvas.save();
            canvas.translate(-dx, -dy);
            normal.draw(canvas);
            canvas.restore();
        }
        canvas.translate(mItemCenterOffset, 0);
    }
    canvas.restore();
}
 
Example 10
Source File: StoryViewPagerAdapter.java    From Instagram-Profile-Downloader with MIT License 4 votes vote down vote up
@Override
public int getItemPosition(Object object) {
    return PagerAdapter.POSITION_NONE;
}
 
Example 11
Source File: AFragmentStatePagerAdapter.java    From BaseProject with Apache License 2.0 4 votes vote down vote up
@Override
public int getItemPosition(Object object) {
    return PagerAdapter.POSITION_NONE;
}
 
Example 12
Source File: ViewPagerFragmentAdapter.java    From BaseProject with Apache License 2.0 4 votes vote down vote up
@Override
public int getItemPosition(Object object) {
    return PagerAdapter.POSITION_NONE;
}
 
Example 13
Source File: QiscusPhotoPagerAdapter.java    From qiscus-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public int getItemPosition(Object object) {
    return PagerAdapter.POSITION_NONE;
}
 
Example 14
Source File: CustomViewPager.java    From AsteroidOSSync with GNU General Public License v3.0 4 votes vote down vote up
void dataSetChanged() {
    // This method only gets called if our observer is attached, so mAdapter is non-null.

    final int adapterCount = mAdapter.getCount();
    mExpectedAdapterCount = adapterCount;
    boolean needPopulate = mItems.size() < mOffscreenPageLimit * 2 + 1
            && mItems.size() < adapterCount;
    int newCurrItem = mCurItem;

    boolean isUpdating = false;
    for (int i = 0; i < mItems.size(); i++) {
        final ItemInfo ii = mItems.get(i);
        final int newPos = mAdapter.getItemPosition(ii.object);

        if (newPos == PagerAdapter.POSITION_UNCHANGED) {
            continue;
        }

        if (newPos == PagerAdapter.POSITION_NONE) {
            mItems.remove(i);
            i--;

            if (!isUpdating) {
                mAdapter.startUpdate(this);
                isUpdating = true;
            }

            mAdapter.destroyItem(this, ii.position, ii.object);
            needPopulate = true;

            if (mCurItem == ii.position) {
                // Keep the current item in the valid range
                newCurrItem = Math.max(0, Math.min(mCurItem, adapterCount - 1));
                needPopulate = true;
            }
            continue;
        }

        if (ii.position != newPos) {
            if (ii.position == mCurItem) {
                // Our current item changed position. Follow it.
                newCurrItem = newPos;
            }

            ii.position = newPos;
            needPopulate = true;
        }
    }

    if (isUpdating) {
        mAdapter.finishUpdate(this);
    }

    Collections.sort(mItems, COMPARATOR);

    if (needPopulate) {
        // Reset our known page widths; populate will recompute them.
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (!lp.isDecor) {
                lp.widthFactor = 0.f;
            }
        }

        setCurrentItemInternal(newCurrItem, false, true);
        requestLayout();
    }
}
 
Example 15
Source File: VerticalViewPager.java    From DKVideoPlayer with Apache License 2.0 4 votes vote down vote up
void dataSetChanged() {
    // This method only gets called if our observer is attached, so mAdapter is non-null.

    final int adapterCount = mAdapter.getCount();
    mExpectedAdapterCount = adapterCount;
    boolean needPopulate = mItems.size() < mOffscreenPageLimit * 2 + 1 &&
            mItems.size() < adapterCount;
    int newCurrItem = mCurItem;

    boolean isUpdating = false;
    for (int i = 0; i < mItems.size(); i++) {
        final ItemInfo ii = mItems.get(i);
        final int newPos = mAdapter.getItemPosition(ii.object);

        if (newPos == PagerAdapter.POSITION_UNCHANGED) {
            continue;
        }

        if (newPos == PagerAdapter.POSITION_NONE) {
            mItems.remove(i);
            i--;

            if (!isUpdating) {
                mAdapter.startUpdate(this);
                isUpdating = true;
            }

            mAdapter.destroyItem(this, ii.position, ii.object);
            needPopulate = true;

            if (mCurItem == ii.position) {
                // Keep the current item in the valid range
                newCurrItem = Math.max(0, Math.min(mCurItem, adapterCount - 1));
                needPopulate = true;
            }
            continue;
        }

        if (ii.position != newPos) {
            if (ii.position == mCurItem) {
                // Our current item changed position. Follow it.
                newCurrItem = newPos;
            }

            ii.position = newPos;
            needPopulate = true;
        }
    }

    if (isUpdating) {
        mAdapter.finishUpdate(this);
    }

    Collections.sort(mItems, COMPARATOR);

    if (needPopulate) {
        // Reset our known page widths; populate will recompute them.
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (!lp.isDecor) {
                lp.heightFactor = 0.f;
            }
        }

        setCurrentItemInternal(newCurrItem, false, true);
        requestLayout();
    }
}
 
Example 16
Source File: DemoPagerAdapter.java    From ScrollingPagerIndicator with Apache License 2.0 4 votes vote down vote up
@Override
public int getItemPosition(@NonNull Object object) {
    return PagerAdapter.POSITION_NONE;
}
 
Example 17
Source File: SliderPager.java    From Android-Image-Slider with Apache License 2.0 4 votes vote down vote up
void dataSetChanged() {
    // This method only gets called if our observer is attached, so mAdapter is non-null.

    final int adapterCount = mAdapter.getCount();
    mExpectedAdapterCount = adapterCount;
    boolean needPopulate = mItems.size() < mOffscreenPageLimit * 2 + 1
            && mItems.size() < adapterCount;
    int newCurrItem = mCurItem;

    boolean isUpdating = false;
    for (int i = 0; i < mItems.size(); i++) {
        final ItemInfo ii = mItems.get(i);
        final int newPos = mAdapter.getItemPosition(ii.object);

        if (newPos == PagerAdapter.POSITION_UNCHANGED) {
            continue;
        }

        if (newPos == PagerAdapter.POSITION_NONE) {
            mItems.remove(i);
            i--;

            if (!isUpdating) {
                mAdapter.startUpdate(this);
                isUpdating = true;
            }

            mAdapter.destroyItem(this, ii.position, ii.object);
            needPopulate = true;

            if (mCurItem == ii.position) {
                // Keep the current item in the valid range
                newCurrItem = Math.max(0, Math.min(mCurItem, adapterCount - 1));
                needPopulate = true;
            }
            continue;
        }

        if (ii.position != newPos) {
            if (ii.position == mCurItem) {
                // Our current item changed position. Follow it.
                newCurrItem = newPos;
            }

            ii.position = newPos;
            needPopulate = true;
        }
    }

    if (isUpdating) {
        mAdapter.finishUpdate(this);
    }

    Collections.sort(mItems, COMPARATOR);

    if (needPopulate) {
        // Reset our known page widths; populate will recompute them.
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (!lp.isDecor) {
                lp.widthFactor = 0.f;
            }
        }

        setCurrentItemInternal(newCurrItem, false, true);
        requestLayout();
    }
}
 
Example 18
Source File: MediaPagerAdapter.java    From leafpicrevived with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getItemPosition(@NonNull Object object) {
    return PagerAdapter.POSITION_NONE;
}
 
Example 19
Source File: TabStripView.java    From ProjectX with Apache License 2.0 2 votes vote down vote up
/**
 * 获取点击的页位置
 *
 * @param downX ACTION_DOWN X轴坐标
 * @param downY ACTION_DOWN Y轴坐标
 * @param upX   ACTION_UP X轴坐标
 * @param upY   ACTION_UP Y轴坐标
 * @return 位置
 */
protected int getClickedPosition(float downX, float downY, float upX, float upY) {
    return PagerAdapter.POSITION_NONE;
}
 
Example 20
Source File: TabStripViewGroup.java    From ProjectX with Apache License 2.0 2 votes vote down vote up
/**
 * 获取点击的页位置
 *
 * @param downX ACTION_DOWN X轴坐标
 * @param downY ACTION_DOWN Y轴坐标
 * @param upX   ACTION_UP X轴坐标
 * @param upY   ACTION_UP Y轴坐标
 * @return 位置
 */
protected int getClickedPosition(float downX, float downY, float upX, float upY) {
    return PagerAdapter.POSITION_NONE;
}