// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
// 
//     public abstract long id();
// 
//     public abstract String created_at();
// 
//     public abstract User follower();
// 
//     public static TypeAdapter<Follower> typeAdapter(Gson gson) {
//         return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
//     @CallSuper
//     @Override
//     protected void bindView(View itemView) {
//         ButterKnife.bind(this, itemView);
//     }
// }


import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Follower;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
/*
 * Copyright 2017 Jiaheng Ge
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ge.protein.ui.epoxy.models;




@EpoxyModelClass(layout = R.layout.epoxy_follower)
public abstract class FollowerModel extends EpoxyModelWithHolder<FollowerModel.FollowerHolder> {

    @EpoxyAttribute
    View.OnClickListener itemOnClickListener;
    @EpoxyAttribute
    Follower follower;

    private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
    private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
            .diskCacheStrategy(DiskCacheStrategy.ALL);

    @Override
    protected FollowerHolder createNewHolder() {
        return new FollowerHolder();
    }

    @Override
    public void bind(FollowerHolder holder) {
        super.bind(holder);

        holder.name.setText(follower.follower().name());
        holder.info.setText(holder.itemView.getContext().getString(R.string.user_info, follower.follower().shots_count(),
                follower.follower().followers_count()));

        Glide.with(holder.itemView.getContext())
                .load(follower.follower().avatar_url())
                .transition(transitionOptions)
                .apply(requestOptions)
                .into(holder.avatar);

        holder.itemView.setOnClickListener(itemOnClickListener);
        holder.itemView.setTag(R.id.clicked_model, follower);
    }

// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
// 
//     public abstract long id();
// 
//     public abstract String created_at();
// 
//     public abstract User follower();
// 
//     public static TypeAdapter<Follower> typeAdapter(Gson gson) {
//         return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
//     @CallSuper
//     @Override
//     protected void bindView(View itemView) {
//         ButterKnife.bind(this, itemView);
//     }
// }


// Path: app/src/main/java/com/ge/protein/ui/epoxy/models/FollowerModel.java
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Follower;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;

/*
 * Copyright 2017 Jiaheng Ge
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ge.protein.ui.epoxy.models;




@EpoxyModelClass(layout = R.layout.epoxy_follower)
public abstract class FollowerModel extends EpoxyModelWithHolder<FollowerModel.FollowerHolder> {

    @EpoxyAttribute
    View.OnClickListener itemOnClickListener;
    @EpoxyAttribute
    Follower follower;

    private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
    private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
            .diskCacheStrategy(DiskCacheStrategy.ALL);

    @Override
    protected FollowerHolder createNewHolder() {
        return new FollowerHolder();
    }

    @Override
    public void bind(FollowerHolder holder) {
        super.bind(holder);

        holder.name.setText(follower.follower().name());
        holder.info.setText(holder.itemView.getContext().getString(R.string.user_info, follower.follower().shots_count(),
                follower.follower().followers_count()));

        Glide.with(holder.itemView.getContext())
                .load(follower.follower().avatar_url())
                .transition(transitionOptions)
                .apply(requestOptions)
                .into(holder.avatar);

        holder.itemView.setOnClickListener(itemOnClickListener);
        holder.itemView.setTag(R.id.clicked_model, follower);
    }

    static class FollowerHolder extends BaseEpoxyHolder {