Android Open Source - SeniorDesign Summary Screen






From Project

Back to project page SeniorDesign.

License

The source code is released under:

GNU General Public License

If you think the Android project SeniorDesign 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 fakesetgame.seniordesign;
/*  w w  w.ja  v a 2s  .  c  o m*/
import fakesetgame.seniordesign.data.GameOutcome;
import fakesetgame.seniordesign.data.GameSummaryListItemCursorAdapter;
import fakesetgame.seniordesign.data.PlayerDataDbHelper;
import fakesetgame.seniordesign.model.Game;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

/**
 * This is the Activity class for the overlay screen
 * that is shown to the user at the conclusion of a game.
 */
public class SummaryScreen extends Activity {

    private Game.GameType mode;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.summary_activity);
        long lastGameID = getIntent().getLongExtra("lastGame", 0);

        GameOutcome lastGame = PlayerDataDbHelper.getOutcome(this, lastGameID);
        mode = lastGame.getMode();
        long lastGameTime = lastGame.getElapsed() / 1000;

        TextView elapsed = (TextView) findViewById(R.id.elapsedTime);
        if(lastGame.getOutcome() == Game.Outcome.Win)
            elapsed.setText(String.format("%d:%02d", lastGameTime / 60, lastGameTime % 60));
        else elapsed.setText(":(");

        GameSummaryListItemCursorAdapter adapter = new GameSummaryListItemCursorAdapter(this, PlayerDataDbHelper.getBestOutcomes(this, lastGame.getMode(), 5, lastGame.wasHintUsed()), 0);
        ListView listView = (ListView) findViewById(R.id.listView);
        listView.setAdapter(adapter);

        if(lastGame.getOutcome() == Game.Outcome.Win)
            messageUser(getResources().getString(lastGame.wasHintUsed() ? R.string.hintUsed : R.string.hintNotUsed));
        else messageUser(getResources().getString(R.string.lostGame));
    }

    private void messageUser(String message) {
        Toast toast = Toast.makeText(this, message,
                (message.length() > 24 ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT));
        toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
        toast.show();
    }

    public void StartNewGame(View v) {
        Intent i = new Intent(this, GameScreen.class);
        i.putExtra("type", mode);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(i);
    }

    public void MainMenu(View v) {
        Intent i = new Intent(this, HomeScreen.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(i);
    }
}




Java Source Code List

fakesetgame.seniordesign.BoardTest.java
fakesetgame.seniordesign.GameScreen.java
fakesetgame.seniordesign.GameTest.java
fakesetgame.seniordesign.HomeScreen.java
fakesetgame.seniordesign.OptionsScreen.java
fakesetgame.seniordesign.SettingsTest.java
fakesetgame.seniordesign.SplashScreen.java
fakesetgame.seniordesign.SummaryScreen.java
fakesetgame.seniordesign.TileSetTest.java
fakesetgame.seniordesign.data.FoundSetRecord.java
fakesetgame.seniordesign.data.GameOutcome.java
fakesetgame.seniordesign.data.GameSummaryListItemCursorAdapter.java
fakesetgame.seniordesign.data.OptionsHelper.java
fakesetgame.seniordesign.data.PlayerDataDbHelper.java
fakesetgame.seniordesign.data.Setting.java
fakesetgame.seniordesign.data.package-info.java
fakesetgame.seniordesign.model.BoardSize.java
fakesetgame.seniordesign.model.Board.java
fakesetgame.seniordesign.model.Color.java
fakesetgame.seniordesign.model.GameOverEvent.java
fakesetgame.seniordesign.model.GameOverListener.java
fakesetgame.seniordesign.model.Game.java
fakesetgame.seniordesign.model.HintProvider.java
fakesetgame.seniordesign.model.Modifier.java
fakesetgame.seniordesign.model.Shading.java
fakesetgame.seniordesign.model.Shape.java
fakesetgame.seniordesign.model.TileSet.java
fakesetgame.seniordesign.model.Tile.java
fakesetgame.seniordesign.model.package-info.java
fakesetgame.seniordesign.view.GameSummaryListItemView.java
fakesetgame.seniordesign.view.ShadedImageView.java
fakesetgame.seniordesign.view.package-info.java
fakesetgame.seniordesign.package-info.java