Android Open Source - QuizGame Statistics Activity






From Project

Back to project page QuizGame.

License

The source code is released under:

GNU General Public License

If you think the Android project QuizGame 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 it.splineyellow.quizgame;
/*from  w w w. j av a  2s  . c  o  m*/
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import java.sql.SQLException;

// Copyright SplineYellow - 2014

/*
    Classe per la gestione delle statistiche di gioco.
 */
/*
    TODO
    Nel database sono implementati i metodi relativi a questa activity; una volta risolti i problemi
    di ricezione del tabellone, sar possibile anche aggiornare le varie statistiche relative alle
    partite vinte, perse e pareggiate; alle risposta corrette e sbagliate.
 */
public class StatisticsActivity extends Activity {
    UtentiDatabaseAdapter utentiDatabaseAdapter = new UtentiDatabaseAdapter(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.statistics_activity);

        try {
            utentiDatabaseAdapter.open();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        String currentUserData = utentiDatabaseAdapter.getCurrentUser();

        String [] data = currentUserData.split(",");

        String currentUser = data[0];

        TextView username = (TextView) findViewById(R.id.statistics_nickname);

        username.setText(currentUser);

        int result = utentiDatabaseAdapter.getPlayData(currentUser, 1);

        TextView giocate = (TextView) findViewById(R.id.statistics_giocate);

        giocate.setText(Integer.toString(result));

        result = utentiDatabaseAdapter.getPlayData(currentUser, 2);

        TextView vinte = (TextView) findViewById(R.id.statistics_vinte);

        vinte.setText(Integer.toString(result));

        result = utentiDatabaseAdapter.getPlayData(currentUser, 3);

        TextView pareggiate = (TextView) findViewById(R.id.statistics_pareggiate);

        pareggiate.setText(Integer.toString(result));

        result = utentiDatabaseAdapter.getPlayData(currentUser, 4);

        TextView perse = (TextView) findViewById(R.id.statistics_perse);

        perse.setText(Integer.toString(result));

        result = utentiDatabaseAdapter.getPlayData(currentUser, 5);

        TextView giuste = (TextView) findViewById(R.id.statistics_giuste);

        giuste.setText(Integer.toString(result));

        result = utentiDatabaseAdapter.getPlayData(currentUser, 6);

        TextView sbagliate = (TextView) findViewById(R.id.statistics_sbagliate);

        sbagliate.setText(Integer.toString(result));

        String access = utentiDatabaseAdapter.getLastAccess(currentUser);

        String[] accessData = access.split(";");

        access = accessData[0] + " " + accessData[1];

        TextView lastAccess = (TextView) findViewById(R.id.statistics_ultimo_accesso);

        lastAccess.setText(access);

        utentiDatabaseAdapter.close();
    }
}




Java Source Code List

it.splineyellow.quizgame.ConnectionActivity.java
it.splineyellow.quizgame.DomandeDatabaseAdapter.java
it.splineyellow.quizgame.EndGameActivity.java
it.splineyellow.quizgame.ListGamesActivity.java
it.splineyellow.quizgame.MainActivity.java
it.splineyellow.quizgame.MenuActivity.java
it.splineyellow.quizgame.QuestionActivity.java
it.splineyellow.quizgame.ScoreActivity.java
it.splineyellow.quizgame.StartGameActivity.java
it.splineyellow.quizgame.StatisticsActivity.java
it.splineyellow.quizgame.UtentiDatabaseAdapter.java