Android Open Source - android-simlple-minefield High Scores Activity






From Project

Back to project page android-simlple-minefield.

License

The source code is released under:

Apache License

If you think the Android project android-simlple-minefield 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.trabo.minefield;
/*  w w w  .ja v a 2s  .  c  om*/
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;
import com.trabo.minefield.utils.AppContract;
import com.trabo.minefield.utils.AppUtils;

import static com.trabo.minefield.utils.AppContract.*;

/**
 * @author Andriy Petruk <andrii.petruk{at}gmail.com>
 * @date 27.06.14.
 */
public class HighScoresActivity extends Activity {
    private static final long NO_VALUE = Long.MIN_VALUE;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.high_scores_activity);

        SharedPreferences scoreData = getSharedPreferences(AppContract.HIGH_SCORE_PREFS, 0);

        long easyScore = scoreData.getLong(GameType.EASY.name(), NO_VALUE);
        long normalScore = scoreData.getLong(GameType.NORMAL.name(), NO_VALUE);
        long hardScore = scoreData.getLong(GameType.HARD.name(), NO_VALUE);

        if (easyScore != NO_VALUE) {
            ((TextView) findViewById(R.id.easy_high_score)).setText(AppUtils.getTimeString(easyScore));
        }

        if (normalScore != NO_VALUE) {
            ((TextView) findViewById(R.id.normal_high_score)).setText(AppUtils.getTimeString(normalScore));
        }

        if (hardScore != NO_VALUE) {
            ((TextView) findViewById(R.id.hard_high_score)).setText(AppUtils.getTimeString(hardScore));
        }
    }
}




Java Source Code List

com.trabo.minefield.CellOnTouchListener.java
com.trabo.minefield.GameActivity.java
com.trabo.minefield.HighScoresActivity.java
com.trabo.minefield.MainActivity.java
com.trabo.minefield.MineFieldListener.java
com.trabo.minefield.MineModel.java
com.trabo.minefield.MinefieldAdapter.java
com.trabo.minefield.MinefieldView.java
com.trabo.minefield.utils.AppContract.java
com.trabo.minefield.utils.AppUtils.java
com.trabo.minefield.utils.MineGridUtils.java