Q:

java.lang. IllegalStateException: Fragment already active

I am creating a walkthrough activity with a ViewPager and fragments, I have been able to successfully create the walkthrough, but the issue is, I can only swipe to the front, if I try to swipe back the app crashes, I tried replicating it on another test app which worked perfectly both front and back, although that one uses a TextView while this one uses an ImageView. 
I need help figuring out why it crashes while swiping to back. 
public class WalkThroughActivity extends AppCompatActivity {

    ViewPager mPager;
    LinearLayout mLinearLayout;
    CustomPagerAdapter mAdapter;
    MyPageIndicator mIndicator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_walk_through);

        mPager = (ViewPager) findViewById(R.id.pager);
        mLinearLayout = (LinearLayout) findViewById(R.id.pagesContainer);
        List < Fragment > fragments = new ArrayList < >();
        fragments.add(ContentFragment.newInstance(R.drawable.walkthrough_card_1));
        fragments.add(ContentFragment.newInstance(R.drawable.walkthrough_card_2));
        fragments.add(ContentFragment.newInstance(R.drawable.walkthrough_card_3));

        mAdapter = new CustomPagerAdapter(getSupportFragmentManager(), fragments);
        mPager.setAdapter(mAdapter);
        mIndicator = new MyPageIndicator(this, mLinearLayout, mPager, R.drawable.indicator_circle);
        mIndicator.setPageCount(fragments.size());
        mIndicator.show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mIndicator.cleanup();
    }

    static class CustomPagerAdapter extends FragmentStatePagerAdapter {

        List < Fragment > mFrags = new ArrayList < >();

        public CustomPagerAdapter(FragmentManager fm, List < Fragment > frags) {
            super(fm);
            mFrags = frags;
        }

        @Override
        public Fragment getItem(int position) {
            int index = position % mFrags.size();
            return mFrags.get(index);
        }

        @Override
        public int getCount() {
            return Integer. MAX_VALUE;
        }

    }
}

ContentFragment
public class ContentFragment extends Fragment {
    private static final String ARG_PARAM1 = "param1";

    private int mParam1;

    public ContentFragment() {
        // Required empty public constructor
    }

    public static ContentFragment newInstance(int param1) {
        ContentFragment fragment = new ContentFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_PARAM1, param1);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() ! = null) {
            mParam1 = getArguments().getInt(ARG_PARAM1);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.indicator_fragment, container, false);;
        ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
        imageView.setImageResource(mParam1);
        return view;
    }

    public int getmParam1() {
        return mParam1;
    }

}

Error Log
FATAL EXCEPTION: main
    Process: com.simpumind.shoopa, PID: 8207
        java.lang. IllegalStateException: Fragment already active
            at android.support.v4.app. Fragment.setInitialSavedState(Fragment.java:576)
            at android.support.v4.app. FragmentStatePagerAdapter.instantiateItem(FragmentStatePagerAdapter.java:114)
            at android.support.v4.view. ViewPager.addNewItem(ViewPager.java:1034)
            at android.support.v4.view. ViewPager.populate(ViewPager.java:1216)
            at android.support.v4.view. ViewPager.populate(ViewPager.java:1116)
            at android.support.v4.view. ViewPager$3.run(ViewPager.java:273)
            at android.view. Choreographer$CallbackRecord.run(Choreographer.java:858)
            at android.view. Choreographer.doCallbacks(Choreographer.java:670)
            at android.view. Choreographer.doFrame(Choreographer.java:603)
            at android.view. Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
            at android.os. Handler.handleCallback(Handler.java:739)
            at android.os. Handler.dispatchMessage(Handler.java:95)
            at android.os. Looper.loop(Looper.java:148)
            at android.app. ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect. Method.invoke(Native Method)
            at com.android.internal.os. ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os. ZygoteInit.main(ZygoteInit.java:616)

A:

I believe that offending lines of code are
    @Override
    public Fragment getItem(int position) {
        int index = position % mFrags.size();
        return mFrags.get(index);
    }

    @Override
    public int getCount() {
        return Integer. MAX_VALUE;
    }

I'm not sure what you are trying to achieve but this code is very bad.  It makes the ViewPager believe that you have much more fragments than you actually have AND reuse the same fragement several times.  Assume that mFrags.size() is 2 and  the ViewPager asks for #0, #1 and #2 - you would return the fragment #0 twice and the ViewPager  might try to pass the same fragment through lifecycle twice.  This re-usage of fragments is most probably the source of the exception you see. 
By the way, what's wrong with straightforward? 
    @Override
    public Fragment getItem(int position) {
        return mFrags.get(position);
    }

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

