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


Java OrientationHelper.createVerticalHelper方法代码示例

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


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

示例1: scrollToRightPositionWhenItemChanged

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
/**
     * 当item位置变换,滚动recycler到正确的位置
     * TODO: 2017/2/21 0021 整理更优雅的写法  还有scrollToPosition(0)是否必要?
     */
    private void scrollToRightPositionWhenItemChanged(RecyclerView recyclerView, View itemView, int itemPos) {
        final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
        if (layoutManager instanceof ItemTouchHelper.ViewDropHandler) {
            OrientationHelper helper = OrientationHelper.createVerticalHelper(layoutManager);
            int start = helper.getDecoratedStart(itemView);
            int end = helper.getDecoratedEnd(itemView);
            ((LinearLayoutManager) layoutManager).scrollToPositionWithOffset(
                    itemPos, lastItemPos > itemPos ? start : end - itemViewHeight);
//                System.out.println(lastItemPos + "-" + childPos + "OrientationHelperOrientationHelper:"
//                        + height + "==" + itemViewHeight + "=||=" + start + "===" + end + "||||||" + myStart + "===" + itemTargetView.getHeight() );
        }
        if (lastItemPos == 0 || itemPos == 0) {
            recyclerView.scrollToPosition(0);
        }
    }
 
开发者ID:free46000,项目名称:MultiItem,代码行数:20,代码来源:ItemDragHelper.java

示例2: findOneVisibleChild

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible,
                                 boolean acceptPartiallyVisible) {
    if (mLayoutManager.canScrollVertically() != mIsOrientationHelperVertical
            || mOrientationHelper == null) {
        mIsOrientationHelperVertical = mLayoutManager.canScrollVertically();
        mOrientationHelper = mIsOrientationHelperVertical
                ? OrientationHelper.createVerticalHelper(mLayoutManager)
                : OrientationHelper.createHorizontalHelper(mLayoutManager);
    }

    final int start = mOrientationHelper.getStartAfterPadding();
    final int end = mOrientationHelper.getEndAfterPadding();
    final int next = toIndex > fromIndex ? 1 : -1;
    View partiallyVisible = null;
    for (int i = fromIndex; i != toIndex; i += next) {
        final View child = mLayoutManager.getChildAt(i);
        if (child != null) {
            final int childStart = mOrientationHelper.getDecoratedStart(child);
            final int childEnd = mOrientationHelper.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,代码行数:35,代码来源:EndlessRecyclerOnScrollListener.java

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

示例4: 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:XecureIT,项目名称:PeSanKita-android,代码行数:32,代码来源:RecyclerViewPositionHelper.java

示例5: 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:NICOLITE,项目名称:HutHelper,代码行数:32,代码来源:RecycleViewPositonHelper.java

示例6: getVerticalHelper

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getVerticalHelper(RecyclerView.LayoutManager layoutManager) {
    if (verticalHelper == null) {
        verticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
    }
    return verticalHelper;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:GravityDelegate.java

示例7: getVerticalHelper

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getVerticalHelper(RecyclerView.LayoutManager layoutManager) {
    if (mVerticalHelper == null) {
        mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
    }
    return mVerticalHelper;
}
 
开发者ID:hoanganhtuan95ptit,项目名称:EditPhoto,代码行数:7,代码来源:StartSnapHelper.java

示例8: findSnapView

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
@Override
View findSnapView(RecyclerView.LayoutManager layoutManager) {
    OrientationHelper helper = layoutManager.canScrollHorizontally()
            ? OrientationHelper.createHorizontalHelper(layoutManager)
            : OrientationHelper.createVerticalHelper(layoutManager);
    int childCount = layoutManager.getChildCount();
    if (childCount == 0) return null;

    View closestChild = null;
    int closestPosition = RecyclerView.NO_POSITION;
    final int containerPosition = getContainerPosition(layoutManager, helper);
    int absClosest = Integer.MAX_VALUE;

    for (int i = 0; i < childCount; i++) {
        final View child = layoutManager.getChildAt(i);
        int childPosition = getChildPosition(child, helper);
        int absDistance = Math.abs(childPosition - containerPosition);
        if (helper.getDecoratedStart(child) == 0
                && previousClosestPosition != 0
                && layoutManager.getPosition(child) == 0) {
            //RecyclerView reached start
            closestChild = child;
            closestPosition = layoutManager.getPosition(closestChild);
            break;
        }
        if (helper.getDecoratedEnd(child) == helper.getTotalSpace()
                && previousClosestPosition != layoutManager.getItemCount() - 1
                && layoutManager.getPosition(child) == layoutManager.getItemCount() - 1) {
            //RecyclerView reached end
            closestChild = child;
            closestPosition = layoutManager.getPosition(closestChild);
            break;
        }
        if (previousClosestPosition == layoutManager.getPosition(child) && getDistance(layoutManager, child, helper) == 0) {
            //child is already set to the position.
            closestChild = child;
            break;
        }
        if (layoutManager.getPosition(child) % snapCount != 0) {
            continue;
        }
        if (absDistance < absClosest) {
            absClosest = absDistance;
            closestChild = child;
            closestPosition = layoutManager.getPosition(closestChild);
        }
    }
    previousClosestPosition = closestPosition == RecyclerView.NO_POSITION ? previousClosestPosition : closestPosition;
    isNoOffset = getDistance(layoutManager, closestChild, helper) == 0;
    if (listener != null && closestPosition != RecyclerView.NO_POSITION) {
        listener.snapped(closestPosition);
    }
    return closestChild;
}
 
开发者ID:TakuSemba,项目名称:MultiSnapRecyclerView,代码行数:55,代码来源:SnapHelperDelegator.java

示例9: getVerticalHelper

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getVerticalHelper(RecyclerView.LayoutManager layoutManager) {
  if (mVerticalHelper == null) {
    mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
  }
  return mVerticalHelper;
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:7,代码来源:GravitySnapHelper.java


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