Search in sources :

Example 46 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project greedo-layout-for-android by 500px.

the class GreedoLayoutManager method onLayoutChildren.

// The initial call from the framework, received when we need to start laying out the initial
// set of views, or when the user changes the data set
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
    // We have nothing to show for an empty data set but clear any existing views
    if (getItemCount() == 0) {
        detachAndScrapAttachedViews(recycler);
        return;
    }
    mSizeCalculator.setContentWidth(getContentWidth());
    mSizeCalculator.reset();
    int initialTopOffset = 0;
    if (getChildCount() == 0) {
        // First or empty layout
        mFirstVisiblePosition = 0;
        mFirstVisibleRow = 0;
    } else {
        // Adapter data set changes
        // Keep the existing initial position, and save off the current scrolled offset.
        final View topChild = getChildAt(0);
        if (mForceClearOffsets) {
            initialTopOffset = 0;
            mForceClearOffsets = false;
        } else {
            initialTopOffset = getDecoratedTop(topChild);
        }
    }
    detachAndScrapAttachedViews(recycler);
    preFillGrid(Direction.NONE, 0, initialTopOffset, recycler, state);
    mPendingScrollPositionOffset = 0;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 47 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)

Example 48 with Recycler

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

the class DiscreteScrollLayoutManager method layoutView.

private void layoutView(RecyclerView.Recycler recycler, int position, Point viewCenter) {
    View v = detachedCache.get(position);
    if (v == null) {
        v = recycler.getViewForPosition(position);
        addView(v);
        measureChildWithMargins(v, 0, 0);
        layoutDecoratedWithMargins(v, viewCenter.x - childHalfWidth, viewCenter.y - childHalfHeight, viewCenter.x + childHalfWidth, viewCenter.y + childHalfHeight);
    } else {
        attachView(v);
        detachedCache.remove(position);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 49 with Recycler

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

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

use of android.support.v7.widget.RecyclerView.Recycler in project mosby by sockeqwe.

the class CountriesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.countries_list);
    ButterKnife.bind(this);
    // Setup contentView == SwipeRefreshView
    contentView.setOnRefreshListener(this);
    // Setup recycler view
    adapter = new CountriesAdapter(this);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);
    loadData(false);
}
Also used : CountriesAdapter(com.hannesdorfmann.mosby3.sample.mvp.CountriesAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

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