Android Open Source - adamsonelearn Home Fragment






From Project

Back to project page adamsonelearn.

License

The source code is released under:

MIT License

If you think the Android project adamsonelearn 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.jaselogic.adamsonelearn;
//from w  ww.jav a 2  s .  c  om
import com.viewpagerindicator.TabPageIndicator;

import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class HomeFragment extends Fragment {
  
  private static final int NUM_PAGES = 3;
  private static final String[] STR_TITLES = new String[] {
    "Updates",
    "Subjects",
    "Today"
  };
  
  //pager view
  private ViewPager mPager;
  //pager adapter
  private PagerAdapter mPagerAdapter;
  
  public HomeFragment() {

  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_home, container, false);
    
    //create a new instance of ViewPager and PagerAdapter
    mPager = (ViewPager) rootView.findViewById(R.id.home_pager);
    mPagerAdapter = new HomePagerAdapter(getChildFragmentManager());
    mPager.setOffscreenPageLimit(2);
    mPager.setAdapter(mPagerAdapter);
    
    TabPageIndicator indicator = (TabPageIndicator) rootView.findViewById(R.id.viewpagerIndicator);
    indicator.setViewPager(mPager);
    
    return rootView;
  }

  //Home Pager Adapter
  private class HomePagerAdapter extends FragmentStatePagerAdapter {
    public HomePagerAdapter(FragmentManager fm) {
      super(fm);
    }
    
    @Override
    public Fragment getItem(int position) {
      if(position == 0) {
        return new HomePageFragment.UpdatesFragment();
      }
      
      if(position == 1) {
        return new HomePageFragment.SubjectsFragment();
      }
      
      return new HomePageFragment.TodayFragment();
    }
    
    @Override
    public CharSequence getPageTitle(int position) {
      return STR_TITLES[position].toUpperCase();
    }
    
    @Override
    public int getCount() {
      return NUM_PAGES;
    }
  }
}




Java Source Code List

com.jaselogic.adamsonelearn.AlertDialogBuilder.java
com.jaselogic.adamsonelearn.CurrDisplayAdapter.java
com.jaselogic.adamsonelearn.CurriculumFragment.java
com.jaselogic.adamsonelearn.CurriculumIntentService.java
com.jaselogic.adamsonelearn.CurriculumPageFragment.java
com.jaselogic.adamsonelearn.Dashboard.java
com.jaselogic.adamsonelearn.DownloadDocumentIntentService.java
com.jaselogic.adamsonelearn.DrawerListAdapter.java
com.jaselogic.adamsonelearn.HomeFragment.java
com.jaselogic.adamsonelearn.HomePageFragment.java
com.jaselogic.adamsonelearn.LoginIntentService.java
com.jaselogic.adamsonelearn.Main.java
com.jaselogic.adamsonelearn.NonSwipeViewPager.java
com.jaselogic.adamsonelearn.ScheduleHelper.java
com.jaselogic.adamsonelearn.SubjectIntentService.java
com.jaselogic.adamsonelearn.SubjectListAdapter.java
com.jaselogic.adamsonelearn.TodayListAdapter.java
com.jaselogic.adamsonelearn.UpdateIntentService.java
com.jaselogic.adamsonelearn.UpdatesListAdapter.java
com.jaselogic.adamsonelearn.YearSelectAdapter.java
com.viewpagerindicator.CirclePageIndicator.java
com.viewpagerindicator.IconPageIndicator.java
com.viewpagerindicator.IconPagerAdapter.java
com.viewpagerindicator.IcsLinearLayout.java
com.viewpagerindicator.LinePageIndicator.java
com.viewpagerindicator.PageIndicator.java
com.viewpagerindicator.TabPageIndicator.java
com.viewpagerindicator.TitlePageIndicator.java
com.viewpagerindicator.UnderlinePageIndicator.java