package it.unipr.mobdev;

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

/**
 * A FragmentPagerAdapter that returns a fragment corresponding to the current page
 * of the ViewPager
 */
public class AppSectionsPagerAdapter extends FragmentPagerAdapter {

	public AppSectionsPagerAdapter(FragmentManager fm) {
		super(fm);
	}

	/**
	 * Returns the Fragment associated to the element in position 'i'
	 */
	@Override
	public Fragment getItem(int i) {
		switch (i) {
		case 0:
			return new BookmarkGridFragment();
		case 1:
			return new BookmarkListFragment();    
		default:
			return new BookmarkGridFragment();
		}
	}

	/**
	 * Returns the number of element in the ViewPager
	 */
	@Override
	public int getCount() {
		return 2;
	}

	/**
	 * Returns the title (as CharSequence) of the Page at position 'position'
	 */
	@Override
	public CharSequence getPageTitle(int position) {
		switch (position) {
		case 0:
			return "Add";
		case 1:
			return "Top";
		case 2:
			return "My List";    
		default:
			return "No Title !";
		}
	}
}
