Android Open Source - ScienceQuiz Start Home Fragment






From Project

Back to project page ScienceQuiz.

License

The source code is released under:

GNU General Public License

If you think the Android project ScienceQuiz 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.finger.sciencequiz;
// w  w w .j  a  va2 s.com
import com.finger.sciencequiz.R;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * A dummy fragment representing a section of the app, but that simply
 * displays dummy text.
 */
public class StartHomeFragment extends Fragment
{
    public StartHomeFragment ()
    {
  super ();
  h = new Handler ();
  d = new Diashow (this);
    }

    protected ViewPager gallery;
    protected int       galPos;
    protected Handler   h;
    protected Runnable  d;
    protected final int DIA_DELAY = 7000;

    @Override
    public View onCreateView (LayoutInflater inflater, ViewGroup container,
                        Bundle savedInstanceState)
    {
  View rootView = inflater.inflate (
      R.layout.fragment_main_start,
      container,
      false);
  gallery = (ViewPager) rootView.findViewById (R.id.gallery_view_pager);
  ImageAdapter adapter =
                  new ImageAdapter (inflater, rootView.getContext ());
  gallery.setAdapter (adapter);
  return rootView;
    }
    
    @Override
    public void onResume ()
    {
  super.onResume ();
  h.postDelayed (d, DIA_DELAY);
    }
    
    @Override
    public void onPause ()
    {
  super.onPause ();
  h.removeCallbacks (d);
    }

    public void next ()
    {
  galPos = (galPos + 1) % 3;
  gallery.setCurrentItem (galPos);
    }
    
    class Diashow implements Runnable
    {
  public Diashow (StartHomeFragment f)
  {
      this.f = f;
  }

  protected StartHomeFragment f;
  
  @Override
        public void run ()
        {
      f.next ();
      h.postDelayed (this, f.DIA_DELAY);
        }
  
    }
}




Java Source Code List

com.finger.sciencequiz.AboutActivity.java
com.finger.sciencequiz.ConfigReader.java
com.finger.sciencequiz.FriendsHomeFragment.java
com.finger.sciencequiz.GalleryViewPager.java
com.finger.sciencequiz.GameActivity.java
com.finger.sciencequiz.GameTypeSelectActivity.java
com.finger.sciencequiz.HistoryActivity.java
com.finger.sciencequiz.HomePagerAdapter.java
com.finger.sciencequiz.ImageAdapter.java
com.finger.sciencequiz.LobbyActivity.java
com.finger.sciencequiz.MainActivity.java
com.finger.sciencequiz.NavigationDrawerFragment.java
com.finger.sciencequiz.NewGameActivity.java
com.finger.sciencequiz.ProfileHomeFragment.java
com.finger.sciencequiz.RotationTextView.java
com.finger.sciencequiz.RunningGamesHomeFragment.java
com.finger.sciencequiz.SettingsActivity.java
com.finger.sciencequiz.StartHomeFragment.java