// Path: app/src/main/java/com/tyq/jiemian/adapter/PopularListAdapter.java
// public class PopularListAdapter extends RecyclerView.Adapter {
// 
//     private PopularNews popularNews;
//     private LayoutInflater inflater;
//     private Context context;
//     public PopularListAdapter(Context context) {
//         this.context = context;
//         inflater = LayoutInflater.from(context);
//     }
// 
//     public void addAll(PopularNews popularNews){
//         this.popularNews = popularNews;
//         notifyDataSetChanged();
//     }
// 
//     @Override
//     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         return new PopularViewHolder(context,inflater.inflate(R.layout.item_popular_news,parent,false));
//     }
// 
//     @Override
//     public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//         if (holder instanceof PopularViewHolder){
//             ((PopularViewHolder) holder).updateUi(popularNews.getArticle().get(position));
//         }
//     }
// 
//     @Override
//     public int getItemCount() {
//         return popularNews == null ? 0 : popularNews.getArticle().size() > 10 ? 10 : popularNews.getArticle().size();
//     }
// 
//     static class PopularViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//         private ItemPopularNewsBinding dataBinding;
//         private PopularNews.ArticleEntity article;
//         private Context context;
// 
//         public PopularViewHolder(Context context,View itemView) {
//             super(itemView);
//             this.context = context;
//             dataBinding = DataBindingUtil.bind(itemView);
//             itemView.setOnClickListener(this);
//         }
//         public void updateUi(PopularNews.ArticleEntity article){
//             this.article = article;
//             dataBinding.setArticle(article);
//             ImageLoader.getInstance().displayImage(article.getImg(),dataBinding.image);
//         }
// 
//         @Override
//         public void onClick(View v) {
//             Intent intent = new Intent(context, JmDetailActivity.class);
//             intent.putExtra(Constant.NEWS_URL,article.getUrl());
//             context.startActivity(intent);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/tyq/jiemian/presenter/HomePresenter.java
// public class HomePresenter extends BasePresenter {
//     private Context context;
// 
//     public HomePresenter(Context context) {
//         super(context);
//         this.context = context;
//     }
// 
//     public void requestPopularList(final HomeInterface homeInterface) {
//         Type type = new TypeToken<BaseVolleyResponse<PopularNews>>() {
//         }.getType();
//         String url = Constant.POPULAR_NEWS_URL;
//         Map<String, Object> mParams = new HashMap<>();
//         mParams.put("id", "recomm");
//         mParams.put("page", "1");
//         VolleyGetRequest<BaseVolleyResponse<PopularNews>> request = new VolleyGetRequest<BaseVolleyResponse<PopularNews>>(context, url, mParams, type, new Response.Listener<BaseVolleyResponse<PopularNews>>() {
//             @Override
//             public void onResponse(BaseVolleyResponse<PopularNews> response) {
//                 homeInterface.onRequestPopularNewsSuccess(response.getData());
//             }
//         }, new Response.ErrorListener() {
//             @Override
//             public void onErrorResponse(VolleyError error) {
//                 homeInterface.onRequestPopularNewsFailed(handlerException(error));
//             }
//         });
//         httpClient.addToRequestQueue(request);
// 
//     }
// 
//     public void requestSearchResult(String keyWord, final SearchInterface searchInterface){
//         Type type = new TypeToken<BaseSearchResponse<SearchItem>>(){}.getType();
//         String url = Constant.SEARCH_URL;
//         Map<String,Object> mParams = new HashMap<>();
//         mParams.put("keyword",keyWord);
//         mParams.put("page",1);
//         mParams.put("count",20);
//         VolleyHttpRequest<BaseSearchResponse<SearchItem>> request = new VolleyGetRequest<BaseSearchResponse<SearchItem>>(context, url, mParams, type, new Response.Listener<BaseSearchResponse<SearchItem>>() {
//             @Override
//             public void onResponse(BaseSearchResponse<SearchItem> response) {
//                 searchInterface.onSearchResultSuccess(response.getRetData());
//             }
//         }, new Response.ErrorListener() {
//             @Override
//             public void onErrorResponse(VolleyError error) {
//                 searchInterface.onSearchResultFailed(handlerException(error));
//             }
//         });
//         httpClient.addToRequestQueue(request);
//     }
// }
// 
// Path: app/src/main/java/com/tyq/jiemian/ui/callback/HomeInterface.java
// public interface HomeInterface  {
//     void onRequestPopularNewsSuccess(PopularNews news);
// 
//     void onRequestPopularNewsFailed(String errMsg);
// }


import android.content.Context;
import android.databinding.DataBindingUtil;
import android.databinding.tool.util.L;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import com.tyq.jiemian.adapter.PopularListAdapter;
import com.tyq.jiemian.bean.PopularNews;
import com.tyq.jiemian.databinding.ItemPopularListBinding;
import com.tyq.jiemian.presenter.HomePresenter;
import com.tyq.jiemian.ui.callback.HomeInterface;
package com.tyq.jiemian.adapter.VH;



/**
 * Created by tyq on 2016/6/4.
 */
public class PopularViewHolder extends RecyclerView.ViewHolder implements HomeInterface {
    private ItemPopularListBinding dataBinding;
// Path: app/src/main/java/com/tyq/jiemian/adapter/PopularListAdapter.java
// public class PopularListAdapter extends RecyclerView.Adapter {
// 
//     private PopularNews popularNews;
//     private LayoutInflater inflater;
//     private Context context;
//     public PopularListAdapter(Context context) {
//         this.context = context;
//         inflater = LayoutInflater.from(context);
//     }
// 
//     public void addAll(PopularNews popularNews){
//         this.popularNews = popularNews;
//         notifyDataSetChanged();
//     }
// 
//     @Override
//     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         return new PopularViewHolder(context,inflater.inflate(R.layout.item_popular_news,parent,false));
//     }
// 
//     @Override
//     public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//         if (holder instanceof PopularViewHolder){
//             ((PopularViewHolder) holder).updateUi(popularNews.getArticle().get(position));
//         }
//     }
// 
//     @Override
//     public int getItemCount() {
//         return popularNews == null ? 0 : popularNews.getArticle().size() > 10 ? 10 : popularNews.getArticle().size();
//     }
// 
//     static class PopularViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
//         private ItemPopularNewsBinding dataBinding;
//         private PopularNews.ArticleEntity article;
//         private Context context;
// 
//         public PopularViewHolder(Context context,View itemView) {
//             super(itemView);
//             this.context = context;
//             dataBinding = DataBindingUtil.bind(itemView);
//             itemView.setOnClickListener(this);
//         }
//         public void updateUi(PopularNews.ArticleEntity article){
//             this.article = article;
//             dataBinding.setArticle(article);
//             ImageLoader.getInstance().displayImage(article.getImg(),dataBinding.image);
//         }
// 
//         @Override
//         public void onClick(View v) {
//             Intent intent = new Intent(context, JmDetailActivity.class);
//             intent.putExtra(Constant.NEWS_URL,article.getUrl());
//             context.startActivity(intent);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/tyq/jiemian/presenter/HomePresenter.java
// public class HomePresenter extends BasePresenter {
//     private Context context;
// 
//     public HomePresenter(Context context) {
//         super(context);
//         this.context = context;
//     }
// 
//     public void requestPopularList(final HomeInterface homeInterface) {
//         Type type = new TypeToken<BaseVolleyResponse<PopularNews>>() {
//         }.getType();
//         String url = Constant.POPULAR_NEWS_URL;
//         Map<String, Object> mParams = new HashMap<>();
//         mParams.put("id", "recomm");
//         mParams.put("page", "1");
//         VolleyGetRequest<BaseVolleyResponse<PopularNews>> request = new VolleyGetRequest<BaseVolleyResponse<PopularNews>>(context, url, mParams, type, new Response.Listener<BaseVolleyResponse<PopularNews>>() {
//             @Override
//             public void onResponse(BaseVolleyResponse<PopularNews> response) {
//                 homeInterface.onRequestPopularNewsSuccess(response.getData());
//             }
//         }, new Response.ErrorListener() {
//             @Override
//             public void onErrorResponse(VolleyError error) {
//                 homeInterface.onRequestPopularNewsFailed(handlerException(error));
//             }
//         });
//         httpClient.addToRequestQueue(request);
// 
//     }
// 
//     public void requestSearchResult(String keyWord, final SearchInterface searchInterface){
//         Type type = new TypeToken<BaseSearchResponse<SearchItem>>(){}.getType();
//         String url = Constant.SEARCH_URL;
//         Map<String,Object> mParams = new HashMap<>();
//         mParams.put("keyword",keyWord);
//         mParams.put("page",1);
//         mParams.put("count",20);
//         VolleyHttpRequest<BaseSearchResponse<SearchItem>> request = new VolleyGetRequest<BaseSearchResponse<SearchItem>>(context, url, mParams, type, new Response.Listener<BaseSearchResponse<SearchItem>>() {
//             @Override
//             public void onResponse(BaseSearchResponse<SearchItem> response) {
//                 searchInterface.onSearchResultSuccess(response.getRetData());
//             }
//         }, new Response.ErrorListener() {
//             @Override
//             public void onErrorResponse(VolleyError error) {
//                 searchInterface.onSearchResultFailed(handlerException(error));
//             }
//         });
//         httpClient.addToRequestQueue(request);
//     }
// }
// 
// Path: app/src/main/java/com/tyq/jiemian/ui/callback/HomeInterface.java
// public interface HomeInterface  {
//     void onRequestPopularNewsSuccess(PopularNews news);
// 
//     void onRequestPopularNewsFailed(String errMsg);
// }


// Path: app/src/main/java/com/tyq/jiemian/adapter/VH/PopularViewHolder.java
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.databinding.tool.util.L;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import com.tyq.jiemian.adapter.PopularListAdapter;
import com.tyq.jiemian.bean.PopularNews;
import com.tyq.jiemian.databinding.ItemPopularListBinding;
import com.tyq.jiemian.presenter.HomePresenter;
import com.tyq.jiemian.ui.callback.HomeInterface;

package com.tyq.jiemian.adapter.VH;



/**
 * Created by tyq on 2016/6/4.
 */
public class PopularViewHolder extends RecyclerView.ViewHolder implements HomeInterface {
    private ItemPopularListBinding dataBinding;
    private PopularListAdapter adapter;