本文整理汇总了Java中android.support.v7.widget.RecyclerView.LayoutManager.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java LayoutManager.getChildCount方法的具体用法?Java LayoutManager.getChildCount怎么用?Java LayoutManager.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.RecyclerView.LayoutManager
的用法示例。
在下文中一共展示了LayoutManager.getChildCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSwapTargets
import android.support.v7.widget.RecyclerView.LayoutManager; //导入方法依赖的package包/类
private List<ViewHolder> findSwapTargets(ViewHolder viewHolder) {
if (this.mSwapTargets == null) {
this.mSwapTargets = new ArrayList();
this.mDistances = new ArrayList();
} else {
this.mSwapTargets.clear();
this.mDistances.clear();
}
int margin = this.mCallback.getBoundingBoxMargin();
int left = Math.round(this.mSelectedStartX + this.mDx) - margin;
int top = Math.round(this.mSelectedStartY + this.mDy) - margin;
int right = (viewHolder.itemView.getWidth() + left) + (margin * 2);
int bottom = (viewHolder.itemView.getHeight() + top) + (margin * 2);
int centerX = (left + right) / 2;
int centerY = (top + bottom) / 2;
LayoutManager lm = this.mRecyclerView.getLayoutManager();
int childCount = lm.getChildCount();
for (int i = 0; i < childCount; i++) {
View other = lm.getChildAt(i);
if (other != viewHolder.itemView && other.getBottom() >= top && other.getTop() <= bottom && other.getRight() >= left && other.getLeft() <= right) {
ViewHolder otherVh = this.mRecyclerView.getChildViewHolder(other);
if (this.mCallback.canDropOver(this.mRecyclerView, this.mSelected, otherVh)) {
int dx = Math.abs(centerX - ((other.getLeft() + other.getRight()) / 2));
int dy = Math.abs(centerY - ((other.getTop() + other.getBottom()) / 2));
int dist = (dx * dx) + (dy * dy);
int pos = 0;
int cnt = this.mSwapTargets.size();
int j = 0;
while (j < cnt && dist > ((Integer) this.mDistances.get(j)).intValue()) {
pos++;
j++;
}
this.mSwapTargets.add(pos, otherVh);
this.mDistances.add(pos, Integer.valueOf(dist));
}
}
}
return this.mSwapTargets;
}
示例2: computeScrollOffset
import android.support.v7.widget.RecyclerView.LayoutManager; //导入方法依赖的package包/类
static int computeScrollOffset(State state, OrientationHelper orientation, View startChild, View endChild, LayoutManager lm, boolean smoothScrollbarEnabled, boolean reverseLayout) {
if (lm.getChildCount() == 0 || state.getItemCount() == 0 || startChild == null || endChild == null) {
return 0;
}
int itemsBefore = reverseLayout ? Math.max(0, (state.getItemCount() - Math.max(lm.getPosition(startChild), lm.getPosition(endChild))) - 1) : Math.max(0, Math.min(lm.getPosition(startChild), lm.getPosition(endChild)));
if (!smoothScrollbarEnabled) {
return itemsBefore;
}
return Math.round((((float) itemsBefore) * (((float) Math.abs(orientation.getDecoratedEnd(endChild) - orientation.getDecoratedStart(startChild))) / ((float) (Math.abs(lm.getPosition(startChild) - lm.getPosition(endChild)) + 1)))) + ((float) (orientation.getStartAfterPadding() - orientation.getDecoratedStart(startChild))));
}
示例3: computeScrollExtent
import android.support.v7.widget.RecyclerView.LayoutManager; //导入方法依赖的package包/类
static int computeScrollExtent(State state, OrientationHelper orientation, View startChild, View endChild, LayoutManager lm, boolean smoothScrollbarEnabled) {
if (lm.getChildCount() == 0 || state.getItemCount() == 0 || startChild == null || endChild == null) {
return 0;
}
if (!smoothScrollbarEnabled) {
return Math.abs(lm.getPosition(startChild) - lm.getPosition(endChild)) + 1;
}
return Math.min(orientation.getTotalSpace(), orientation.getDecoratedEnd(endChild) - orientation.getDecoratedStart(startChild));
}
示例4: computeScrollRange
import android.support.v7.widget.RecyclerView.LayoutManager; //导入方法依赖的package包/类
static int computeScrollRange(State state, OrientationHelper orientation, View startChild, View endChild, LayoutManager lm, boolean smoothScrollbarEnabled) {
if (lm.getChildCount() == 0 || state.getItemCount() == 0 || startChild == null || endChild == null) {
return 0;
}
if (!smoothScrollbarEnabled) {
return state.getItemCount();
}
return (int) ((((float) (orientation.getDecoratedEnd(endChild) - orientation.getDecoratedStart(startChild))) / ((float) (Math.abs(lm.getPosition(startChild) - lm.getPosition(endChild)) + 1))) * ((float) state.getItemCount()));
}
示例5: draw
import android.support.v7.widget.RecyclerView.LayoutManager; //导入方法依赖的package包/类
private void draw(Canvas c, RecyclerView parent, int firstItem, LayoutManager layoutManager) {
for (int i = 0; i < layoutManager.getChildCount(); i++) {
final int viewAdapterPosition = firstItem + i;
final View view = layoutManager.findViewByPosition(viewAdapterPosition);
if (view != null) {
mItemDecorationCallback.draw(c, mTextPaint, view,
mItemDecorationCallback.getItemOffsets(layoutManager, viewAdapterPosition,
getEdge(viewAdapterPosition, layoutManager)),
layoutManager.getItemCount(), viewAdapterPosition);
}
}
}