本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: getOrientationHelper
import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
public OrientationHelper getOrientationHelper() {
if (mHorizontalHelper == null) {
mHorizontalHelper = OrientationHelper.createHorizontalHelper(this);
}
return mHorizontalHelper;
}
示例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;
}
示例7: getHorizontalHelper
import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getHorizontalHelper(RecyclerView.LayoutManager layoutManager) {
if (horizontalHelper == null) {
horizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
}
return horizontalHelper;
}
示例8: LinearLayoutManagerSnapHelper
import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
public LinearLayoutManagerSnapHelper(LinearLayoutManager layoutManager) {
this.layoutManager = layoutManager;
this.orientationHelper = OrientationHelper.createHorizontalHelper(this.layoutManager);
}
示例9: getHorizontalHelper
import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getHorizontalHelper(RecyclerView.LayoutManager layoutManager) {
if (mHorizontalHelper == null) {
mHorizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
}
return mHorizontalHelper;
}
示例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;
}
示例11: getHorizontalHelper
import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getHorizontalHelper(RecyclerView.LayoutManager layoutManager) {
if (mHorizontalHelper == null) {
mHorizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
}
return mHorizontalHelper;
}