use of android.support.v7.widget.RecyclerView.Recycler in project platform_frameworks_base by android.
the class DirectoryFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mInflater = inflater;
final View view = inflater.inflate(R.layout.fragment_directory, container, false);
mMessageBar = MessageBar.create(getChildFragmentManager());
mProgressBar = view.findViewById(R.id.progressbar);
mEmptyView = view.findViewById(android.R.id.empty);
mRecView = (RecyclerView) view.findViewById(R.id.dir_list);
mRecView.setRecyclerListener(new RecyclerListener() {
@Override
public void onViewRecycled(ViewHolder holder) {
cancelThumbnailTask(holder.itemView);
}
});
mRecView.setItemAnimator(new DirectoryItemAnimator(getActivity()));
// Make the recycler and the empty views responsive to drop events.
mRecView.setOnDragListener(mOnDragListener);
mEmptyView.setOnDragListener(mOnDragListener);
return view;
}
use of android.support.v7.widget.RecyclerView.Recycler in project twoway-view by lucasr.
the class SpannableGridLayoutManager method moveLayoutToPosition.
@Override
protected void moveLayoutToPosition(int position, int offset, Recycler recycler, State state) {
final boolean isVertical = isVertical();
final Lanes lanes = getLanes();
lanes.reset(0);
for (int i = 0; i <= position; i++) {
SpannableItemEntry entry = (SpannableItemEntry) getItemEntryForPosition(i);
if (entry == null) {
final View child = recycler.getViewForPosition(i);
entry = (SpannableItemEntry) cacheChildLaneAndSpan(child, Direction.END);
}
mTempLaneInfo.set(entry.startLane, entry.anchorLane);
// removed item. See BaseLayoutManager.invalidateItemLanes().
if (mTempLaneInfo.isUndefined()) {
lanes.findLane(mTempLaneInfo, getLaneSpanForPosition(i), Direction.END);
entry.setLane(mTempLaneInfo);
}
lanes.getChildFrame(mTempRect, getChildWidth(entry.colSpan), getChildHeight(entry.rowSpan), mTempLaneInfo, Direction.END);
if (i != position) {
pushChildFrame(entry, mTempRect, entry.startLane, getLaneSpan(entry, isVertical), Direction.END);
}
}
lanes.getLane(mTempLaneInfo.startLane, mTempRect);
lanes.reset(Direction.END);
lanes.offset(offset - (isVertical ? mTempRect.bottom : mTempRect.right));
}
use of android.support.v7.widget.RecyclerView.Recycler in project twoway-view by lucasr.
the class StaggeredGridLayoutManager method moveLayoutToPosition.
@Override
void moveLayoutToPosition(int position, int offset, Recycler recycler, State state) {
final boolean isVertical = isVertical();
final Lanes lanes = getLanes();
lanes.reset(0);
for (int i = 0; i <= position; i++) {
StaggeredItemEntry entry = (StaggeredItemEntry) getItemEntryForPosition(i);
if (entry != null) {
mTempLaneInfo.set(entry.startLane, entry.anchorLane);
// removed item. See BaseLayoutManager.invalidateItemLanes().
if (mTempLaneInfo.isUndefined()) {
lanes.findLane(mTempLaneInfo, getLaneSpanForPosition(i), Direction.END);
entry.setLane(mTempLaneInfo);
}
lanes.getChildFrame(mTempRect, entry.width, entry.height, mTempLaneInfo, Direction.END);
} else {
final View child = recycler.getViewForPosition(i);
// XXX: This might potentially cause stalls in the main
// thread if the layout ends up having to measure tons of
// child views. We might need to add different policies based
// on known assumptions regarding certain layouts e.g. child
// views have stable aspect ratio, lane size is fixed, etc.
measureChild(child, Direction.END);
// The measureChild() call ensures an entry is created for
// this position.
entry = (StaggeredItemEntry) getItemEntryForPosition(i);
mTempLaneInfo.set(entry.startLane, entry.anchorLane);
lanes.getChildFrame(mTempRect, getDecoratedMeasuredWidth(child), getDecoratedMeasuredHeight(child), mTempLaneInfo, Direction.END);
cacheItemFrame(entry, mTempRect);
}
if (i != position) {
pushChildFrame(entry, mTempRect, entry.startLane, entry.span, Direction.END);
}
}
lanes.getLane(mTempLaneInfo.startLane, mTempRect);
lanes.reset(Direction.END);
lanes.offset(offset - (isVertical ? mTempRect.bottom : mTempRect.right));
}
use of android.support.v7.widget.RecyclerView.Recycler in project twoway-view by lucasr.
the class TwoWayLayoutManager method recycleChildrenFromEnd.
private void recycleChildrenFromEnd(Direction direction, Recycler recycler) {
final int childrenEnd = getEndWithPadding();
final int childCount = getChildCount();
int firstDetachedPos = 0;
int detachedCount = 0;
for (int i = childCount - 1; i >= 0; i--) {
final View child = getChildAt(i);
final int childStart = getChildStart(child);
if (childStart <= childrenEnd) {
break;
}
firstDetachedPos = i;
detachedCount++;
detachChild(child, direction);
}
while (--detachedCount >= 0) {
final View child = getChildAt(firstDetachedPos);
removeAndRecycleViewAt(firstDetachedPos, recycler);
updateLayoutEdgesFromRemovedChild(child, direction);
}
}
use of android.support.v7.widget.RecyclerView.Recycler in project twoway-view by lucasr.
the class TwoWayLayoutManager method makeAndAddView.
private View makeAndAddView(int position, Direction direction, Recycler recycler) {
final View child = recycler.getViewForPosition(position);
final boolean isItemRemoved = ((LayoutParams) child.getLayoutParams()).isItemRemoved();
if (!isItemRemoved) {
addView(child, (direction == Direction.END ? -1 : 0));
}
setupChild(child, direction);
if (!isItemRemoved) {
updateLayoutEdgesFromNewChild(child);
}
return child;
}
Aggregations