ca.rmen.android.scrumchatter.chart.ChartPagerAdapter.java Source code

Java tutorial

Introduction

Here is the source code for ca.rmen.android.scrumchatter.chart.ChartPagerAdapter.java

Source

/*
 * Copyright 2016 Carmen Alvarez
 * <p/>
 * This file is part of Scrum Chatter.
 * <p/>
 * Scrum Chatter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * <p/>
 * Scrum Chatter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * <p/>
 * You should have received a copy of the GNU General Public License
 * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>.
 */
package ca.rmen.android.scrumchatter.chart;

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

import java.util.Locale;

import ca.rmen.android.scrumchatter.R;

final class ChartPagerAdapter extends FragmentPagerAdapter {

    private final Context mContext;

    public ChartPagerAdapter(Context context, FragmentManager fm) {
        super(fm);
        mContext = context;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0)
            return new MeetingsChartsFragment();
        if (position == 1)
            return new MembersChartsFragment();

        return null;
    }

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

    @Override
    public CharSequence getPageTitle(int position) {
        Locale l = Locale.getDefault();
        switch (position) {
        case 0:
            return mContext.getString(R.string.title_section_meetings).toUpperCase(l);
        case 1:
            return mContext.getString(R.string.title_section_team).toUpperCase(l);
        }
        return null;
    }
}