Search in sources :

Example 91 with Recycler

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;
}
Also used : ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) RecyclerListener(android.support.v7.widget.RecyclerView.RecyclerListener) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) TextView(android.widget.TextView)

Example 92 with Recycler

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));
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 93 with Recycler

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));
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 94 with Recycler

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);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 95 with Recycler

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;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)108 View (android.view.View)102 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)20 TextView (android.widget.TextView)19 ImageView (android.widget.ImageView)13 OrientationHelper (android.support.v7.widget.OrientationHelper)12 GridLayoutManager (android.support.v7.widget.GridLayoutManager)10 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)10 Point (android.graphics.Point)7 Bundle (android.os.Bundle)7 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)7 SuppressLint (android.annotation.SuppressLint)6 Context (android.content.Context)6 ViewGroup (android.view.ViewGroup)6 ActivityManager (android.app.ActivityManager)5 AccessibilityNodeInfoCompat (android.support.v4.view.accessibility.AccessibilityNodeInfoCompat)5 SpanSizeLookup (android.support.v7.widget.GridLayoutManager.SpanSizeLookup)5 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)5 Recycler (android.support.v7.widget.RecyclerView.Recycler)5 RecyclerListener (android.support.v7.widget.RecyclerView.RecyclerListener)5