当前位置: 首页>>代码示例>>Java>>正文


Java OrientationHelper.getDecoratedMeasurement方法代码示例

本文整理汇总了Java中android.support.v7.widget.OrientationHelper.getDecoratedMeasurement方法的典型用法代码示例。如果您正苦于以下问题:Java OrientationHelper.getDecoratedMeasurement方法的具体用法?Java OrientationHelper.getDecoratedMeasurement怎么用?Java OrientationHelper.getDecoratedMeasurement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.OrientationHelper的用法示例。


在下文中一共展示了OrientationHelper.getDecoratedMeasurement方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findStartView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private View findStartView(RecyclerView.LayoutManager layoutManager, OrientationHelper helper) {

    if (layoutManager instanceof LinearLayoutManager) {
      int firstChild = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();

      if (firstChild == RecyclerView.NO_POSITION) {
        return null;
      }

      View child = layoutManager.findViewByPosition(firstChild);

      if (helper.getDecoratedEnd(child) >= helper.getDecoratedMeasurement(child) / 2
          && helper.getDecoratedEnd(child) > 0) {
        return child;
      } else {
        if (((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition()
            == layoutManager.getItemCount() - 1) {
          return null;
        } else {
          return layoutManager.findViewByPosition(firstChild + 1);
        }
      }
    }

    return super.findSnapView(layoutManager);
  }
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:27,代码来源:GravitySnapHelper.java

示例2: findEndView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private View findEndView(RecyclerView.LayoutManager layoutManager, OrientationHelper helper) {

    if (layoutManager instanceof LinearLayoutManager) {
      int lastChild = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();

      if (lastChild == RecyclerView.NO_POSITION) {
        return null;
      }

      View child = layoutManager.findViewByPosition(lastChild);

      if (helper.getDecoratedStart(child) + helper.getDecoratedMeasurement(child) / 2
          <= helper.getTotalSpace()) {
        return child;
      } else {
        if (((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition() == 0) {
          return null;
        } else {
          return layoutManager.findViewByPosition(lastChild - 1);
        }
      }
    }

    return super.findSnapView(layoutManager);
  }
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:26,代码来源:GravitySnapHelper.java

示例3: findEndView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private View findEndView(RecyclerView.LayoutManager layoutManager,
                         OrientationHelper helper) {

    if (layoutManager instanceof LinearLayoutManager) {
        int lastChild = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();

        if (lastChild == RecyclerView.NO_POSITION) {
            return null;
        }

        View child = layoutManager.findViewByPosition(lastChild);

        float visibleWidth;

        if (mIsRtlHorizontal) {
            visibleWidth = (float) helper.getDecoratedEnd(child)
                    / helper.getDecoratedMeasurement(child);
        } else {
            visibleWidth = (float) (helper.getTotalSpace() - helper.getDecoratedStart(child))
                    / helper.getDecoratedMeasurement(child);
        }

        // If we're at the start of the list, we shouldn't snap
        // to avoid having the first item not completely visible.
        boolean startOfList = ((LinearLayoutManager) layoutManager)
                .findFirstCompletelyVisibleItemPosition() == 0;

        if (visibleWidth > 0.5f && !startOfList) {
            return child;
        } else if (mSnapLastItemEnabled && startOfList) {
            return child;
        } else if (startOfList) {
            return null;
        } else {
            // If the child wasn't returned, we need to return the previous view
            return layoutManager.findViewByPosition(lastChild - 1);
        }
    }
    return null;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:41,代码来源:GravitySnapHelper.java

示例4: findEndView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private View findEndView(RecyclerView.LayoutManager layoutManager,
                         OrientationHelper helper) {

    if (layoutManager instanceof LinearLayoutManager) {
        int lastChild = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();

        if (lastChild == RecyclerView.NO_POSITION) {
            return null;
        }

        View child = layoutManager.findViewByPosition(lastChild);

        float visibleWidth;

        if (isRtlHorizontal) {
            visibleWidth = (float) helper.getDecoratedEnd(child)
                    / helper.getDecoratedMeasurement(child);
        } else {
            visibleWidth = (float) (helper.getTotalSpace() - helper.getDecoratedStart(child))
                    / helper.getDecoratedMeasurement(child);
        }

        // If we're at the start of the list, we shouldn't snap
        // to avoid having the first item not completely visible.
        boolean startOfList = ((LinearLayoutManager) layoutManager)
                .findFirstCompletelyVisibleItemPosition() == 0;

        if (visibleWidth > 0.5f && !startOfList) {
            return child;
        } else if (snapLastItem && startOfList) {
            return child;
        } else if (startOfList) {
            return null;
        } else {
            // If the child wasn't returned, we need to return the previous view
            return layoutManager.findViewByPosition(lastChild - 1);
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:GravityDelegate.java

示例5: prependToSpan

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
void prependToSpan(View view, OrientationHelper helper) {
    LayoutParams lp = getLayoutParams(view);
    mViews.add(0, view);
    mCachedStart = INVALID_LINE;
    if (mViews.size() == 1) {
        mCachedEnd = INVALID_LINE;
    }
    if (lp.isItemRemoved() || lp.isItemChanged()) {
        mDeletedSize += helper.getDecoratedMeasurement(view);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:StaggeredGridLayoutHelper.java

示例6: findCenterView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
/**
 * Return the child view that is currently closest to the center of this parent.
 *
 * @param layoutManager The {@link RecyclerView.LayoutManager} associated with the attached
 *                      {@link RecyclerView}.
 * @param helper        The relevant {@link OrientationHelper} for the attached {@link RecyclerView}.
 * @return the child view that is currently closest to the center of this parent.
 */
@Nullable
private View findCenterView(RecyclerView.LayoutManager layoutManager,
                            OrientationHelper helper) {
    int childCount = layoutManager.getChildCount();
    if (childCount == 0) {
        return null;
    }

    View closestChild = null;
    final int center;
    if (layoutManager.getClipToPadding()) {
        center = helper.getStartAfterPadding() + helper.getTotalSpace() / 2;
    } else {
        center = helper.getEnd() / 2;
    }
    int absClosest = Integer.MAX_VALUE;

    for (int i = 0; i < childCount; i++) {
        final View child = layoutManager.getChildAt(i);
        final int childMonthIndex = layoutManager.getPosition(child) % ITEM_PER_MONTH;
        if (childMonthIndex != ITEM_PER_MONTH / 2) {
            i += ITEM_PER_MONTH * (childMonthIndex > ITEM_PER_MONTH / 2 ? 1.5f : 0.5f) - childMonthIndex - 1;
            continue;
        }
        int childCenter = helper.getDecoratedStart(child)
                + (helper.getDecoratedMeasurement(child) / 2);
        int absDistance = Math.abs(childCenter - center);

        // if child center is closer than previous closest, set it as closest
        if (absDistance < absClosest) {
            absClosest = absDistance;
            closestChild = child;
        }
    }
    return closestChild;
}
 
开发者ID:thaihuynhxyz,项目名称:recycler-view-calendar,代码行数:45,代码来源:CalendarSnapHelper.java

示例7: popEnd

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
void popEnd(OrientationHelper helper) {
    final int size = mViews.size();
    View end = mViews.remove(size - 1);
    final LayoutParams lp = getLayoutParams(end);
    if (lp.isItemRemoved() || lp.isItemChanged()) {
        mDeletedSize -= helper.getDecoratedMeasurement(end);
    }
    if (size == 1) {
        mCachedStart = INVALID_LINE;
    }
    mCachedEnd = INVALID_LINE;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:StaggeredGridLayoutHelper.java

示例8: popStart

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
void popStart(OrientationHelper helper) {
    View start = mViews.remove(0);
    final LayoutParams lp = getLayoutParams(start);
    if (mViews.size() == 0) {
        mCachedEnd = INVALID_LINE;
    }
    if (lp.isItemRemoved() || lp.isItemChanged()) {
        mDeletedSize -= helper.getDecoratedMeasurement(start);
    }
    mCachedStart = INVALID_LINE;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:StaggeredGridLayoutHelper.java

示例9: handleOne

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private int handleOne(LayoutStateWrapper layoutState, LayoutChunkResult result, LayoutManagerHelper helper,
    boolean layoutInVertical, int parentWidth, int parentHeight, int parentHPadding, int parentVPadding) {
    int mainConsumed = 0;
    OrientationHelper orientationHelper = helper.getMainOrientationHelper();

    View view = mChildrenViews[0];
    final ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(
        view.getLayoutParams());

    if (!Float.isNaN(mAspectRatio)) {
        if (layoutInVertical) {
            lp.height = (int) ((parentWidth - parentHPadding) / mAspectRatio);
        } else {
            lp.width = (int) ((parentHeight - parentVPadding) * mAspectRatio);
        }
    }

    final float weight = getViewMainWeight(lp, 0);

    // fill width
    int widthSpec = helper.getChildMeasureSpec(
        Float.isNaN(weight) ? (parentWidth - parentHPadding)
            : (int) ((parentWidth - parentHPadding) * weight),
        layoutInVertical ? MATCH_PARENT : lp.width, !layoutInVertical);
    int heightSpec = helper.getChildMeasureSpec(parentHeight - parentVPadding,
        layoutInVertical ? lp.height : MeasureSpec.EXACTLY, layoutInVertical);

    helper.measureChildWithMargins(view, widthSpec, heightSpec);

    mainConsumed = orientationHelper.getDecoratedMeasurement(view) + (layoutInVertical ?
        getVerticalMargin() + getVerticalPadding()
        : getHorizontalMargin() + getHorizontalPadding());

    calculateRect(mainConsumed, mAreaRect, layoutState, helper);

    layoutChild(view, mAreaRect.left, mAreaRect.top, mAreaRect.right, mAreaRect.bottom,
        helper);
    handleStateOnResult(result, view);
    return mainConsumed;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:OnePlusNLayoutHelper.java

示例10: getStartView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private View getStartView(RecyclerView.LayoutManager layoutManager,
                          OrientationHelper helper) {

    if (layoutManager instanceof LinearLayoutManager) {
        int firstChild = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();

        boolean isLastItem = ((LinearLayoutManager) layoutManager)
                .findLastCompletelyVisibleItemPosition()
                == layoutManager.getItemCount() - 1;

        if (firstChild == RecyclerView.NO_POSITION || isLastItem) {
            return null;
        }

        View child = layoutManager.findViewByPosition(firstChild);

        if (helper.getDecoratedEnd(child) >= helper.getDecoratedMeasurement(child) / 2
                && helper.getDecoratedEnd(child) > 0) {
            return child;
        } else {
            if (((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition()
                    == layoutManager.getItemCount() - 1) {
                return null;
            } else {
                return layoutManager.findViewByPosition(firstChild + 1);
            }
        }
    }

    return super.findSnapView(layoutManager);
}
 
开发者ID:hoanganhtuan95ptit,项目名称:EditPhoto,代码行数:32,代码来源:StartSnapHelper.java

示例11: findStartView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
/**
 * Returns the first view that we should snap to.
 *
 * @param layoutManager the recyclerview's layout manager
 * @param helper        orientation helper to calculate view sizes
 * @return the first view in the LayoutManager to snap to
 */
private View findStartView(RecyclerView.LayoutManager layoutManager,
                           OrientationHelper helper) {

    if (layoutManager instanceof LinearLayoutManager) {
        int firstChild = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
        int offset = 1;

        if (layoutManager instanceof GridLayoutManager) {
            offset += ((GridLayoutManager) layoutManager).getSpanCount() - 1;
        }

        if (firstChild == RecyclerView.NO_POSITION) {
            return null;
        }

        View child = layoutManager.findViewByPosition(firstChild);

        float visibleWidth;

        // We should return the child if it's visible width
        // is greater than 0.5 of it's total width.
        // In a RTL configuration, we need to check the start point and in LTR the end point
        if (isRtlHorizontal) {
            visibleWidth = (float) (helper.getTotalSpace() - helper.getDecoratedStart(child))
                    / helper.getDecoratedMeasurement(child);
        } else {
            visibleWidth = (float) helper.getDecoratedEnd(child)
                    / helper.getDecoratedMeasurement(child);
        }

        // If we're at the end of the list, we shouldn't snap
        // to avoid having the last item not completely visible.
        boolean endOfList = ((LinearLayoutManager) layoutManager)
                .findLastCompletelyVisibleItemPosition()
                == layoutManager.getItemCount() - 1;

        if (visibleWidth > 0.5f && !endOfList) {
            return child;
        } else if (snapLastItem && endOfList) {
            return child;
        } else if (endOfList) {
            return null;
        } else {
            // If the child wasn't returned, we need to return
            // the next view close to the start.
            return layoutManager.findViewByPosition(firstChild + offset);
        }
    }

    return null;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:59,代码来源:GravityDelegate.java

示例12: findEndView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private View findEndView(RecyclerView.LayoutManager layoutManager,
                         OrientationHelper helper) {

    if (layoutManager instanceof LinearLayoutManager) {
        int lastChild = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
        int offset = 1;

        if (layoutManager instanceof GridLayoutManager) {
            offset += ((GridLayoutManager) layoutManager).getSpanCount() - 1;
        }

        if (lastChild == RecyclerView.NO_POSITION) {
            return null;
        }

        View child = layoutManager.findViewByPosition(lastChild);

        float visibleWidth;

        if (isRtlHorizontal) {
            visibleWidth = (float) helper.getDecoratedEnd(child)
                    / helper.getDecoratedMeasurement(child);
        } else {
            visibleWidth = (float) (helper.getTotalSpace() - helper.getDecoratedStart(child))
                    / helper.getDecoratedMeasurement(child);
        }

        // If we're at the start of the list, we shouldn't snap
        // to avoid having the first item not completely visible.
        boolean startOfList = ((LinearLayoutManager) layoutManager)
                .findFirstCompletelyVisibleItemPosition() == 0;

        if (visibleWidth > 0.5f && !startOfList) {
            return child;
        } else if (snapLastItem && startOfList) {
            return child;
        } else if (startOfList) {
            return null;
        } else {
            // If the child wasn't returned, we need to return the previous view
            return layoutManager.findViewByPosition(lastChild - offset);
        }
    }
    return null;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:46,代码来源:GravityDelegate.java

示例13: findStartView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
/**
 * Returns the first view that we should snap to.
 *
 * @param layoutManager the recyclerview's layout manager
 * @param helper        orientation helper to calculate view sizes
 * @return the first view in the LayoutManager to snap to
 */
private View findStartView(RecyclerView.LayoutManager layoutManager,
                           OrientationHelper helper) {

    if (layoutManager instanceof LinearLayoutManager) {
        int firstChild = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();

        if (firstChild == RecyclerView.NO_POSITION) {
            return null;
        }

        View child = layoutManager.findViewByPosition(firstChild);

        float visibleWidth;

        // We should return the child if it's visible width
        // is greater than 0.5 of it's total width.
        // In a RTL configuration, we need to check the start point and in LTR the end point
        if (mIsRtlHorizontal) {
            visibleWidth = (float) (helper.getTotalSpace() - helper.getDecoratedStart(child))
                    / helper.getDecoratedMeasurement(child);
        } else {
            visibleWidth = (float) helper.getDecoratedEnd(child)
                    / helper.getDecoratedMeasurement(child);
        }

        // If we're at the end of the list, we shouldn't snap
        // to avoid having the last item not completely visible.
        boolean endOfList = ((LinearLayoutManager) layoutManager)
                .findLastCompletelyVisibleItemPosition()
                == layoutManager.getItemCount() - 1;

        if (visibleWidth > 0.5f && !endOfList) {
            return child;
        } else if (mSnapLastItemEnabled && endOfList) {
            return child;
        } else if (endOfList) {
            return null;
        } else {
            // If the child wasn't returned, we need to return
            // the next view close to the start.
            return layoutManager.findViewByPosition(firstChild + 1);
        }
    }

    return null;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:54,代码来源:GravitySnapHelper.java

示例14: getChildPosition

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
@Override
int getChildPosition(View targetView, OrientationHelper helper) {
    return helper.getDecoratedStart(targetView) + helper.getDecoratedMeasurement(targetView);
}
 
开发者ID:TakuSemba,项目名称:MultiSnapRecyclerView,代码行数:5,代码来源:EndSnapHelperDelegator.java


注:本文中的android.support.v7.widget.OrientationHelper.getDecoratedMeasurement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。