// Path: app/src/main/java/com/wulinpeng/daiylreader/category/categorydetail/view/CatDetailFragment.java
// public class CatDetailFragment extends BaseFragment implements ICatDetailView, SwipeRefreshLayout.OnRefreshListener, LoadMoreAdapter.OnLoadMoreListener {
// 
//     @BindView(R.id.error_view)
//     public ErrorView errorView;
// 
//     @BindView(R.id.refresh_layout)
//     public SwipeRefreshLayout refreshLayout;
// 
//     @BindView(R.id.recycler_view)
//     public RecyclerView recyclerView;
// 
//     private BookShortAdapter adapter;
// 
//     private LoadMoreAdapter loadMoreAdapter;
// 
//     private List<BookShort> data;
// 
//     private ICatDetailPresenter presenter;
// 
//     /**
//      * fragment不能直接构造传值，只能这样
//      * @param major
//      * @param type
//      * @return
//      */
//     public static CatDetailFragment newInstance(String major, String gender, String type) {
//         CatDetailFragment catDetailFragment = new CatDetailFragment();
//         Bundle bundle = new Bundle();
//         bundle.putString("major", major);
//         bundle.putString("gender", gender);
//         bundle.putString("type", type);
//         catDetailFragment.setArguments(bundle);
//         return catDetailFragment;
//     }
// 
//     @Override
//     public void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         presenter = new CatDetailPresenterImpl(this, getArguments().getString("major"),
//                 getArguments().getString("gender"),
//                 getArguments().getString("type"));
//     }
// 
//     @Override
//     protected int getLayoutId() {
//         return R.layout.fragment_catdetail;
//     }
// 
//     @Override
//     protected void initViews() {
//         data = new ArrayList<>();
//         adapter = new BookShortAdapter(getContext(), data);
//         loadMoreAdapter = LoadMoreAdapter.Companion.wrap(getContext(), adapter, this);
//         recyclerView.setAdapter(loadMoreAdapter);
//         recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// 
//         errorView.bindContentView(recyclerView);
// 
//         refreshLayout.setOnRefreshListener(this);
//         refreshLayout.post(new Runnable() {
//             @Override
//             public void run() {
//                 presenter.firstLoad();
//             }
//         });
//     }
// 
//     @Override
//     protected void initData() {
//     }
// 
//     @Override
//     public void showLoading(boolean loading) {
//         refreshLayout.setRefreshing(loading);
//     }
// 
//     @Override
//     public void onFirstLoadError(String msg) {
//         errorView.bindDefaultErrorView(msg);
//         errorView.showError(true);
//         Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
//     }
// 
//     @Override
//     public void onFirstLoadFinish(List<BookShort> data) {
//         this.data.clear();
//         this.data.addAll(data);
//         if (data.isEmpty()) {
//             errorView.bindDefaultErrorView("empty");
//             errorView.showError(true);
//         } else {
//             errorView.showError(false);
//             adapter.notifyDataSetChanged();
//         }
//     }
// 
//     @Override
//     public void onLoadMoreError(String msg) {
//         loadMoreAdapter.updateLoadMoreState(LoadMoreAdapter.LoadingState.LOADING_STATE_ERROR);
//         Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
//     }
// 
//     @Override
//     public void onLoadMoreFinish(List<BookShort> data) {
//         this.data.addAll(data);
//         loadMoreAdapter.updateLoadMoreState(LoadMoreAdapter.LoadingState.LOADING_STATE_NORMAL);
//     }
// 
//     @Override
//     public void onLoadMoreEnd() {
//         loadMoreAdapter.updateLoadMoreState(LoadMoreAdapter.LoadingState.LOADING_STATE_NO_MORE);
//         Toast.makeText(getContext(), "没有更多了", Toast.LENGTH_SHORT).show();
//     }
// 
//     @Override
//     public void onRefresh() {
//         presenter.firstLoad();
//     }
// 
//     @Override
//     public void onLoadMore() {
//         presenter.loadMore();
//     }
// }


import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.wulinpeng.daiylreader.R;
import com.wulinpeng.daiylreader.category.categorydetail.view.CatDetailFragment;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import wulinpeng.com.framework.base.ui.BaseActivity;
package com.wulinpeng.daiylreader.category.categorydetail.ui;





/**
 * @author wulinpeng
 * @datetime: 17/2/19 下午2:07
 * @description:
 */
public class CategoryDetailActivity extends BaseActivity {

    @BindView(R.id.common_toolbar)
    public Toolbar toolbar;

    @BindView(R.id.tab_layout)
    public TabLayout tabLayout;

    @BindView(R.id.view_pager)
    public ViewPager viewPager;

    private FragmentPagerAdapter pagerAdapter;

    private List<Fragment> tabFragments = new ArrayList<>();

    private String[] tabTitles = {"最热", "最新", "好评", "完结"};

    private String cat;

    public static void startActivity(Context context, String cat, String gender) {

        Intent intent = new Intent(context, CategoryDetailActivity.class);
        intent.putExtra("cat", cat);
        intent.putExtra("gender", gender);
        context.startActivity(intent);
    }

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

    @Override
    protected void initViews() {

        String cat = getIntent().getStringExtra("cat");

        toolbar.setNavigationIcon(R.drawable.back_arrow_white);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Path: app/src/main/java/com/wulinpeng/daiylreader/category/categorydetail/view/CatDetailFragment.java
// public class CatDetailFragment extends BaseFragment implements ICatDetailView, SwipeRefreshLayout.OnRefreshListener, LoadMoreAdapter.OnLoadMoreListener {
// 
//     @BindView(R.id.error_view)
//     public ErrorView errorView;
// 
//     @BindView(R.id.refresh_layout)
//     public SwipeRefreshLayout refreshLayout;
// 
//     @BindView(R.id.recycler_view)
//     public RecyclerView recyclerView;
// 
//     private BookShortAdapter adapter;
// 
//     private LoadMoreAdapter loadMoreAdapter;
// 
//     private List<BookShort> data;
// 
//     private ICatDetailPresenter presenter;
// 
//     /**
//      * fragment不能直接构造传值，只能这样
//      * @param major
//      * @param type
//      * @return
//      */
//     public static CatDetailFragment newInstance(String major, String gender, String type) {
//         CatDetailFragment catDetailFragment = new CatDetailFragment();
//         Bundle bundle = new Bundle();
//         bundle.putString("major", major);
//         bundle.putString("gender", gender);
//         bundle.putString("type", type);
//         catDetailFragment.setArguments(bundle);
//         return catDetailFragment;
//     }
// 
//     @Override
//     public void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         presenter = new CatDetailPresenterImpl(this, getArguments().getString("major"),
//                 getArguments().getString("gender"),
//                 getArguments().getString("type"));
//     }
// 
//     @Override
//     protected int getLayoutId() {
//         return R.layout.fragment_catdetail;
//     }
// 
//     @Override
//     protected void initViews() {
//         data = new ArrayList<>();
//         adapter = new BookShortAdapter(getContext(), data);
//         loadMoreAdapter = LoadMoreAdapter.Companion.wrap(getContext(), adapter, this);
//         recyclerView.setAdapter(loadMoreAdapter);
//         recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// 
//         errorView.bindContentView(recyclerView);
// 
//         refreshLayout.setOnRefreshListener(this);
//         refreshLayout.post(new Runnable() {
//             @Override
//             public void run() {
//                 presenter.firstLoad();
//             }
//         });
//     }
// 
//     @Override
//     protected void initData() {
//     }
// 
//     @Override
//     public void showLoading(boolean loading) {
//         refreshLayout.setRefreshing(loading);
//     }
// 
//     @Override
//     public void onFirstLoadError(String msg) {
//         errorView.bindDefaultErrorView(msg);
//         errorView.showError(true);
//         Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
//     }
// 
//     @Override
//     public void onFirstLoadFinish(List<BookShort> data) {
//         this.data.clear();
//         this.data.addAll(data);
//         if (data.isEmpty()) {
//             errorView.bindDefaultErrorView("empty");
//             errorView.showError(true);
//         } else {
//             errorView.showError(false);
//             adapter.notifyDataSetChanged();
//         }
//     }
// 
//     @Override
//     public void onLoadMoreError(String msg) {
//         loadMoreAdapter.updateLoadMoreState(LoadMoreAdapter.LoadingState.LOADING_STATE_ERROR);
//         Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
//     }
// 
//     @Override
//     public void onLoadMoreFinish(List<BookShort> data) {
//         this.data.addAll(data);
//         loadMoreAdapter.updateLoadMoreState(LoadMoreAdapter.LoadingState.LOADING_STATE_NORMAL);
//     }
// 
//     @Override
//     public void onLoadMoreEnd() {
//         loadMoreAdapter.updateLoadMoreState(LoadMoreAdapter.LoadingState.LOADING_STATE_NO_MORE);
//         Toast.makeText(getContext(), "没有更多了", Toast.LENGTH_SHORT).show();
//     }
// 
//     @Override
//     public void onRefresh() {
//         presenter.firstLoad();
//     }
// 
//     @Override
//     public void onLoadMore() {
//         presenter.loadMore();
//     }
// }


// Path: app/src/main/java/com/wulinpeng/daiylreader/category/categorydetail/ui/CategoryDetailActivity.java
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.wulinpeng.daiylreader.R;
import com.wulinpeng.daiylreader.category.categorydetail.view.CatDetailFragment;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import wulinpeng.com.framework.base.ui.BaseActivity;

package com.wulinpeng.daiylreader.category.categorydetail.ui;





/**
 * @author wulinpeng
 * @datetime: 17/2/19 下午2:07
 * @description:
 */
public class CategoryDetailActivity extends BaseActivity {

    @BindView(R.id.common_toolbar)
    public Toolbar toolbar;

    @BindView(R.id.tab_layout)
    public TabLayout tabLayout;

    @BindView(R.id.view_pager)
    public ViewPager viewPager;

    private FragmentPagerAdapter pagerAdapter;

    private List<Fragment> tabFragments = new ArrayList<>();

    private String[] tabTitles = {"最热", "最新", "好评", "完结"};

    private String cat;

    public static void startActivity(Context context, String cat, String gender) {

        Intent intent = new Intent(context, CategoryDetailActivity.class);
        intent.putExtra("cat", cat);
        intent.putExtra("gender", gender);
        context.startActivity(intent);
    }

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

    @Override
    protected void initViews() {

        String cat = getIntent().getStringExtra("cat");

        toolbar.setNavigationIcon(R.drawable.back_arrow_white);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);