// Path: app/src/main/java/com/wulinpeng/daiylreader/bean/RankingInfoResponse.java
// public class RankingInfoResponse {
// 
//     private List<Rank> male;
// 
//     private List<Rank> female;
// 
//     public List<Rank> getMale() {
//         return male;
//     }
// 
//     public void setMale(List<Rank> male) {
//         this.male = male;
//     }
// 
//     public List<Rank> getFemale() {
//         return female;
//     }
// 
//     public void setFemale(List<Rank> female) {
//         this.female = female;
//     }
// 
//     @Override
//     public String toString() {
//         return "RankingInfoResponse{" +
//                 "male=" + male +
//                 ", female=" + female +
//                 '}';
//     }
// 
//     public class Rank {
//         private String _id;
//         private String title;
//         private String cover;
// 
//         public String get_id() {
//             return _id;
//         }
// 
//         public void set_id(String _id) {
//             this._id = _id;
//         }
// 
//         public String getTitle() {
//             return title;
//         }
// 
//         public void setTitle(String title) {
//             this.title = title;
//         }
// 
//         public String getCover() {
//             return cover;
//         }
// 
//         public void setCover(String cover) {
//             this.cover = cover;
//         }
// 
//         @Override
//         public String toString() {
//             return "Ranks{" +
//                     "_id='" + _id + '\'' +
//                     ", title='" + title + '\'' +
//                     ", cover='" + cover + '\'' +
//                     '}';
//         }
//     }
// }
// 
// Path: app/src/main/java/com/wulinpeng/daiylreader/rank/adapter/RankingAdapter.java
// public class RankingAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
// 
//     private Context context;
// 
//     private List<RankingInfoResponse.Rank> data;
// 
//     private LayoutInflater inflater;
// 
//     public RankingAdapter(Context context, List<RankingInfoResponse.Rank> data) {
//         this.context = context;
//         this.data = data;
//         inflater = LayoutInflater.from(context);
//     }
// 
//     @Override
//     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         View view = inflater.inflate(R.layout.item_rank, parent, false);
//         return new RankingViewHolder(view);
//     }
// 
//     @Override
//     public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//         RankingViewHolder viewHolder = (RankingViewHolder) holder;
//         RankingInfoResponse.Rank rank = data.get(position);
//         ImageLoadEntity imageLoadEntity = new ImageLoadEntity(UrlUtil.getCoverUrl(rank.getCover()), R.drawable.book_cover_default, viewHolder.iocn);
//         ImageHelper.INSTANCE.load(context, imageLoadEntity);
//         viewHolder.textView.setText(rank.getTitle());
//     }
// 
//     @Override
//     public int getItemCount() {
//         return data.size();
//     }
// 
//     class RankingViewHolder extends RecyclerView.ViewHolder {
// 
//         @BindView(R.id.icon)
//         public ImageView iocn;
//         @BindView(R.id.text)
//         public TextView textView;
// 
//         public RankingViewHolder(View itemView) {
//             super(itemView);
//             ButterKnife.bind(this, itemView);
//             itemView.setOnClickListener(v -> {
//                 RankingInfoResponse.Rank rank = data.get(getLayoutPosition());
//                 RankDetailActivity.startActivity(context, rank.get_id(), rank.getTitle());
//             });
//         }
//     }
// }
// 
// Path: app/src/main/java/com/wulinpeng/daiylreader/util/RxUtil.java
// public class RxUtil {
// 
//     public static <T> Observable.Transformer<T, T> rxScheduler() {
//         return observable -> observable
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread());
//     }
// }


import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;
import com.wulinpeng.daiylreader.R;
import com.wulinpeng.daiylreader.net.ReaderApiManager;
import com.wulinpeng.daiylreader.bean.RankingInfoResponse;
import com.wulinpeng.daiylreader.rank.adapter.RankingAdapter;
import com.wulinpeng.daiylreader.util.RxUtil;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import wulinpeng.com.framework.base.ui.BaseFragment;
package com.wulinpeng.daiylreader.rank.ui;





/**
 * @author wulinpeng
 * @datetime: 17/2/18 下午11:38
 * @description:
 */
public class RankFragment extends BaseFragment {

    @BindView(R.id.male)
    public RecyclerView maleRv;

    @BindView(R.id.female)
    public RecyclerView femaleRv;

    private RankingAdapter maleAdapter, femaleAdapter;

    private List<RankingInfoResponse.Rank> maleRanks = new ArrayList<>();

    private List<RankingInfoResponse.Rank> femaleRanks = new ArrayList<>();

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_rank;
    }

    @Override
    protected void initViews() {
        maleAdapter = new RankingAdapter(getContext(), maleRanks);
        femaleAdapter = new RankingAdapter(getContext(), femaleRanks);

        maleRv.setLayoutManager(new LinearLayoutManager(getContext()));
        femaleRv.setLayoutManager(new LinearLayoutManager(getContext()));

        maleRv.setAdapter(maleAdapter);
        femaleRv.setAdapter(femaleAdapter);
    }

    @Override
    protected void initData() {
        ReaderApiManager.INSTANCE.getRankingInfo()
                .compose(RxUtil.rxScheduler())
                .subscribe(rankingInfoResponse -> {
                    maleRanks.clear();
                    maleRanks.addAll(rankingInfoResponse.getMale().subList(0, 5));
// Path: app/src/main/java/com/wulinpeng/daiylreader/bean/RankingInfoResponse.java
// public class RankingInfoResponse {
// 
//     private List<Rank> male;
// 
//     private List<Rank> female;
// 
//     public List<Rank> getMale() {
//         return male;
//     }
// 
//     public void setMale(List<Rank> male) {
//         this.male = male;
//     }
// 
//     public List<Rank> getFemale() {
//         return female;
//     }
// 
//     public void setFemale(List<Rank> female) {
//         this.female = female;
//     }
// 
//     @Override
//     public String toString() {
//         return "RankingInfoResponse{" +
//                 "male=" + male +
//                 ", female=" + female +
//                 '}';
//     }
// 
//     public class Rank {
//         private String _id;
//         private String title;
//         private String cover;
// 
//         public String get_id() {
//             return _id;
//         }
// 
//         public void set_id(String _id) {
//             this._id = _id;
//         }
// 
//         public String getTitle() {
//             return title;
//         }
// 
//         public void setTitle(String title) {
//             this.title = title;
//         }
// 
//         public String getCover() {
//             return cover;
//         }
// 
//         public void setCover(String cover) {
//             this.cover = cover;
//         }
// 
//         @Override
//         public String toString() {
//             return "Ranks{" +
//                     "_id='" + _id + '\'' +
//                     ", title='" + title + '\'' +
//                     ", cover='" + cover + '\'' +
//                     '}';
//         }
//     }
// }
// 
// Path: app/src/main/java/com/wulinpeng/daiylreader/rank/adapter/RankingAdapter.java
// public class RankingAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
// 
//     private Context context;
// 
//     private List<RankingInfoResponse.Rank> data;
// 
//     private LayoutInflater inflater;
// 
//     public RankingAdapter(Context context, List<RankingInfoResponse.Rank> data) {
//         this.context = context;
//         this.data = data;
//         inflater = LayoutInflater.from(context);
//     }
// 
//     @Override
//     public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         View view = inflater.inflate(R.layout.item_rank, parent, false);
//         return new RankingViewHolder(view);
//     }
// 
//     @Override
//     public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
//         RankingViewHolder viewHolder = (RankingViewHolder) holder;
//         RankingInfoResponse.Rank rank = data.get(position);
//         ImageLoadEntity imageLoadEntity = new ImageLoadEntity(UrlUtil.getCoverUrl(rank.getCover()), R.drawable.book_cover_default, viewHolder.iocn);
//         ImageHelper.INSTANCE.load(context, imageLoadEntity);
//         viewHolder.textView.setText(rank.getTitle());
//     }
// 
//     @Override
//     public int getItemCount() {
//         return data.size();
//     }
// 
//     class RankingViewHolder extends RecyclerView.ViewHolder {
// 
//         @BindView(R.id.icon)
//         public ImageView iocn;
//         @BindView(R.id.text)
//         public TextView textView;
// 
//         public RankingViewHolder(View itemView) {
//             super(itemView);
//             ButterKnife.bind(this, itemView);
//             itemView.setOnClickListener(v -> {
//                 RankingInfoResponse.Rank rank = data.get(getLayoutPosition());
//                 RankDetailActivity.startActivity(context, rank.get_id(), rank.getTitle());
//             });
//         }
//     }
// }
// 
// Path: app/src/main/java/com/wulinpeng/daiylreader/util/RxUtil.java
// public class RxUtil {
// 
//     public static <T> Observable.Transformer<T, T> rxScheduler() {
//         return observable -> observable
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread());
//     }
// }


// Path: app/src/main/java/com/wulinpeng/daiylreader/rank/ui/RankFragment.java
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;
import com.wulinpeng.daiylreader.R;
import com.wulinpeng.daiylreader.net.ReaderApiManager;
import com.wulinpeng.daiylreader.bean.RankingInfoResponse;
import com.wulinpeng.daiylreader.rank.adapter.RankingAdapter;
import com.wulinpeng.daiylreader.util.RxUtil;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import wulinpeng.com.framework.base.ui.BaseFragment;

package com.wulinpeng.daiylreader.rank.ui;





/**
 * @author wulinpeng
 * @datetime: 17/2/18 下午11:38
 * @description:
 */
public class RankFragment extends BaseFragment {

    @BindView(R.id.male)
    public RecyclerView maleRv;

    @BindView(R.id.female)
    public RecyclerView femaleRv;

    private RankingAdapter maleAdapter, femaleAdapter;

    private List<RankingInfoResponse.Rank> maleRanks = new ArrayList<>();

    private List<RankingInfoResponse.Rank> femaleRanks = new ArrayList<>();

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_rank;
    }

    @Override
    protected void initViews() {
        maleAdapter = new RankingAdapter(getContext(), maleRanks);
        femaleAdapter = new RankingAdapter(getContext(), femaleRanks);

        maleRv.setLayoutManager(new LinearLayoutManager(getContext()));
        femaleRv.setLayoutManager(new LinearLayoutManager(getContext()));

        maleRv.setAdapter(maleAdapter);
        femaleRv.setAdapter(femaleAdapter);
    }

    @Override
    protected void initData() {
        ReaderApiManager.INSTANCE.getRankingInfo()
                .compose(RxUtil.rxScheduler())
                .subscribe(rankingInfoResponse -> {
                    maleRanks.clear();
                    maleRanks.addAll(rankingInfoResponse.getMale().subList(0, 5));
                    femaleRanks.clear();