Search in sources :

Example 56 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project smartmodule by carozhu.

the class FullyLinearLayoutManager method measureScrapChild.

private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec, int heightSpec, int[] measuredDimension) {
    try {
        //fix 动态添加时报IndexOutOfBoundsException
        View view = recycler.getViewForPosition(0);
        if (view != null) {
            RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
            int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec, getPaddingLeft() + getPaddingRight(), p.width);
            int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec, getPaddingTop() + getPaddingBottom(), p.height);
            view.measure(childWidthSpec, childHeightSpec);
            measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
            measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
            recycler.recycleView(view);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 57 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project smartmodule by carozhu.

the class MyLinearLayoutManager method measureScrapChild.

private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec, int heightSpec, int[] measuredDimension) {
    try {
        //fix 动态添加时报IndexOutOfBoundsException
        View view = recycler.getViewForPosition(0);
        if (view != null) {
            RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
            int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec, getPaddingLeft() + getPaddingRight(), p.width);
            int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec, getPaddingTop() + getPaddingBottom(), p.height);
            view.measure(childWidthSpec, childHeightSpec);
            measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
            measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
            recycler.recycleView(view);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 58 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project android_frameworks_base by crdroidandroid.

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 59 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project DragTopLayout by chenupt.

the class RecyclerFragment method initViews.

private void initViews() {
    RecyclerView recyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    // init recycler view
    ModelRecyclerAdapter adapter = new ModelRecyclerAdapter(getActivity(), DataService.getInstance().getModelManager());
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(adapter);
    // set data source
    adapter.setList(DataService.getInstance().getList());
    adapter.notifyDataSetChanged();
    // attach top listener
    recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            EventBus.getDefault().post(AttachUtil.isRecyclerViewAttach(recyclerView));
        }
    });
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) ModelRecyclerAdapter(github.chenupt.multiplemodel.recycler.ModelRecyclerAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 60 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project UltimateRecyclerView by cymcsg.

the class CustomLinearLayoutManager method measureScrapChild.

private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec, int heightSpec, int[] measuredDimension) {
    View view = recycler.getViewForPosition(position);
    if (view != null) {
        RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
        int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec, getPaddingLeft() + getPaddingRight(), p.width);
        int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec, getPaddingTop() + getPaddingBottom(), p.height);
        view.measure(childWidthSpec, childHeightSpec);
        measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
        measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
        recycler.recycleView(view);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)106 View (android.view.View)100 TextView (android.widget.TextView)19 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)15 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 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)7 SuppressLint (android.annotation.SuppressLint)6 Context (android.content.Context)6 Bundle (android.os.Bundle)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 ViewGroup (android.view.ViewGroup)5