Android Open Source - Game-of-thrones-trivia High Score Activity






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.ui;
//from ww w  . ja  va2  s  .c  om
import java.util.ArrayList;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.GameOfThrones.Trivia.R;
import com.GameOfThrones.Trivia.R.id;
import com.GameOfThrones.Trivia.R.layout;
import com.GameOfThrones.Trivia.core.HighScore;
import com.GameOfThrones.Trivia.data.HighScorePrefs;
/**
 * Displays user high scores saved in sharedPreferences
 * 
 * @author andre
 *
 */
public class HighScoreActivity extends DynamicBackgroundActivity {

  /* (non-Javadoc)
   * @see com.GameOfThrones.Trivia.SuperActivities.DynamicBackgroundActivity#onCreate(android.os.Bundle)
   */
  /**
   * Set up listview
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.high_score);

    final ListView listview = (ListView) findViewById(R.id.listview);

    ArrayList<String> highScores = getHighScores();

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(
        getBaseContext(), R.layout.row, highScores);
    // Bind to our new adapter.
    listview.setAdapter(adapter);
  }
  
  /***
   * Returns an arraylist of Strings that represent each highscore
   * @return
   */
  public ArrayList<String> getHighScores() {
    ArrayList<String> list = new ArrayList<String>();
    HighScorePrefs prefs = new HighScorePrefs(getBaseContext());
    for (int i = prefs.getHighScoreCount() -1; i > -1; i--) {
      HighScore temp = prefs.getHighScore(i);

      list.add(temp.toString());
    }
    return list;
  }

  /* (non-Javadoc)
   * @see com.GameOfThrones.Trivia.SuperActivities.DynamicBackgroundActivity#getBackgroundLayout()
   */
  @Override
  protected int getBackgroundLayout() {
    // TODO Auto-generated method stub
    return R.id.highScoreActivity;
  }

}




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