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


Java OrientationHelper.createHorizontalHelper方法代码示例

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


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

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

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

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

示例5: getOrientationHelper

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
public OrientationHelper getOrientationHelper() {

        if (mHorizontalHelper == null) {
            mHorizontalHelper = OrientationHelper.createHorizontalHelper(this);
        }
        return mHorizontalHelper;

    }
 
开发者ID:Manuaravind1989,项目名称:InfiniteTabsView,代码行数:9,代码来源:TabLayoutManager.java

示例6: getHorizontalHelper

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
@NonNull
private OrientationHelper getHorizontalHelper(
        @NonNull RecyclerView.LayoutManager layoutManager) {
    if (mHorizontalHelper == null) {
        mHorizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
    }
    return mHorizontalHelper;
}
 
开发者ID:thaihuynhxyz,项目名称:recycler-view-calendar,代码行数:9,代码来源:CalendarSnapHelper.java

示例7: getHorizontalHelper

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

示例8: LinearLayoutManagerSnapHelper

import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
public LinearLayoutManagerSnapHelper(LinearLayoutManager layoutManager) {
    this.layoutManager = layoutManager;
    this.orientationHelper = OrientationHelper.createHorizontalHelper(this.layoutManager);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:5,代码来源:LinearLayoutManagerSnapHelper.java

示例9: getHorizontalHelper

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

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

示例11: getHorizontalHelper

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


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