package com.joker.fourfun.ui.fragment;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.joker.fourfun.Constants;
import com.joker.fourfun.R;
import com.joker.fourfun.adapter.PictureOneAdapter;
import com.joker.fourfun.base.BaseMvpFragment;
import com.joker.fourfun.presenter.PicturePresenter;
import com.joker.fourfun.presenter.contract.PictureContract;
import com.joker.fourfun.utils.SystemUtil;
import com.joker.fourfun.widget.ZoomOutPageTransformer;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PictureFragment extends BaseMvpFragment<PictureContract.View, PicturePresenter> implements
        PictureContract.View {
    @BindView(R.id.vp_content)
    ViewPager mVpContent;
    private Bundle mPictureBundle;
    private List<PictureChildFragment> mFragments;

    public static PictureFragment newInstance(Bundle bundle) {
        PictureFragment pictureFragment = new PictureFragment();
        pictureFragment.setArguments(bundle);

        return pictureFragment;
    }

    @Override
    protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        analyseArguments();
        View view = inflater.inflate(R.layout.fragment_picture, container, false);
        ButterKnife.bind(this, view);
        mVpContent.setOffscreenPageLimit(1);
        mFragments = new ArrayList<PictureChildFragment>();
        mFragments.add(PictureChildFragment.newInstance(mPictureBundle));
        mFragments.add(new PictureChildFragment());
        mFragments.add(new PictureChildFragment());
        mFragments.add(new PictureChildFragment());
        mFragments.add(new PictureChildFragment());
        mFragments.add(new PictureChildFragment());
        mFragments.add(new PictureChildFragment());
        mFragments.add(new PictureChildFragment());
        mVpContent.setPageTransformer(true, new ZoomOutPageTransformer());
        PictureOneAdapter mAdapter = new PictureOneAdapter(getChildFragmentManager(), mFragments);
        mVpContent.setAdapter(mAdapter);

        return view;
    }

    private void analyseArguments() {
        Bundle bundle = getArguments();
        mPictureBundle = bundle.getBundle(Constants.PICTURE_BUNDLE);
    }

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

    @Override
    public void showError(String message) {
        SystemUtil.showToast(mActivity, message);
    }
}

@@ -1451,53 +1451,8 @@
 w);%0A
-        mVpContent.setOffscreenPageLimit(1);%0A
     
@@ -1503,24 +1503,24 @@
 ragment%3E();%0A
+
         mFra
@@ -1906,48 +1906,41 @@
    m
-Fragments.add(new PictureChildFragment()
+VpContent.setOffscreenPageLimit(1
 );%0A 
@@ -2009,24 +2009,520 @@
 sformer());%0A
+        mVpContent.addOnPageChangeListener(new ViewPager.OnPageChangeListener() %7B%0A            @Override%0A            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) %7B%0A            %7D%0A%0A            @Override%0A            public void onPageSelected(int position) %7B%0A                mFragments.get(position).setFragmentPosition(position);%0A            %7D%0A%0A            @Override%0A            public void onPageScrollStateChanged(int state) %7B%0A            %7D%0A        %7D);%0A
         Pict

fix bug