package com.joker.fourfun.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.joker.fourfun.R;
import com.joker.fourfun.base.BaseMvpFragment;
import com.joker.fourfun.model.PicOne;
import com.joker.fourfun.presenter.PictureChildPresenter;
import com.joker.fourfun.presenter.contract.PictureChildContract;
import com.joker.fourfun.utils.GlideUtil;
import com.orhanobut.logger.Logger;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PictureChildFragment extends BaseMvpFragment<PictureChildContract.View,
        PictureChildPresenter> implements PictureChildContract.View {
    @BindView(R.id.iv_content)
    ImageView mIvContent;
    @BindView(R.id.tv_VOL)
    TextView mTvVOL;
    @BindView(R.id.tv_author)
    TextView mTvAuthor;
    @BindView(R.id.tv_des)
    TextView mTvDes;
    @BindView(R.id.tv_date)
    TextView mTvDate;
    // 网页更新慢一天，所以默认值为 1
    private int mDay = 1;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_picture_child, container, false);
        ButterKnife.bind(this, view);

        return view;
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        Logger.e("onLazyInitView");
        mPresenter.getContent(mDay * -1);
    }

    public void setFragmentPosition(int position) {
        // 网页更新慢一天 故要 +1
        mDay = position + 1;
    }

    @Override
    public void showContent(PicOne picOne) {
        GlideUtil.setImage(mActivity, picOne.getPicUrl(), mIvContent);
        mTvAuthor.setText(picOne.getAuthorWork());
        mTvVOL.setText(picOne.getVOL());
        mTvDes.setText(picOne.getPicDescription());
        mTvDate.setText(picOne.getPicDate());
    }

    @Override
    public void showError(String message) {

    }

    @Override
    protected void initInject() {
        getComponent().inject(this);
    }
}

@@ -371,18 +371,19 @@
 odel.Pic
-On
+tur
 e;%0Aimpor
@@ -1546,44 +1546,8 @@
 e);%0A
-        Logger.e(%22onLazyInitView%22);%0A
     
@@ -1584,16 +1584,16 @@
  * -1);%0A
+
     %7D%0A%0A 
@@ -1753,17 +1753,19 @@
 (Pic
-On
+tur
 e pic
-On
+tur
 e) %7B
@@ -1806,18 +1806,19 @@
 ity, pic
-On
+tur
 e.getPic
@@ -1862,26 +1862,27 @@
 .setText(pic
-On
+tur
 e.getAuthorW
@@ -1911,26 +1911,27 @@
 .setText(pic
-On
+tur
 e.getVOL());
@@ -1949,34 +1949,35 @@
 vDes.setText(pic
-On
+tur
 e.getPicDescript
@@ -2015,10 +2015,11 @@
 (pic
-On
+tur
 e.ge
@@ -2028,16 +2028,34 @@
 icDate()
+.replace(%22-%22, %22 %22)
 );%0A    %7D

refactor code