// Path: app/src/main/java/com/github/captain_miao/databinding/tutorial/base/BasePagerAdapter.java
// public abstract class BasePagerAdapter<T> extends PagerAdapter {
//     protected ArrayList<T> mData = new ArrayList();
//     protected LayoutInflater mInflater;
//     protected Context mContext;
// 
//     public BasePagerAdapter(Context c) {
//         mContext = c;
//         mInflater = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//     }
// 
//     @Override
//     public abstract Object instantiateItem(ViewGroup container, int position);
// 
//     @Override
//     public abstract void destroyItem(ViewGroup container, int position, Object object);
// 
//     @Override
//     public int getCount() {
//         return mData != null ? mData.size() : 0;
//     }
// 
//     public void addItem(final T item) {
//         mData.add(item);
//         notifyDataSetChanged();
//     }
//     public void addAll(final List<T> items) {
//         if (items != null) {
//             mData.addAll(items);
//         }
//         notifyDataSetChanged();
//     }
//     public void setData(final List<T> items) {
//         mData.clear();
//         if (items != null) {
//             mData.addAll(items);
//         }
//         notifyDataSetChanged();
//     }
// 
//     public void addItem(int idx, final T item) {
//         mData.add(idx, item);
//         notifyDataSetChanged();
//     }
// 
//     public void clearItems() {
//         mData.clear();
//         notifyDataSetChanged();
//     }
// 
//     public T getItem(int position) {
//         return mData.get(position);
//     }
// 
//     public ArrayList<T> getData() {
//         return mData;
//     }
// }


import android.content.Context;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import com.github.captain_miao.databinding.tutorial.R;
import com.github.captain_miao.databinding.tutorial.base.BasePagerAdapter;
import com.github.captain_miao.databinding.tutorial.databinding.ViewPageItemViewBinding;
import java.util.ArrayList;
import java.util.List;


    private class GuideAdapter extends BasePagerAdapter<GuideViewModel> {

        public GuideAdapter(Context c) {
            super(c);
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            GuideViewModel model = getItem(position);

            ViewPageItemViewBinding frgGuideBinding
                    = ViewPageItemViewBinding.inflate(mInflater, container, false);
            frgGuideBinding.setViewModel(model);
            container.addView(frgGuideBinding.getRoot());
            return frgGuideBinding.getRoot();

        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            if(object instanceof View) {
                container.removeView((View) object);
            }
        }


        @Override
        public boolean isViewFromObject(View view, Object object) {
// Path: app/src/main/java/com/github/captain_miao/databinding/tutorial/base/BasePagerAdapter.java
// public abstract class BasePagerAdapter<T> extends PagerAdapter {
//     protected ArrayList<T> mData = new ArrayList();
//     protected LayoutInflater mInflater;
//     protected Context mContext;
// 
//     public BasePagerAdapter(Context c) {
//         mContext = c;
//         mInflater = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//     }
// 
//     @Override
//     public abstract Object instantiateItem(ViewGroup container, int position);
// 
//     @Override
//     public abstract void destroyItem(ViewGroup container, int position, Object object);
// 
//     @Override
//     public int getCount() {
//         return mData != null ? mData.size() : 0;
//     }
// 
//     public void addItem(final T item) {
//         mData.add(item);
//         notifyDataSetChanged();
//     }
//     public void addAll(final List<T> items) {
//         if (items != null) {
//             mData.addAll(items);
//         }
//         notifyDataSetChanged();
//     }
//     public void setData(final List<T> items) {
//         mData.clear();
//         if (items != null) {
//             mData.addAll(items);
//         }
//         notifyDataSetChanged();
//     }
// 
//     public void addItem(int idx, final T item) {
//         mData.add(idx, item);
//         notifyDataSetChanged();
//     }
// 
//     public void clearItems() {
//         mData.clear();
//         notifyDataSetChanged();
//     }
// 
//     public T getItem(int position) {
//         return mData.get(position);
//     }
// 
//     public ArrayList<T> getData() {
//         return mData;
//     }
// }


// Path: app/src/main/java/com/github/captain_miao/databinding/tutorial/viewpage/ViewPageActivity.java
import android.content.Context;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import com.github.captain_miao.databinding.tutorial.R;
import com.github.captain_miao.databinding.tutorial.base.BasePagerAdapter;
import com.github.captain_miao.databinding.tutorial.databinding.ViewPageItemViewBinding;
import java.util.ArrayList;
import java.util.List;



    private class GuideAdapter extends BasePagerAdapter<GuideViewModel> {

        public GuideAdapter(Context c) {
            super(c);
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            GuideViewModel model = getItem(position);

            ViewPageItemViewBinding frgGuideBinding
                    = ViewPageItemViewBinding.inflate(mInflater, container, false);
            frgGuideBinding.setViewModel(model);
            container.addView(frgGuideBinding.getRoot());
            return frgGuideBinding.getRoot();

        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            if(object instanceof View) {
                container.removeView((View) object);
            }
        }


        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;