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


Java OrientationHelper.getDecoratedEnd方法代码示例

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


在下文中一共展示了OrientationHelper.getDecoratedEnd方法的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: findOneVisibleChild

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible,
                                 boolean acceptPartiallyVisible) {
    OrientationHelper helper;
    if (layoutManager.canScrollVertically()) {
        helper = OrientationHelper.createVerticalHelper(layoutManager);
    } else {
        helper = OrientationHelper.createHorizontalHelper(layoutManager);
    }

    final int start = helper.getStartAfterPadding();
    final int end = helper.getEndAfterPadding();
    final int next = toIndex > fromIndex ? 1 : -1;
    View partiallyVisible = null;
    for (int i = fromIndex; i != toIndex; i += next) {
        final View child = layoutManager.getChildAt(i);
        final int childStart = helper.getDecoratedStart(child);
        final int childEnd = helper.getDecoratedEnd(child);
        if (childStart < end && childEnd > start) {
            if (completelyVisible) {
                if (childStart >= start && childEnd <= end) {
                    return child;
                } else if (acceptPartiallyVisible && partiallyVisible == null) {
                    partiallyVisible = child;
                }
            } else {
                return child;
            }
        }
    }
    return partiallyVisible;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:RecyclerViewPositionHelper.java

示例3: distanceToEnd

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private int distanceToEnd(View targetView, OrientationHelper helper, boolean fromStart) {
    if (isRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:GravityDelegate.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: computeAlignOffset

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
@Override
public int computeAlignOffset(int offset, boolean isLayoutEnd,
                              boolean useAnchor, LayoutManagerHelper helper) {
    final boolean layoutInVertical = helper.getOrientation() == VERTICAL;
    final OrientationHelper orientationHelper = helper.getMainOrientationHelper();
    final View child = helper.findViewByPosition(offset + getRange().getLower());

    if (child == null) {
        return 0;
    }

    if (layoutInVertical) {
        // in middle nothing need to do
        if (isLayoutEnd) {
            if (offset == getItemCount() - 1) {
                //the last item may not have the largest bottom, so calculate gaps between last items in every lane
                return mMarginBottom + mPaddingBottom + (getMaxEnd(orientationHelper.getDecoratedEnd(child),
                    orientationHelper) - orientationHelper.getDecoratedEnd(child));
            } else if (!useAnchor) {
                final int minEnd = getMinEnd(orientationHelper.getDecoratedStart(child), orientationHelper);
                return minEnd - orientationHelper.getDecoratedEnd(child);
            }
        } else {
            if (offset == 0) {
                //the first item may not have the smallest top, so calculate gaps between first items in every lane
                return -mMarginTop - mPaddingTop - (orientationHelper.getDecoratedStart(child) - getMinStart(
                    orientationHelper.getDecoratedStart(child), orientationHelper));
            } else if (!useAnchor) {
                final int maxStart = getMaxStart(orientationHelper.getDecoratedEnd(child), orientationHelper);
                return maxStart - orientationHelper.getDecoratedStart(child);
            }
        }

    } else {

    }

    return 0;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:40,代码来源:StaggeredGridLayoutHelper.java

示例6: 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

示例7: calculateCachedEnd

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
void calculateCachedEnd(OrientationHelper helper) {
    if (mViews.size() == 0) {
        mCachedEnd = INVALID_LINE;
    } else {
        final View endView = mViews.get(mViews.size() - 1);
        mCachedEnd = helper.getDecoratedEnd(endView);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:StaggeredGridLayoutHelper.java

示例8: 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

示例9: distanceToEnd

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private int distanceToEnd(View targetView, OrientationHelper helper, boolean fromStart) {
    if (mIsRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
开发者ID:mangoblogger,项目名称:MangoBloggerAndroidApp,代码行数:8,代码来源:GravitySnapHelper.java

示例10: findOneVisibleChild

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible,
                         boolean acceptPartiallyVisible) {
    OrientationHelper helper;
    if (layoutManager.canScrollVertically()) {
        helper = OrientationHelper.createVerticalHelper(layoutManager);
    } else {
        helper = OrientationHelper.createHorizontalHelper(layoutManager);
    }

    final int start = helper.getStartAfterPadding();
    final int end = helper.getEndAfterPadding();
    final int next = toIndex > fromIndex ? 1 : -1;
    View partiallyVisible = null;
    for (int i = fromIndex; i != toIndex; i += next) {
        final View child = layoutManager.getChildAt(i);
        final int childStart = helper.getDecoratedStart(child);
        final int childEnd = helper.getDecoratedEnd(child);
        if (childStart < end && childEnd > start) {
            if (completelyVisible) {
                if (childStart >= start && childEnd <= end) {
                    return child;
                } else if (acceptPartiallyVisible && partiallyVisible == null) {
                    partiallyVisible = child;
                }
            } else {
                return child;
            }
        }
    }
    return partiallyVisible;
}
 
开发者ID:lecrec,项目名称:lecrec-android,代码行数:32,代码来源:RecyclerViewPositionHelper.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();

        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

示例12: 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

示例13: 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

示例14: distanceToEnd

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private int distanceToEnd(View targetView, OrientationHelper helper) {
  if (mIsRtl) {
    return helper.getDecoratedStart(targetView) - helper.getStartAfterPadding();
  }
  return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:7,代码来源:GravitySnapHelper.java


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