package com.mikescamell.sharedelementtransitions.recycler_view;

import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.mikescamell.sharedelementtransitions.R;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;

/**
 * Created by msc10 on 16/02/2017.
 */

public class AnimalGalleryAdapter extends RecyclerView.Adapter<AnimalGalleryAdapter.ImageViewHolder> {

    private final AnimalItemClickListener animalItemClickListener;
    private ArrayList<AnimalItem> animalItems;

    public AnimalGalleryAdapter(ArrayList<AnimalItem> animalItems, AnimalItemClickListener animalItemClickListener) {
        this.animalItems = animalItems;
        this.animalItemClickListener = animalItemClickListener;
    }

    @Override
    public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ImageViewHolder(LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_animal_square, parent, false));
    }

    @Override
    public int getItemCount() {
        return animalItems.size();
    }

    @Override
    public void onBindViewHolder(final ImageViewHolder holder, final int position) {
        final AnimalItem animalItem = animalItems.get(position);

        Picasso.with(holder.itemView.getContext())
                .load(animalItem.imageUrl)
                .into(holder.animalImageView);

        final String transitionName = "animal_image_" + String.valueOf(position);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            holder.animalImageView.setTransitionName(transitionName);
        }

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                animalItemClickListener.onAnimalItemClick(position, animalItem, holder.animalImageView);
            }
        });
    }

    public static class ImageViewHolder extends RecyclerView.ViewHolder {

        private ImageView animalImageView;

        public ImageViewHolder(View itemView) {
            super(itemView);
            animalImageView = (ImageView) itemView.findViewById(R.id.item_animal_square_image);
        }
    }
}

@@ -77,16 +77,34 @@
 oid.
-os.Build
+support.v4.view.ViewCompat
 ;%0Aim
@@ -1297,22 +1297,16 @@
  holder,
- final
  int pos
@@ -1310,24 +1310,24 @@
 position) %7B%0A
+
         fina
@@ -1534,230 +1534,78 @@
     
-final String transitionName = %22animal_image_%22 + String.valueOf(position);%0A        if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.LOLLIPOP) %7B%0A            holder.animalImageView.setTransitionName(transitionName);%0A        %7D
+ViewCompat.setTransitionName(holder.animalImageView, animalItem.name);
 %0A%0A  
@@ -1796,24 +1796,43 @@
 emClick(
-p
+holder.getAdapterP
 osition
+()
 , animal

Tidy onBindViewHolder