本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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: 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;
}
示例6: getVerticalHelper
import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getVerticalHelper(RecyclerView.LayoutManager layoutManager) {
if (verticalHelper == null) {
verticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
}
return verticalHelper;
}
示例7: getVerticalHelper
import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getVerticalHelper(RecyclerView.LayoutManager layoutManager) {
if (mVerticalHelper == null) {
mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
}
return mVerticalHelper;
}
示例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;
}
示例9: getVerticalHelper
import android.support.v7.widget.OrientationHelper; //导入方法依赖的package包/类
private OrientationHelper getVerticalHelper(RecyclerView.LayoutManager layoutManager) {
if (mVerticalHelper == null) {
mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
}
return mVerticalHelper;
}