當前位置: 首頁>>代碼示例>>Java>>正文


Java PositionData.width方法代碼示例

本文整理匯總了Java中net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData.width方法的典型用法代碼示例。如果您正苦於以下問題:Java PositionData.width方法的具體用法?Java PositionData.width怎麽用?Java PositionData.width使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData的用法示例。


在下文中一共展示了PositionData.width方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getImitativePositionData

import net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData; //導入方法依賴的package包/類
/**
 * IPagerIndicator支持彈性效果的輔助方法
 *
 * @param positionDataList
 * @param index
 * @return
 */
public static PositionData getImitativePositionData(List<PositionData> positionDataList, int index) {
    if (index >= 0 && index <= positionDataList.size() - 1) { // 越界後,返回假的PositionData
        return positionDataList.get(index);
    } else {
        PositionData result = new PositionData();
        PositionData referenceData;
        int offset;
        if (index < 0) {
            offset = index;
            referenceData = positionDataList.get(0);
        } else {
            offset = index - positionDataList.size() + 1;
            referenceData = positionDataList.get(positionDataList.size() - 1);
        }
        result.mLeft = referenceData.mLeft + offset * referenceData.width();
        result.mTop = referenceData.mTop;
        result.mRight = referenceData.mRight + offset * referenceData.width();
        result.mBottom = referenceData.mBottom;
        result.mContentLeft = referenceData.mContentLeft + offset * referenceData.width();
        result.mContentTop = referenceData.mContentTop;
        result.mContentRight = referenceData.mContentRight + offset * referenceData.width();
        result.mContentBottom = referenceData.mContentBottom;
        return result;
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:33,代碼來源:FragmentContainerHelper.java

示例2: onPageSelected

import net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData; //導入方法依賴的package包/類
@Override
public void onPageSelected(int position) {
    if (mDataList == null || mDataList.isEmpty()) {
        return;
    }
    PositionData data = mDataList.get(position);
    mCircleCenterX = data.mLeft + data.width() / 2;
    invalidate();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:DotPagerIndicator.java

示例3: onPageScrolled

import net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData; //導入方法依賴的package包/類
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    if (mIndicatorDrawable == null) {
        return;
    }

    if (mPositionDataList == null || mPositionDataList.isEmpty()) {
        return;
    }

    // 計算錨點位置
    PositionData current = FragmentContainerHelper.getImitativePositionData(mPositionDataList, position);
    PositionData next = FragmentContainerHelper.getImitativePositionData(mPositionDataList, position + 1);

    float leftX;
    float nextLeftX;
    float rightX;
    float nextRightX;
    if (mMode == MODE_MATCH_EDGE) {
        leftX = current.mLeft + mXOffset;
        nextLeftX = next.mLeft + mXOffset;
        rightX = current.mRight - mXOffset;
        nextRightX = next.mRight - mXOffset;
        mDrawableRect.top = (int) mYOffset;
        mDrawableRect.bottom = (int) (getHeight() - mYOffset);
    } else if (mMode == MODE_WRAP_CONTENT) {
        leftX = current.mContentLeft + mXOffset;
        nextLeftX = next.mContentLeft + mXOffset;
        rightX = current.mContentRight - mXOffset;
        nextRightX = next.mContentRight - mXOffset;
        mDrawableRect.top = (int) (current.mContentTop - mYOffset);
        mDrawableRect.bottom = (int) (current.mContentBottom + mYOffset);
    } else {    // MODE_EXACTLY
        leftX = current.mLeft + (current.width() - mDrawableWidth) / 2;
        nextLeftX = next.mLeft + (next.width() - mDrawableWidth) / 2;
        rightX = current.mLeft + (current.width() + mDrawableWidth) / 2;
        nextRightX = next.mLeft + (next.width() + mDrawableWidth) / 2;
        mDrawableRect.top = (int) (getHeight() - mDrawableHeight - mYOffset);
        mDrawableRect.bottom = (int) (getHeight() - mYOffset);
    }

    mDrawableRect.left = (int) (leftX + (nextLeftX - leftX) * mStartInterpolator.getInterpolation(positionOffset));
    mDrawableRect.right = (int) (rightX + (nextRightX - rightX) * mEndInterpolator.getInterpolation(positionOffset));
    mIndicatorDrawable.setBounds(mDrawableRect);

    invalidate();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:48,代碼來源:CommonPagerIndicator.java

示例4: onPageScrolled

import net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData; //導入方法依賴的package包/類
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    if (mPositionDataList == null || mPositionDataList.isEmpty()) {
        return;
    }

    // 計算顏色
    if (mColors != null && mColors.size() > 0) {
        int currentColor = mColors.get(Math.abs(position) % mColors.size());
        int nextColor = mColors.get(Math.abs(position + 1) % mColors.size());
        int color = ArgbEvaluatorHolder.eval(positionOffset, currentColor, nextColor);
        mPaint.setColor(color);
    }

    // 計算錨點位置
    PositionData current = FragmentContainerHelper.getImitativePositionData(mPositionDataList, position);
    PositionData next = FragmentContainerHelper.getImitativePositionData(mPositionDataList, position + 1);

    float leftX;
    float nextLeftX;
    float rightX;
    float nextRightX;
    if (mMode == MODE_MATCH_EDGE) {
        leftX = current.mLeft + mXOffset;
        nextLeftX = next.mLeft + mXOffset;
        rightX = current.mRight - mXOffset;
        nextRightX = next.mRight - mXOffset;
    } else if (mMode == MODE_WRAP_CONTENT) {
        leftX = current.mContentLeft + mXOffset;
        nextLeftX = next.mContentLeft + mXOffset;
        rightX = current.mContentRight - mXOffset;
        nextRightX = next.mContentRight - mXOffset;
    } else {    // MODE_EXACTLY
        leftX = current.mLeft + (current.width() - mLineWidth) / 2;
        nextLeftX = next.mLeft + (next.width() - mLineWidth) / 2;
        rightX = current.mLeft + (current.width() + mLineWidth) / 2;
        nextRightX = next.mLeft + (next.width() + mLineWidth) / 2;
    }

    mLineRect.left = leftX + (nextLeftX - leftX) * mStartInterpolator.getInterpolation(positionOffset);
    mLineRect.right = rightX + (nextRightX - rightX) * mEndInterpolator.getInterpolation(positionOffset);
    mLineRect.top = getHeight() - mLineHeight - mYOffset;
    mLineRect.bottom = getHeight() - mYOffset;

    invalidate();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:47,代碼來源:LinePagerIndicator.java

示例5: onPageScrolled

import net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData; //導入方法依賴的package包/類
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    if (mPositionDataList == null || mPositionDataList.isEmpty()) {
        return;
    }

    // 計算顏色
    if (mColors != null && mColors.size() > 0) {
        int currentColor = mColors.get(position % mColors.size());
        int nextColor = mColors.get((position + 1) % mColors.size());
        int color = ArgbEvaluatorHolder.eval(positionOffset, currentColor, nextColor);
        mPaint.setColor(color);
    }

    // 計算錨點位置
    int currentPosition = Math.min(mPositionDataList.size() - 1, position);
    int nextPosition = Math.min(mPositionDataList.size() - 1, position + 1);
    PositionData current = mPositionDataList.get(currentPosition);
    PositionData next = mPositionDataList.get(nextPosition);

    float leftX;
    float nextLeftX;
    float rightX;
    float nextRightX;
    if (mMode == MODE_MATCH_EDGE) {
        leftX = current.mLeft + mXOffset;
        nextLeftX = next.mLeft + mXOffset;
        rightX = current.mRight - mXOffset;
        nextRightX = next.mRight - mXOffset;
    } else if (mMode == MODE_WRAP_CONTENT) {
        leftX = current.mContentLeft + mXOffset;
        nextLeftX = next.mContentLeft + mXOffset;
        rightX = current.mContentRight - mXOffset;
        nextRightX = next.mContentRight - mXOffset;
    } else {    // MODE_EXACTLY
        leftX = current.mLeft + (current.width() - mLineWidth) / 2;
        nextLeftX = next.mLeft + (next.width() - mLineWidth) / 2;
        rightX = current.mLeft + (current.width() + mLineWidth) / 2;
        nextRightX = next.mLeft + (next.width() + mLineWidth) / 2;
    }

    mLineRect.left = leftX + (nextLeftX - leftX) * mStartInterpolator.getInterpolation(positionOffset);
    mLineRect.right = rightX + (nextRightX - rightX) * mEndInterpolator.getInterpolation(positionOffset);
    mLineRect.top = getHeight() - mLineHeight - mYOffset;
    mLineRect.bottom = getHeight() - mYOffset;

    invalidate();
}
 
開發者ID:lizubing1992,項目名稱:Li-MVPArms,代碼行數:49,代碼來源:LinePagerIndicator.java


注:本文中的net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData.width方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。