// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
//   /**
//    * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
//    * knows how to create a view.
//    */
//   ViewFactory<V> getViewFactory();
// 
//   /**
//    * @param view a root view created in the {@link ViewFactory}
//    * @return an enclosing {@link ViewHost} class.
//    * <p>
//    * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
//    * on the view.
//    */
//   VH createViewHost(V view);
// 
//   /**
//    * Displays the data from the model into the view.
//    *
//    * @param model
//    * @param viewHost
//    * @param environment
//    */
//   void bind(M model, VH viewHost, BE environment);
// 
//   /**
//    * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
//    *
//    * @param viewHost
//    * @param environment
//    */
//   void unbind(VH viewHost, BE environment);
// }
// 
// Path: library/src/main/java/drebin/core/ViewFactory.java
// public interface ViewFactory<V extends View> {
//   V create(Context context, ViewGroup parent);
// 
//   /**
//    * Convenience class for creating a view based on a layout resource
//    */
//   class INFLATE {
//     public static <V extends View> ViewFactory<V> fromLayout(@LayoutRes final int resId) {
//       return new ViewFactory<V>() {
//         @Override public V create(final Context context, final ViewGroup parent) {
//           return (V) LayoutInflater.from(context).inflate(resId, parent, false);
//         }
//       };
//     }
//   }
// }
// 
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
//   public final V rootView;
// 
//   public ViewHost(V view) {
//     this.rootView = view;
//   }
// }
// 
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
//   private String imageUrl;
//   private String name;
// 
//   public Place(String name, String imageUrl) {
//     this.name = name;
//     this.imageUrl = imageUrl;
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   public String getImageUrl() {
//     return imageUrl;
//   }
// }


import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import drebin.core.Binder;
import drebin.core.ViewFactory;
import drebin.core.ViewHost;
import io.nlopez.drebin.sample.R;
import io.nlopez.drebin.sample.model.Place;
package io.nlopez.drebin.sample.binder;





public class PlacesBinder implements Binder<LinearLayout, PlacesBinder.PlaceViewHost, Place, HasPlacesEnvironment> {

  private static final ViewFactory<LinearLayout> VIEW_FACTORY = ViewFactory.INFLATE.fromLayout(R.layout.view_place);

  @Inject
  public PlacesBinder() {

  }

  @Override public ViewFactory<LinearLayout> getViewFactory() {
    return VIEW_FACTORY;
  }

  @Override public PlaceViewHost createViewHost(LinearLayout view) {
    return new PlaceViewHost(view);
  }

  @Override public void bind(final Place model, PlaceViewHost viewHost, final HasPlacesEnvironment environment) {
    viewHost.text.setText(model.getName());
    viewHost.image.setImageURI(model.getImageUrl());
    viewHost.rootView.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(final View view) {
        environment.placeSelected(model);
      }
    });
  }

  @Override public void unbind(PlaceViewHost viewHost, HasPlacesEnvironment environment) {
    viewHost.rootView.setOnClickListener(null);
  }

// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
//   /**
//    * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
//    * knows how to create a view.
//    */
//   ViewFactory<V> getViewFactory();
// 
//   /**
//    * @param view a root view created in the {@link ViewFactory}
//    * @return an enclosing {@link ViewHost} class.
//    * <p>
//    * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
//    * on the view.
//    */
//   VH createViewHost(V view);
// 
//   /**
//    * Displays the data from the model into the view.
//    *
//    * @param model
//    * @param viewHost
//    * @param environment
//    */
//   void bind(M model, VH viewHost, BE environment);
// 
//   /**
//    * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
//    *
//    * @param viewHost
//    * @param environment
//    */
//   void unbind(VH viewHost, BE environment);
// }
// 
// Path: library/src/main/java/drebin/core/ViewFactory.java
// public interface ViewFactory<V extends View> {
//   V create(Context context, ViewGroup parent);
// 
//   /**
//    * Convenience class for creating a view based on a layout resource
//    */
//   class INFLATE {
//     public static <V extends View> ViewFactory<V> fromLayout(@LayoutRes final int resId) {
//       return new ViewFactory<V>() {
//         @Override public V create(final Context context, final ViewGroup parent) {
//           return (V) LayoutInflater.from(context).inflate(resId, parent, false);
//         }
//       };
//     }
//   }
// }
// 
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
//   public final V rootView;
// 
//   public ViewHost(V view) {
//     this.rootView = view;
//   }
// }
// 
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
//   private String imageUrl;
//   private String name;
// 
//   public Place(String name, String imageUrl) {
//     this.name = name;
//     this.imageUrl = imageUrl;
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   public String getImageUrl() {
//     return imageUrl;
//   }
// }


// Path: sample/src/main/java/io/nlopez/drebin/sample/binder/PlacesBinder.java
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import drebin.core.Binder;
import drebin.core.ViewFactory;
import drebin.core.ViewHost;
import io.nlopez.drebin.sample.R;
import io.nlopez.drebin.sample.model.Place;

package io.nlopez.drebin.sample.binder;





public class PlacesBinder implements Binder<LinearLayout, PlacesBinder.PlaceViewHost, Place, HasPlacesEnvironment> {

  private static final ViewFactory<LinearLayout> VIEW_FACTORY = ViewFactory.INFLATE.fromLayout(R.layout.view_place);

  @Inject
  public PlacesBinder() {

  }

  @Override public ViewFactory<LinearLayout> getViewFactory() {
    return VIEW_FACTORY;
  }

  @Override public PlaceViewHost createViewHost(LinearLayout view) {
    return new PlaceViewHost(view);
  }

  @Override public void bind(final Place model, PlaceViewHost viewHost, final HasPlacesEnvironment environment) {
    viewHost.text.setText(model.getName());
    viewHost.image.setImageURI(model.getImageUrl());
    viewHost.rootView.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(final View view) {
        environment.placeSelected(model);
      }
    });
  }

  @Override public void unbind(PlaceViewHost viewHost, HasPlacesEnvironment environment) {
    viewHost.rootView.setOnClickListener(null);
  }

  static class PlaceViewHost extends ViewHost<LinearLayout> {