package org.deke.risk.riskahead.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import org.deke.risk.riskahead.fragment.SubscriptionItemFragment;

/**
 *
 * (C) Copyright 2016 RiskAhead (http://www.riskahead.net)
 * Developer & Contributor: Dennis Thießen (dennis.thiessen@riskahead.net)
 * Date of Release: 10.02.2016
 *
 */
public class SubscriptionsPagerAdapter extends FragmentStatePagerAdapter {
    int mNumOfTabs;

    SubscriptionItemFragment frag1;
    SubscriptionItemFragment frag2;

    public SubscriptionsPagerAdapter(FragmentManager fm, int NumOfTabs) {
        super(fm);
        this.mNumOfTabs = NumOfTabs;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment returnFragment = null;

            switch (position) {
                case 0:
                    if(frag1 == null) frag1 = new SubscriptionItemFragment();
                    returnFragment = frag1;
                    break;
                case 1:
                    if(frag2 == null) frag2 = new SubscriptionItemFragment();
                    returnFragment = frag2;
                    break;
                default:
                    return null;
            }



        return returnFragment;
    }


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