Android Open Source - HijriCalendar-master Month Pager Adapter






From Project

Back to project page HijriCalendar-master.

License

The source code is released under:

MIT License

If you think the Android project HijriCalendar-master 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 com.sahaab.hijri.caldroid;
//w w  w  . j a  va  2  s. co m
import java.util.ArrayList;

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

/**
 * MonthPagerAdapter holds 4 fragments, which provides fragment for current
 * month, previous month and next month. The extra fragment helps for recycle
 * fragments.
 * 
 * @author thomasdao
 * 
 */
public class MonthPagerAdapter extends FragmentPagerAdapter {

  private ArrayList<DateGridFragment> fragments;

  // Lazily create the fragments
  public ArrayList<DateGridFragment> getFragments() {
    if (fragments == null) {
      fragments = new ArrayList<DateGridFragment>();
      for (int i = 0; i < getCount(); i++) {
        fragments.add(new DateGridFragment());
      }
    }
    return fragments;
  }

  public void setFragments(ArrayList<DateGridFragment> fragments) {
    this.fragments = fragments;
  }

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

  @Override
  public Fragment getItem(int position) {
    DateGridFragment fragment = getFragments().get(position);
    return fragment;
  }

  @Override
  public int getCount() {
    // We need 4 gridviews for previous month, current month and next month,
    // and 1 extra fragment for fragment recycle
    return CaldroidFragment.NUMBER_OF_PAGES;
  }

}




Java Source Code List

com.antonyt.infiniteviewpager.InfinitePagerAdapter.java
com.antonyt.infiniteviewpager.InfiniteViewPager.java
com.caldroidsample.CaldroidSampleActivity.java
com.caldroidsample.CaldroidSampleCustomAdapter.java
com.caldroidsample.CaldroidSampleCustomFragment.java
com.sahaab.hijri.caldroid.CaldroidFragment.java
com.sahaab.hijri.caldroid.CaldroidGridAdapter.java
com.sahaab.hijri.caldroid.CaldroidListener.java
com.sahaab.hijri.caldroid.CalendarHelper.java
com.sahaab.hijri.caldroid.DateGridFragment.java
com.sahaab.hijri.caldroid.MonthPagerAdapter.java
com.sahaab.hijri.caldroid.SquareTextView.java
com.sahaab.hijri.caldroid.WeekdayArrayAdapter.java
com.sahaab.hijricalendar.HijriCalendarDate.java