// Path: app/src/main/java/android/support/v17/leanback/streamingapp/model/Card.java
// public class Card {
//     @SerializedName("id") private String id;
//     @SerializedName("type") private Card.Type type;
//     @SerializedName("title") private String title = "";
//     @SerializedName("subtitle") private String subtitle = "";
//     @SerializedName("localImageResource") private String localImageResource = null;
//     @SerializedName("image") private String imageUrl = null;
//     @SerializedName("footerColor") private String footerColor = null;
//     @SerializedName("params") private String params = null;
// 
//     public enum Type {
//         SQUARE_SINGLE_LINE,
//         SQUARE_SINGLE_LINE_CENTERED,
//         SQUARE_TWO_LINE,
//         MOVIE,
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public Card.Type getType() {
//         return type;
//     }
// 
//     public void setType(Card.Type type) {
//         this.type = type;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getSubtitle() {
//         return subtitle;
//     }
// 
//     public void setSubtitle(String subtitle) {
//         this.subtitle = subtitle;
//     }
// 
//     public String getLocalImageResource() {
//         return localImageResource;
//     }
// 
//     public void setLocalImageResource(String localImageResource) {
//         this.localImageResource = localImageResource;
//     }
// 
//     public String getImageUrl() {
//         return imageUrl;
//     }
// 
//     public void setImageUrl(String imageUrl) {
//         this.imageUrl = imageUrl;
//     }
// 
//     public int getFooterColor() {
//         if (this.footerColor == null) return -1;
//         return Color.parseColor(this.footerColor);
//     }
// 
//     public void setFooterColor(String footerColor) {
//         this.footerColor = footerColor;
//     }
// 
//     public String getParams() {
//         return params;
//     }
// 
//     public void setParams(String params) {
//         this.params = params;
//     }
// }
// 
// Path: app/src/main/java/android/support/v17/leanback/streamingapp/presenter/card/ImageCardPresenter.java
// public class ImageCardPresenter extends AbstractCardPresenter<ImageCardView> {
//     public ImageCardPresenter(Context context, int cardThemeResId) {
//         super(new ContextThemeWrapper(context, cardThemeResId));
//     }
// 
// //    public ImageCardPresenter(Context context) {
// //        this(context, R.style.DefaultCardTheme);
// //    }
// 
// 
//     // TODO DELETE THIS
//     @Override
//     protected ImageCardView onCreateView() {
//         ImageCardView imageCardView = new ImageCardView(getContext());
// //        imageCardView.setOnClickListener(new View.OnClickListenr() {
// //            @Override
// //            public void onClick(View v) {
// //                Toast.makeText(getContext(), "Clicked on ImageCardView", Toast.LENGTH_SHORT).show();
// //            }
// //        });
//         return imageCardView;
//     }
// 
//     @Override
//     public void onBindViewHolder(Card card, final ImageCardView cardView) {
//         cardView.setTag(card);
//         cardView.setTitleText(card.getTitle());
//         cardView.setContentText(card.getSubtitle());
// 
//         if(card.getFooterColor() == -1) {
//             cardView.setInfoAreaBackgroundColor(Color.parseColor(getContext().getResources().getString(0 + R.color.default_card_footer_background_color)));
//         } else {
//             cardView.setInfoAreaBackgroundColor(card.getFooterColor());
//         }
// 
//         if (card.getImageUrl() != null) {
//             Picasso.with(getContext()).load(card.getImageUrl()).into(cardView.getMainImageView());
// 
//         } else if (card.getLocalImageResource() != null) {
//             int resourceId = getContext().getResources()
//                     .getIdentifier(card.getLocalImageResource(),
//                             "drawable", getContext().getPackageName());
//             Picasso.with(getContext()).load(resourceId).into(cardView.getMainImageView());
//         }
//     }
// }


import android.content.Context;
import android.support.v17.leanback.streamingapp.R;
import android.support.v17.leanback.streamingapp.model.Card;
import android.support.v17.leanback.streamingapp.presenter.card.ImageCardPresenter;
import android.support.v17.leanback.widget.Presenter;
import android.support.v17.leanback.widget.PresenterSelector;
import java.util.HashMap;
package android.support.v17.leanback.streamingapp.presenter;



public class CardPresenterSelector extends PresenterSelector {

    private final Context mContext;
    private final HashMap<Card.Type, Presenter> presenters = new HashMap<Card.Type, Presenter>();

    public CardPresenterSelector(Context context) {
        mContext = context;
    }

    @Override
    public Presenter getPresenter(Object item) {
        if (!(item instanceof Card)) throw new RuntimeException(
                String.format("The PresenterSelector only supports data items of type '%s'",
                        Card.class.getName()));
        Card card = (Card) item;
        Presenter presenter = presenters.get(card.getType());
        if (presenter == null) {
            switch (card.getType()) {
                case SQUARE_SINGLE_LINE:
                    presenter = new ImageCardPresenter(mContext, R.style.SquareSingleLineCardTheme);
                    break;
                case SQUARE_SINGLE_LINE_CENTERED:
                    presenter = new ImageCardPresenter(mContext, R.style.SquareSingleLineCenteredCardTheme);
                    break;
                case SQUARE_TWO_LINE:
// Path: app/src/main/java/android/support/v17/leanback/streamingapp/model/Card.java
// public class Card {
//     @SerializedName("id") private String id;
//     @SerializedName("type") private Card.Type type;
//     @SerializedName("title") private String title = "";
//     @SerializedName("subtitle") private String subtitle = "";
//     @SerializedName("localImageResource") private String localImageResource = null;
//     @SerializedName("image") private String imageUrl = null;
//     @SerializedName("footerColor") private String footerColor = null;
//     @SerializedName("params") private String params = null;
// 
//     public enum Type {
//         SQUARE_SINGLE_LINE,
//         SQUARE_SINGLE_LINE_CENTERED,
//         SQUARE_TWO_LINE,
//         MOVIE,
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public Card.Type getType() {
//         return type;
//     }
// 
//     public void setType(Card.Type type) {
//         this.type = type;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getSubtitle() {
//         return subtitle;
//     }
// 
//     public void setSubtitle(String subtitle) {
//         this.subtitle = subtitle;
//     }
// 
//     public String getLocalImageResource() {
//         return localImageResource;
//     }
// 
//     public void setLocalImageResource(String localImageResource) {
//         this.localImageResource = localImageResource;
//     }
// 
//     public String getImageUrl() {
//         return imageUrl;
//     }
// 
//     public void setImageUrl(String imageUrl) {
//         this.imageUrl = imageUrl;
//     }
// 
//     public int getFooterColor() {
//         if (this.footerColor == null) return -1;
//         return Color.parseColor(this.footerColor);
//     }
// 
//     public void setFooterColor(String footerColor) {
//         this.footerColor = footerColor;
//     }
// 
//     public String getParams() {
//         return params;
//     }
// 
//     public void setParams(String params) {
//         this.params = params;
//     }
// }
// 
// Path: app/src/main/java/android/support/v17/leanback/streamingapp/presenter/card/ImageCardPresenter.java
// public class ImageCardPresenter extends AbstractCardPresenter<ImageCardView> {
//     public ImageCardPresenter(Context context, int cardThemeResId) {
//         super(new ContextThemeWrapper(context, cardThemeResId));
//     }
// 
// //    public ImageCardPresenter(Context context) {
// //        this(context, R.style.DefaultCardTheme);
// //    }
// 
// 
//     // TODO DELETE THIS
//     @Override
//     protected ImageCardView onCreateView() {
//         ImageCardView imageCardView = new ImageCardView(getContext());
// //        imageCardView.setOnClickListener(new View.OnClickListenr() {
// //            @Override
// //            public void onClick(View v) {
// //                Toast.makeText(getContext(), "Clicked on ImageCardView", Toast.LENGTH_SHORT).show();
// //            }
// //        });
//         return imageCardView;
//     }
// 
//     @Override
//     public void onBindViewHolder(Card card, final ImageCardView cardView) {
//         cardView.setTag(card);
//         cardView.setTitleText(card.getTitle());
//         cardView.setContentText(card.getSubtitle());
// 
//         if(card.getFooterColor() == -1) {
//             cardView.setInfoAreaBackgroundColor(Color.parseColor(getContext().getResources().getString(0 + R.color.default_card_footer_background_color)));
//         } else {
//             cardView.setInfoAreaBackgroundColor(card.getFooterColor());
//         }
// 
//         if (card.getImageUrl() != null) {
//             Picasso.with(getContext()).load(card.getImageUrl()).into(cardView.getMainImageView());
// 
//         } else if (card.getLocalImageResource() != null) {
//             int resourceId = getContext().getResources()
//                     .getIdentifier(card.getLocalImageResource(),
//                             "drawable", getContext().getPackageName());
//             Picasso.with(getContext()).load(resourceId).into(cardView.getMainImageView());
//         }
//     }
// }


// Path: app/src/main/java/android/support/v17/leanback/streamingapp/presenter/CardPresenterSelector.java
import android.content.Context;
import android.support.v17.leanback.streamingapp.R;
import android.support.v17.leanback.streamingapp.model.Card;
import android.support.v17.leanback.streamingapp.presenter.card.ImageCardPresenter;
import android.support.v17.leanback.widget.Presenter;
import android.support.v17.leanback.widget.PresenterSelector;
import java.util.HashMap;

package android.support.v17.leanback.streamingapp.presenter;



public class CardPresenterSelector extends PresenterSelector {

    private final Context mContext;
    private final HashMap<Card.Type, Presenter> presenters = new HashMap<Card.Type, Presenter>();

    public CardPresenterSelector(Context context) {
        mContext = context;
    }

    @Override
    public Presenter getPresenter(Object item) {
        if (!(item instanceof Card)) throw new RuntimeException(
                String.format("The PresenterSelector only supports data items of type '%s'",
                        Card.class.getName()));
        Card card = (Card) item;
        Presenter presenter = presenters.get(card.getType());
        if (presenter == null) {
            switch (card.getType()) {
                case SQUARE_SINGLE_LINE:
                    presenter = new ImageCardPresenter(mContext, R.style.SquareSingleLineCardTheme);
                    break;
                case SQUARE_SINGLE_LINE_CENTERED:
                    presenter = new ImageCardPresenter(mContext, R.style.SquareSingleLineCenteredCardTheme);
                    break;
                case SQUARE_TWO_LINE:
                    presenter = new ImageCardPresenter(mContext, R.style.SquareTwoLineCardTheme);