Android Open Source - journal Monthly Expenses Pager Adapter






From Project

Back to project page journal.

License

The source code is released under:

MIT License

If you think the Android project journal listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package cochrane343.journal;
/*  w w w.j av  a2s  .  co m*/
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

/**
 * The {@link FragmentStatePagerAdapter} used to page through the {@link MonthlyExpensesFragment MonthlyExpensesFragments}
 * displaying the expenses of the different months.
 * 
 * @author cochrane343
 * @version 1.0
 */
public class MonthlyExpensesPagerAdapter extends FragmentStatePagerAdapter {    
    /**
     * The offset to account for the ongoing month
     */
    private final static int CURRENT_MONTH_OFFSET = 1;
    
    public MonthlyExpensesPagerAdapter(final FragmentManager fragmentManager) {
        super(fragmentManager);
    }

    /**
     * @param monthsSinceEpoch the number of months elapsed since the Java epoch, determining the month
     * displayed by the fragment at the specified position
     * @return the fragment associated with the specified position 
     */
    @Override
    public MonthlyExpensesFragment getItem(final int monthsSinceEpoch) {
        return MonthlyExpensesFragment.newInstance(monthsSinceEpoch);
    }
    
    /**
     * @return the number of views available, i.e. the number of months elapsed since the Java epoch
     * plus one
     */
    @Override
    public final int getCount() {
        return DateTimeHelper.getMonthsSinceEpoch() + CURRENT_MONTH_OFFSET;
    }
}




Java Source Code List

cochrane343.journal.Constants.java
cochrane343.journal.CurrencyHelper.java
cochrane343.journal.DateTimeHelper.java
cochrane343.journal.ExpenseEditListener.java
cochrane343.journal.ExpensesListAdapter.java
cochrane343.journal.MainActivity.java
cochrane343.journal.MonthlyExpensesFragment.java
cochrane343.journal.MonthlyExpensesPagerAdapter.java
cochrane343.journal.SettingsActivity.java
cochrane343.journal.TranslationHelper.java
cochrane343.journal.contentprovider.JournalContentProvider.java
cochrane343.journal.contentprovider.JournalContract.java
cochrane343.journal.contentprovider.JournalDatabaseHelper.java
cochrane343.journal.dialogs.CategorySpinnerAdapter.java
cochrane343.journal.dialogs.ExpenseDialogFragment.java
cochrane343.journal.dialogs.ExpenseDialogListener.java
cochrane343.journal.exceptions.IllegalDisplayModeException.java
cochrane343.journal.exceptions.IllegalLoaderIdException.java
cochrane343.journal.exceptions.IllegalUriException.java
cochrane343.journal.exceptions.MissingFragmentArgumentException.java