Android Open Source - Game-of-thrones-trivia Results 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;
/*  ww w.j a v a  2s .c o  m*/
import com.GameOfThrones.Trivia.R;
import com.GameOfThrones.Trivia.R.id;
import com.GameOfThrones.Trivia.R.layout;
import com.GameOfThrones.Trivia.R.string;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

/**
 * End of game activity.
 * 
 * @author andre
 * 
 */
public class ResultsActivity extends DynamicBackgroundActivity implements
    OnClickListener {
  /** Stores the game statsView from the previous user game */
  int correct, total;

  /** References to the views in the UI layout */
  TextView tv, scoreText;
  Button submit, b1, backMain, rateApp;
  /** Score the user obtained while playing game in GameActivity */
  int score;

  /**
   * onCreate(Bundle) - Sets the UI layout and initializes instance variables
   */
  /*
   * (non-Javadoc)
   * 
   * @see
   * com.GameOfThrones.Trivia.SuperActivities.DynamicBackgroundActivity#onCreate
   * (android.os.Bundle)
   */
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.results);
    correct = 0;
    total = 0;
    score = 0;
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      correct = extras.getInt("correct");
      total = extras.getInt("total");
      score = extras.getInt("scoreView");
    }
    tv = (TextView) findViewById(R.id.endView1);
    tv.setVisibility(2);
    b1 = (Button) findViewById(R.id.endbutton1);
    b1.setOnClickListener(this);
    scoreText = (TextView) findViewById(R.id.scoreText);

    backMain = (Button) findViewById(R.id.backMain);
    backMain.setOnClickListener(this);

    rateApp = (Button) findViewById(R.id.rateApp);
    rateApp.setOnClickListener(this);
  }

  /**
   * onReumse() - show the scoreView calculation results in textview
   */
  /*
   * (non-Javadoc)
   * 
   * @see android.app.Activity#onResume()
   */
  public void onResume() {
    super.onResume();
    showResults();
  }

  /**
   * setScore() - Shows a message indicating how successful you were
   */
  private void showResults() {
    String str = "";
    if (score >= 1000) {
      str = "Azor Ahai reborn!!";
    } else if (score >= 600) {
      str = "On your way to the throne....";
    } else {
      str = "Worse than a whitewalker...";
    }
    tv.setText(str);
    scoreText.setText("Score: " + score);
  }

  /**
   * onClick() - Performs the appropriate action for the button the user
   * selects
   * */
  /*
   * (non-Javadoc)
   * 
   * @see android.view.View.OnClickListener#onClick(android.view.View)
   */
  public void onClick(View arg0) {
    super.refreshBackground();
    switch (arg0.getId()) {
    case R.id.endbutton1:
      nextActivity(TriviaSelectionActivity.class);
      break;
    case R.id.backMain:
      nextActivity(MainMenuActivity.class);
      break;
    case R.id.rateApp:
      Intent i = new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse(this.getString(R.string.appUrl)));
      startActivity(i);
      break;
    }
  }

  /**
   * onDestroy() - Cleans up instance variables.
   */
  public void onDestroy() {
    super.onDestroy();
    tv = null;
    b1 = null;
    backMain = null;
  }

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




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