package g0v.ly.android.navigate;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import g0v.ly.android.R;

public class FragmentViewPager extends Fragment {

    private static final int NUM_PAGES = 5;
    private ViewPager viewPager;
    private PagerAdapter pagerAdapter;
/*
    private SparseArray<ViewPagerInnerFragment> innerFragments =
            new SparseArray<ViewPagerInnerFragment>();
*/
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_view_pager, container, false);

        viewPager = (ViewPager) view.findViewById(R.id.view_pager);
        pagerAdapter = new TestViewPagerAdapter(this);
        viewPager.setAdapter(pagerAdapter);

        // debug toast
        Toast.makeText(view.getContext(), "FragmentViewPager", Toast.LENGTH_LONG).show();

        return view;
    }


    public interface ViewPagerInnerFragment {
        public void enter();
        //public void leave();
        //public boolean controlEnabled();
    }

    public class TestViewPagerAdapter extends FragmentPagerAdapter {

        public TestViewPagerAdapter(Fragment fragment) {
            super(fragment.getChildFragmentManager());
        }

        @Override
        public Fragment getItem(int i) {
            return new FragmentTest(i, 300);
        }

        @Override
        public int getCount() {
            return NUM_PAGES;
        }
    }
}

@@ -356,16 +356,126 @@
 Toast;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 import g
@@ -539,24 +539,116 @@
 Fragment %7B%0A%0A
+    private static final Logger logger = LoggerFactory.getLogger(FragmentViewPager.class);%0A%0A
     private 
@@ -750,16 +750,88 @@
 Adapter;
+%0A%0A    private List%3CFragment%3E testFragments = new ArrayList %3CFragment%3E();
 %0A/*%0A    
@@ -1899,24 +1899,108 @@
 em(int i) %7B%0A
+            // TODO: get previous fragment's y position and pass to next fragment.%0A%0A
             
@@ -2132,16 +2132,240 @@
        %7D
+%0A%0A        @Override%0A        public void destroyItem(ViewGroup container, int position, Object object) %7B%0A            super.destroyItem(container, position, object);%0A%0A            logger.error(%22destroy %7B%7D%22, position);%0A        %7D
 %0A    %7D%0A%7D

Add fragment array