Android Open Source - Game-of-thrones-trivia Session






From Project

Back to project page Game-of-thrones-trivia.

License

The source code is released under:

MIT License

If you think the Android project Game-of-thrones-trivia 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.GameOfThrones.Trivia.core;
/*  ww w  .  j  a va2  s. c o  m*/
import java.util.ArrayList;

/**
 * Singleton used to store persistent data throughout application
 * 
 * @author andre
 * 
 */
public class Session {
  /**
   * Session object for this application execution
   */
  protected static Session instance;
  /**
   * drawable reference to background image when in portrait mode
   */

  protected ArrayList<GameCharacter> characters;
  /**
   * Used to know which questions reference which GameCharacter
   */
  
  protected CharacterToQuestionsMap map;

  /**
   * private Constructor - ensures only this class can create session instance
   */
  private Session() {
    characters = new ArrayList<GameCharacter>();
  }

  /**
   * Session instance - guaranteed to always return same instance (Lazy
   * instantiation)
   * 
   * @return
   */
  public static Session getInstance() {
    if (instance == null) {
      instance = new Session();
    }
    return instance;
  }

  /**
   * @return the characters
   */
  public ArrayList<GameCharacter> getCharacters() {
    return characters;
  }

  /**
   * @param characters
   *            the characters to set
   */
  public void setCharacters(ArrayList<GameCharacter> characters) {
    this.characters = characters;
    map = new CharacterToQuestionsMap(characters);
  }

  /**
   * @param object
   * @return
   * @see java.util.ArrayList#add(java.lang.Object)
   */
  public boolean add(GameCharacter object) {
    return characters.add(object);
  }

  /**
   * @return the map
   */
  public CharacterToQuestionsMap getMap() {
    return map;
  }

  /**
   * @param map
   *            the map to set
   */
  public void setMap(CharacterToQuestionsMap map) {
    this.map = map;
  }

}




Java Source Code List

com.GameOfThrones.Trivia.core.CharacterToQuestionsMap.java
com.GameOfThrones.Trivia.core.GameCharacter.java
com.GameOfThrones.Trivia.core.HighScore.java
com.GameOfThrones.Trivia.core.OutOfQuestionsException.java
com.GameOfThrones.Trivia.core.QuestionCollection.java
com.GameOfThrones.Trivia.core.Question.java
com.GameOfThrones.Trivia.core.Session.java
com.GameOfThrones.Trivia.core.SimpleIterator.java
com.GameOfThrones.Trivia.core.TriviaGame.java
com.GameOfThrones.Trivia.data.HighScorePrefs.java
com.GameOfThrones.Trivia.data.RequestWebService.java
com.GameOfThrones.Trivia.data.StringsXMLFileData.java
com.GameOfThrones.Trivia.ui.AboutActivity.java
com.GameOfThrones.Trivia.ui.DynamicBackgroundActivity.java
com.GameOfThrones.Trivia.ui.GameActivity.java
com.GameOfThrones.Trivia.ui.HighScoreActivity.java
com.GameOfThrones.Trivia.ui.MainMenuActivity.java
com.GameOfThrones.Trivia.ui.ResultsActivity.java
com.GameOfThrones.Trivia.ui.TriviaSelectionActivity.java
com.GameOfThrones.Trivia.ui.music.MusicService.java
com.GameOfThrones.Trivia.util.GeneralAlgorithms.java
com.Spartacus.TriviaTest.TriviaMenuActivityTest.java
com.Spartacus.Trivia.utilTest.GeneralAlgorithmsTest.java