Search in sources :

Example 31 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project FloatingSearchView by renaudcerrato.

the class BaseItemAnimator method animateMoveImpl.

private void animateMoveImpl(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }
    // TODO: make EndActions end listeners instead, since end actions aren't called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mMoveAnimations.add(holder);
    animation.setDuration(getMoveDuration()).setListener(new VpaListenerAdapter() {

        @Override
        public void onAnimationStart(View view) {
            dispatchMoveStarting(holder);
        }

        @Override
        public void onAnimationCancel(View view) {
            if (deltaX != 0) {
                ViewCompat.setTranslationX(view, 0);
            }
            if (deltaY != 0) {
                ViewCompat.setTranslationY(view, 0);
            }
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchMoveFinished(holder);
            mMoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 32 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project Onboarding by eoinfogarty.

the class ImageAdapter method onCreateViewHolder.

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

Example 33 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project MovieGuide by esoxjem.

the class MoviesListingAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    holder.itemView.setOnClickListener(holder);
    holder.movie = movies.get(position);
    holder.name.setText(holder.movie.getTitle());
    Glide.with(context).load(holder.movie.getPosterPath()).asBitmap().diskCacheStrategy(DiskCacheStrategy.RESULT).into(new BitmapImageViewTarget(holder.poster) {

        @Override
        public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
            super.onResourceReady(bitmap, anim);
            Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {

                @Override
                public void onGenerated(Palette palette) {
                    holder.titleBackground.setBackgroundColor(palette.getVibrantColor(context.getResources().getColor(R.color.black_translucent_60)));
                }
            });
        }
    });
}
Also used : Palette(android.support.v7.graphics.Palette) Bitmap(android.graphics.Bitmap) BitmapImageViewTarget(com.bumptech.glide.request.target.BitmapImageViewTarget) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation)

Example 34 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project MovieGuide by esoxjem.

the class MoviesListingAdapter method onCreateViewHolder.

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

Example 35 with ViewHolder

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

the class SimpleItemTouchHelperCallback method onChildDraw.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
    super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
    // Fade out the view as it is swiped out of the parent's bounds
    if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
        View itemView = viewHolder.itemView;
        final float alpha = ALPHA_FULL - Math.abs(dX) / (float) itemView.getWidth();
        itemView.setAlpha(alpha);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) TargetApi(android.annotation.TargetApi)

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