@Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.inject(this, view);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    /** 上拉加载更多,加载beforeDailyStories */
    mRecyclerView.setOnLoadMoreListener(
        new LoadMoreRecyclerView.OnLoadMoreListener() {
          @Override
          public void onLoadMore() {
            loadMore();
          }

          @Override
          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            LogUtils.d(TAG, dy + "");
            changeActionBarTitle(dy);
          }
        });
    mSwipeRefreshLayout.setColorSchemeResources(
        android.R.color.holo_blue_dark,
        android.R.color.holo_blue_light,
        android.R.color.holo_green_light,
        android.R.color.holo_green_light);
    /** 下拉刷新,加载latestDailyStories */
    mSwipeRefreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            refresh();
          }
        });
  }
  private void loadMore() {
    mRecyclerView.setLoadingMore(true);

    ZhiHuApplication.getRepository()
        .getBeforeDailyStories(
            mDate,
            new Repository.Callback<DailyStories>() {
              @Override
              public void success(DailyStories dailyStories, boolean outDate) {
                /**
                 * 注意,若果需要查询 11 月 18 日的消息,before 后的数字应为 20131119 所以在加载前一日时,只需要mDate =
                 * dailyStories.getDate()
                 */
                mDate = dailyStories.getDate();
                mRecyclerView.setLoadingMore(false);
                mAdapter.appendList(dailyStories);
              }

              @Override
              public void failure(Exception e) {
                mRecyclerView.setLoadingMore(false);
                Toast.makeText(getActivity(), "加载失败", Toast.LENGTH_SHORT).show();
                e.printStackTrace();
              }
            });
  }
 @Override
 public void onPause() {
   LogUtils.i(TAG, "onPause");
   super.onPause();
   if (mRecyclerView != null) {
     LogUtils.i(TAG, "recyclerView != null");
     View view = mRecyclerView.findViewById(R.id.viewPager);
     if (view != null) {
       LogUtils.i(TAG, "MyViewPager stopAutoScroll");
       ((MyViewPager) view).stopAutoScroll();
     }
   }
 }
 @Override
 public void onActivityCreated(@Nullable Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   mRecyclerView.setAdapter(mAdapter);
   mSwipeRefreshLayout.post(
       new Runnable() {
         @Override
         public void run() {
           if (!isDataLoaded) {
             refresh();
           }
         }
       });
 }