Android Open Source - SeniorDesign Options Helper






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.data;
//  w  w w .j  av  a 2 s .c o  m
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import fakesetgame.seniordesign.R;
import fakesetgame.seniordesign.model.Modifier;


/**
 * A class to assist in saving and retrieving specific game settings.
 */
public class OptionsHelper {

    public static int getHardness(Context ctx){
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(ctx);
        return Integer.valueOf(sp.getString(ctx.getString(R.string.optDiffKey),
                ctx.getString(R.string.optDiffMidLevelValue)));
    }

    public static double getMinDiff(Context ctx) {
        switch (getHardness(ctx)) {
            case 2:
                return getSetCount(ctx) * Modifier.COUNT_DIFFERENCE.getValue() *
                        Modifier.COLOR_DIFFERENCE.getValue() * Modifier.SHAPE_DIFFERENCE.getValue();
            case 1:
                return getSetCount(ctx) * Modifier.COUNT_DIFFERENCE.getValue() *
                        Modifier.SHADING_DIFFERENCE.getValue();
            default:
                return getSetCount(ctx) * Modifier.minModifier;
        }
    }

    public static double getMaxDiff(Context ctx) {
        switch (getHardness(ctx)) {
            case 2:
                return getSetCount(ctx) * Modifier.maxModifier;
            case 1:
                return getSetCount(ctx) * Modifier.COUNT_DIFFERENCE.getValue() *
                        Modifier.COLOR_DIFFERENCE.getValue() * Modifier.SHAPE_DIFFERENCE.getValue();
            default:
                return getSetCount(ctx) * Modifier.COUNT_DIFFERENCE.getValue() *
                        Modifier.SHADING_DIFFERENCE.getValue();
        }
    }

    public static int getSetCount(Context ctx) {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(ctx);
        return Integer.valueOf(sp.getString(ctx.getString(R.string.optSparseKey),
                ctx.getString(R.string.optSparseMidLevelValue)));
    }
}




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