Search in sources :

Example 21 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project SwipeRecyclerView by yanzhenjie.

the class SwipeMenuRecyclerView method smoothOpenMenu.

/**
     * open menu.
     *
     * @param position  position.
     * @param direction use {@link #LEFT_DIRECTION}, {@link #RIGHT_DIRECTION}.
     * @param duration  time millis.
     */
public void smoothOpenMenu(int position, @DirectionMode int direction, int duration) {
    if (mOldSwipedLayout != null) {
        if (mOldSwipedLayout.isMenuOpen()) {
            mOldSwipedLayout.smoothCloseMenu();
        }
    }
    ViewHolder vh = findViewHolderForAdapterPosition(position);
    if (vh != null) {
        View itemView = getSwipeMenuView(vh.itemView);
        if (itemView instanceof SwipeMenuLayout) {
            mOldSwipedLayout = (SwipeMenuLayout) itemView;
            if (direction == RIGHT_DIRECTION) {
                mOldTouchedPosition = position;
                mOldSwipedLayout.smoothOpenRightMenu(duration);
            } else if (direction == LEFT_DIRECTION) {
                mOldTouchedPosition = position;
                mOldSwipedLayout.smoothOpenLeftMenu(duration);
            }
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 22 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project MagicCamera by wuhaoyu1990.

the class FilterAdapter method onCreateViewHolder.

@Override
public FilterHolder onCreateViewHolder(ViewGroup arg0, int arg1) {
    if (arg1 != -1) {
        View view = mInflater.inflate(R.layout.filter_item_layout, arg0, false);
        FilterHolder viewHolder = new FilterHolder(view);
        viewHolder.thumbImage = (ImageView) view.findViewById(R.id.filter_thumb_image);
        viewHolder.filterName = (TextView) view.findViewById(R.id.filter_thumb_name);
        viewHolder.filterRoot = (FrameLayout) view.findViewById(R.id.filter_root);
        viewHolder.thumbSelected = (FrameLayout) view.findViewById(R.id.filter_thumb_selected);
        viewHolder.filterFavourite = (FrameLayout) view.findViewById(R.id.filter_thumb_favorite_layout);
        viewHolder.thumbSelected_bg = (View) view.findViewById(R.id.filter_thumb_selected_bg);
        return viewHolder;
    } else {
        View view = mInflater.inflate(R.layout.filter_division_layout, arg0, false);
        FilterHolder viewHolder = new FilterHolder(view);
        return viewHolder;
    }
}
Also used : ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 23 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project LookLook by xinghongfei.

the class GridItemDividerDecoration method onDrawOver.

@Override
public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
    if (parent.isAnimating())
        return;
    final int childCount = parent.getChildCount();
    final RecyclerView.LayoutManager lm = parent.getLayoutManager();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(child);
        if (requiresDivider(viewHolder)) {
            final int right = lm.getDecoratedRight(child);
            final int bottom = lm.getDecoratedBottom(child);
            // draw the bottom divider
            canvas.drawRect(lm.getDecoratedLeft(child), bottom - dividerSize, right, bottom, paint);
            // draw the right edge divider
            canvas.drawRect(right - dividerSize, lm.getDecoratedTop(child), right, bottom - dividerSize, paint);
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Example 24 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project vlayout by alibaba.

the class VirtualLayoutManager method detachAndScrapAttachedViews.

@Override
public void detachAndScrapAttachedViews(RecyclerView.Recycler recycler) {
    int childCount = this.getChildCount();
    for (int i = childCount - 1; i >= 0; --i) {
        View v = this.getChildAt(i);
        RecyclerView.ViewHolder holder = getChildViewHolder(v);
        if (holder instanceof CacheViewHolder && ((CacheViewHolder) holder).needCached()) {
            // mark not invalid, ignore DataSetChange(), make the ViewHolder itself to maitain the data
            ViewHolderWrapper.setFlags(holder, 0, FLAG_INVALID | FLAG_UPDATED);
        }
    }
    super.detachAndScrapAttachedViews(recycler);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 25 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project MaterializeYourApp by antoniolg.

the class RecyclerViewAdapter method onCreateViewHolder.

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycler, parent, false);
    v.setOnClickListener(this);
    return new ViewHolder(v);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)265 View (android.view.View)248 TextView (android.widget.TextView)129 ImageView (android.widget.ImageView)95 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)47 LayoutInflater (android.view.LayoutInflater)34 ViewGroup (android.view.ViewGroup)32 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)28 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)27 Intent (android.content.Intent)26 ArrayList (java.util.ArrayList)25 Context (android.content.Context)21 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)17 BindView (butterknife.BindView)17 CardView (android.support.v7.widget.CardView)15 Paint (android.graphics.Paint)11 ParallaxRecyclerAdapter (com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter)8 ExampleData (de.madcyph3r.example.data.ExampleData)8 Drawable (android.graphics.drawable.Drawable)7 Test (org.junit.Test)7