package com.tuenti.tuentitv.ui.androidpresenter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v17.leanback.widget.ImageCardView;
import android.support.v17.leanback.widget.Presenter;
import android.view.View;
import android.view.ViewGroup;
import com.squareup.picasso.Picasso;
import com.tuenti.tuentitv.R;
import com.tuenti.tuentitv.ui.model.Account;
import com.tuenti.tuentitv.ui.picasso.PicassoImageCardViewTarget;

/**
 * @author Pedro Vicente Gómez Sánchez.
 */

public class AccountPresenter extends Presenter {

  private static final int CARD_WIDTH = 313;
  private static final int CARD_HEIGHT = 176;

  private static Context context;

  static class ViewHolder extends Presenter.ViewHolder {
    private ImageCardView cardView;
    private Drawable defaultCardImage;
    private PicassoImageCardViewTarget imageCardViewTarget;

    public ViewHolder(View view) {
      super(view);
      cardView = (ImageCardView) view;
      imageCardViewTarget = new PicassoImageCardViewTarget(context, cardView);
      defaultCardImage = context.getResources().getDrawable(R.drawable.ic_launcher);
    }

    protected void updateCardViewImage(String url) {
      Picasso.with(context)
          .load(url)
          .resize(CARD_WIDTH, CARD_HEIGHT)
          .centerCrop()
          .error(defaultCardImage)
          .into(imageCardViewTarget);
    }
  }

  @Override public ViewHolder onCreateViewHolder(ViewGroup parent) {
    context = parent.getContext();

    ImageCardView cardView = new ImageCardView(context);
    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    cardView.setBackgroundColor(context.getResources().getColor(R.color.white));
    return new ViewHolder(cardView);
  }

  @Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    Account account = (Account) item;
    ImageCardView cardView = ((ViewHolder) viewHolder).cardView;
    cardView.setTitleText(account.getName());
    cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
    if (account.getAvatarUrl() != null) {
      ((ViewHolder) viewHolder).updateCardViewImage(account.getAvatarUrl());
    }
  }

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

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

@@ -79,51 +79,8 @@
 xt;%0A
-import android.graphics.drawable.Drawable;%0A
 impo
@@ -747,47 +747,8 @@
 ew;%0A
-    private Drawable defaultCardImage;%0A
     
@@ -803,16 +803,16 @@
 Target;%0A
+
 %0A    pub
@@ -980,93 +980,8 @@
 w);%0A
-      defaultCardImage = context.getResources().getDrawable(R.drawable.ic_launcher);%0A
     
@@ -1167,30 +1167,83 @@
    .
-error(defaultCardImage
+placeholder(R.drawable.ic_launcher)%0A          .error(R.drawable.ic_launcher
 )%0A  

Remove drawable from AccountPresenter