package net.miz_hi.smileessence.listener;

import android.support.v4.view.ViewPager.OnPageChangeListener;
import net.miz_hi.smileessence.system.PageController;
import net.miz_hi.smileessence.view.fragment.NamedFragment;

public class PageChangeListener implements OnPageChangeListener
{

    boolean isOpening = false;
    int lastPosition = 0;

    @Override
    public void onPageScrollStateChanged(int position)
    {
    }

    @Override
    public void onPageScrolled(int arg0, float arg1, int arg2)
    {
    }

    @Override
    public void onPageSelected(int position)
    {
        NamedFragment from = PageController.getInstance().getAdapter().getList().get(lastPosition);
        NamedFragment to = PageController.getInstance().getAdapter().getList().get(position);
        from.onDeselect();
        to.onSelected();
        lastPosition = position;
    }

}

@@ -572,24 +572,120 @@
 tion)%0A    %7B%0A
+        if (lastPosition %3E= PageController.getInstance().getAdapter().getCount())%0A        %7B%0A    
         Name
@@ -764,32 +764,73 @@
 (lastPosition);%0A
+            from.onDeselect();%0A        %7D%0A
         NamedFra
@@ -911,35 +911,8 @@
 n);%0A
-        from.onDeselect();%0A
     

Fix PageChangeListener: Page closing bug