Search in sources :

Example 36 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project AwesomeRecyclerView by forceLain.

the class AwesomeLayoutManager method fill.

private void fill(RecyclerView.Recycler recycler) {
    View anchorView = getAnchorView();
    viewCache.clear();
    for (int i = 0, cnt = getChildCount(); i < cnt; i++) {
        View view = getChildAt(i);
        int pos = getPosition(view);
        viewCache.put(pos, view);
    }
    for (int i = 0; i < viewCache.size(); i++) {
        detachView(viewCache.valueAt(i));
    }
    switch(orientation) {
        case VERTICAL:
            fillUp(anchorView, recycler);
            fillDown(anchorView, recycler);
            break;
        case HORIZONTAL:
            fillLeft(anchorView, recycler);
            fillRight(anchorView, recycler);
            break;
    }
    for (int i = 0; i < viewCache.size(); i++) {
        recycler.recycleView(viewCache.valueAt(i));
    }
    updateViewScale();
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 37 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project AwesomeRecyclerView by forceLain.

the class AwesomeLayoutManager method fillRight.

private void fillRight(View anchorView, RecyclerView.Recycler recycler) {
    int anchorPos;
    int anchorLeft = 0;
    if (anchorView != null) {
        anchorPos = getPosition(anchorView);
        anchorLeft = getDecoratedLeft(anchorView);
    } else {
        anchorPos = mAnchorPos;
    }
    int pos = anchorPos;
    boolean fillRight = true;
    int viewLeft = anchorLeft;
    int itemCount = getItemCount();
    int width = getWidth();
    int height = getHeight();
    final int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
    final int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST);
    while (fillRight && pos < itemCount) {
        View view = viewCache.get(pos);
        if (view == null) {
            view = recycler.getViewForPosition(pos);
            addView(view);
            measureChildWithDecorationsAndMargin(view, widthSpec, heightSpec);
            int decoratedMeasuredHeight = getDecoratedMeasuredHeight(view);
            int decoratedMeasuredWidth = getDecoratedMeasuredWidth(view);
            layoutDecorated(view, viewLeft, 0, viewLeft + decoratedMeasuredWidth, decoratedMeasuredHeight);
        } else {
            attachView(view);
            viewCache.remove(pos);
        }
        viewLeft = getDecoratedRight(view);
        fillRight = viewLeft <= width;
        pos++;
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 38 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project fresco by facebook.

the class MainFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mConfig = Config.load(getContext());
    // Initialize the SimpleAdapter
    mSimpleAdapter = initializeSimpleAdapter(mConfig);
    // We use a different layout based on the type of output
    final View layout;
    switch(mConfig.recyclerLayoutType) {
        case Const.RECYCLER_VIEW_LAYOUT_VALUE:
            layout = inflater.inflate(R.layout.content_recyclerview, container, false);
            initializeRecyclerView(layout);
            break;
        case Const.LISTVIEW_LAYOUT_VALUE:
            layout = inflater.inflate(R.layout.content_listview, container, false);
            initializeListView(layout);
            break;
        case Const.GRID_RECYCLER_VIEW_LAYOUT_VALUE:
            layout = inflater.inflate(R.layout.content_recyclerview, container, false);
            initializeGridRecyclerView(layout);
            break;
        default:
            throw new IllegalStateException("Recycler Layout not supported");
    }
    updateAdapter();
    return layout;
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ListView(android.widget.ListView)

Example 39 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project agera by google.

the class NotesFragment method onCreateView.

@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.notes_fragment, container, false);
    // Find the clear button and wire the click listener to call the clear notes updatable
    view.findViewById(R.id.clear).setOnClickListener(v -> notesStore.clearNotes());
    // Find the add button and wire the click listener to show a dialog that in turn calls the add
    // note from text from the notes store when adding notes
    view.findViewById(R.id.add).setOnClickListener(v -> {
        final EditText editText = new EditText(v.getContext());
        editText.setId(R.id.edit);
        new AlertDialog.Builder(v.getContext()).setTitle(R.string.add_note).setView(editText).setPositiveButton(R.string.add, (d, i) -> {
            notesStore.insertNoteFromText(editText.getText().toString());
        }).create().show();
    });
    // Setup the recycler view using the repository adapter
    recyclerView = (RecyclerView) view.findViewById(R.id.result);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    final ImageView imageView = (ImageView) view.findViewById(R.id.background);
    updatable = () -> backgroundRepository.get().ifSucceededSendTo(imageView::setImageBitmap);
    return view;
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) ImageView(android.widget.ImageView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Nullable(android.support.annotation.Nullable)

Example 40 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project DiscreteScrollView by yarolegovich.

the class DiscreteScrollLayoutManager method initChildDimensions.

private void initChildDimensions(RecyclerView.Recycler recycler) {
    View viewToMeasure = recycler.getViewForPosition(0);
    addView(viewToMeasure);
    measureChildWithMargins(viewToMeasure, 0, 0);
    int childViewWidth = getDecoratedMeasuredWidth(viewToMeasure);
    int childViewHeight = getDecoratedMeasuredHeight(viewToMeasure);
    childHalfWidth = childViewWidth / 2;
    childHalfHeight = childViewHeight / 2;
    scrollToChangeCurrent = orientationHelper.getDistanceToChangeCurrent(childViewWidth, childViewHeight);
    detachAndScrapView(viewToMeasure, recycler);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Point(android.graphics.Point)

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