package me.jessyan.art.base;

import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

public class AdapterViewPager extends FragmentStatePagerAdapter {
    private List<BaseFragment> list;
    private CharSequence[] mTitles;

    public AdapterViewPager(FragmentManager fragmentManager) {
        super(fragmentManager);
    }

    public void bindData(List<BaseFragment> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    public void bindData(List<BaseFragment> list, CharSequence[] titles) {
        this.list = list;
        this.mTitles = titles;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (mTitles != null) {
            return mTitles[position];
        }
        return super.getPageTitle(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Parcelable saveState() {
        return null;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        Fragment f = (Fragment) super.instantiateItem(container, position);
        View view = f.getView();
        if (view != null)
            container.addView(view);
        return f;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        View view = list.get(position).getView();
        if (view != null)
            container.removeView(view);
    }
}

@@ -370,28 +370,24 @@
 rivate List%3C
-Base
 Fragment%3E li
@@ -384,17 +384,18 @@
 agment%3E 
-l
+mL
 ist;%0D%0A  
@@ -490,16 +490,37 @@
 tManager
+, List%3CFragment%3E list
 ) %7B%0D%0A   
@@ -553,70 +553,8 @@
 );%0D%0A
-    %7D%0D%0A%0D%0A    public void bindData(List%3CBaseFragment%3E list) %7B%0D%0A
     
@@ -554,33 +554,34 @@
 ;%0D%0A        this.
-l
+mL
 ist = list;%0D%0A   
@@ -585,80 +585,81 @@
     
-    notifyDataSetChanged();%0D%0A    %7D%0D%0A%0D%0A    public void bindData(
+%7D%0D%0A%0D%0A%0D%0A    public AdapterViewPager(FragmentManager fragmentManager, 
 List%3C
-Base
 Frag
@@ -692,24 +692,57 @@
  titles) %7B%0D%0A
+        super(fragmentManager);%0D%0A
         this
@@ -742,17 +742,18 @@
    this.
-l
+mL
 ist = li
@@ -793,41 +793,8 @@
 s;%0D%0A
-        notifyDataSetChanged();%0D%0A
     
@@ -869,25 +869,26 @@
      return 
-l
+mL
 ist.get(posi
@@ -1169,17 +1169,18 @@
  return 
-l
+mL
 ist.size
@@ -1683,17 +1683,18 @@
  view = 
-l
+mL
 ist.get(

Improve AdapterViewPager