Android Open Source - PitchCounter State Singleton






From Project

Back to project page PitchCounter.

License

The source code is released under:

MIT License

If you think the Android project PitchCounter 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.westglenn.www.pitchcounter;
//from   ww  w  . j ava  2s.c om
import java.util.ArrayList;

/**
 * Created by jtrotman on 9/14/2014.
 */
public class StateSingleton
{
    private static StateSingleton instance;

    private ArrayList<Pitcher> list;
    private int currentPitcherId;

    public StateSingleton() {
        this.list = new ArrayList<Pitcher>();
        // must have 1 pitcher
        Pitcher p = new Pitcher();
        p.setName("Pitcher 1");
        this.list.add(p);

        currentPitcherId = 0;
    }

    public ArrayList<Pitcher> getList()
    {
        return this.list;
    }

    public int getCurrentPitcherId()
    {
        return this.currentPitcherId;
    }

    public void setCurrentPitcherId(int newValue)
    {
        this.currentPitcherId = newValue;
    }

    public Pitcher getCurrentPitcher() {
        for (Pitcher p : this.list) {
            if (p.getId() == this.currentPitcherId) {
                return p;
            }
        }
        return null;
    }

    public static StateSingleton getInstance()
    {
        if (instance == null)
        {
            instance = new StateSingleton();
        }
        return instance;
    }
}




Java Source Code List

com.westglenn.www.pitchcounter.AboutActivity.java
com.westglenn.www.pitchcounter.AddPitcherActivity.java
com.westglenn.www.pitchcounter.ApplicationTest.java
com.westglenn.www.pitchcounter.EditPitcherActivity.java
com.westglenn.www.pitchcounter.HelpActivity.java
com.westglenn.www.pitchcounter.HomeActivity.java
com.westglenn.www.pitchcounter.PitcherActivity.java
com.westglenn.www.pitchcounter.PitcherListActivity.java
com.westglenn.www.pitchcounter.Pitcher.java
com.westglenn.www.pitchcounter.SettingsActivity.java
com.westglenn.www.pitchcounter.StateSingleton.java