package com.github.pedrovgs.tuentitv.ui.viewpresenter;

import android.content.Context;
import android.support.v17.leanback.widget.Presenter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.github.pedrovgs.tuentitv.model.ImageInfo;
import com.squareup.picasso.Picasso;
import com.tuenti.tuentitv.R;

public class ImagePresenter extends Presenter {

  private static Context context;
  private static int CARD_WIDTH = 300;
  private static int CARD_HEIGHT = 200;

  static class ViewHolder extends Presenter.ViewHolder {

    private ImageInfo imageInfo;
    private ImageView imageView;

    public ViewHolder(View view) {
      super(view);
      imageView = (ImageView) view;
    }

    public void setImageInfo(ImageInfo imageInfo) {
      this.imageInfo = imageInfo;
    }

    protected void updateCardViewImage(String url) {
      Picasso.with(context)
          .load(url)
          .resize(CARD_WIDTH, CARD_HEIGHT)
          .centerCrop()
          .placeholder(R.color.third_color)
          .into(imageView);
    }
  }

  @Override public ViewHolder onCreateViewHolder(ViewGroup parent) {
    context = parent.getContext();
    ImageView imageView = new ImageView(context);
    imageView.setFocusable(true);
    imageView.setFocusableInTouchMode(true);
    imageView.setBackgroundColor(context.getResources().getColor(R.color.third_color));
    return new ViewHolder(imageView);
  }

  @Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    ImageInfo imageInfo = (ImageInfo) item;
    ((ViewHolder) viewHolder).setImageInfo(imageInfo);
    if (imageInfo.getImageUrl() != null) {
      ((ViewHolder) viewHolder).updateCardViewImage(imageInfo.getImageUrl());
    }
  }

  @Override public void onUnbindViewHolder(Presenter.ViewHolder viewHolder) {
    //Empty
  }

  @Override public void onViewAttachedToWindow(Presenter.ViewHolder viewHolder) {
    //Empty
  }
}

@@ -398,30 +398,29 @@
 r %7B%0A%0A  p
-rivate
+ublic
  static 
 Context 
@@ -415,50 +415,69 @@
 tic 
-Context context;%0A  private static int CARD
+final int IMAGE_HEIGHT = 200;%0A  public static final int IMAGE
 _WID
@@ -507,29 +507,23 @@
 tic 
-int CARD_HEIGHT = 200
+Context context
 ;%0A%0A 
@@ -960,20 +960,21 @@
 ize(
-CARD
+IMAGE
 _WIDTH, 
 CARD
@@ -973,12 +973,13 @@
 TH, 
-CARD
+IMAGE
 _HEI
@@ -1194,16 +1194,16 @@
 text();%0A
-
     Imag
@@ -1244,16 +1244,106 @@
 ntext);%0A
+    imageView.setMinimumHeight(IMAGE_HEIGHT);%0A    imageView.setMinimumWidth(IMAGE_WIDTH);%0A
     imag

Fix ImagePresenter issue related to height and width