// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java
// public class PuzzleApplication extends Application{
// 
//     private static Context mContext;
// 
//     private static User mUser;
// 
//     private static DishManager dm;
// 
//     public static int getLevel() {
//         return level;
//     }
// 
//     public static void setLevel(int level) {
//         if(level < 3) return;
//         PuzzleApplication.level = level;
//         initDishManager();
//     }
// 
//     private static int level = 4;
// 
//     @Override
//     public void onCreate(){
//         super.onCreate();
//         LeakCanary.install(this);
//         Bmob.initialize(this, StaticValue.bmobId);
//         if(mContext == null) mContext = getApplicationContext();
//         SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE);
//         setLevel(pref.getInt(StaticValue.SP_LEVEL, 4));
//     }
// 
//     public static User getmUser() {
//         return mUser;
//     }
// 
//     public static void setmUser(User mUser) {
//         PuzzleApplication.mUser = mUser;
//     }
// 
//     public static Context getAppContext(){
//         return mContext;
//     }
// 
//     public static void initDishManager(){
//         dm = new DishManager(level);
//     }
// 
//     public static DishManager getDishManager(){
//         return dm;
//     }
// }
// 
// Path: app/src/main/java/studio/androiddev/puzzle/utils/StaticValue.java
// public class StaticValue {
//     public static String bmobId = "284420dcdca2ba4dbb2f1b2bb463fb35";
// 
//     public static final String SP_NAME = "puzzle_sp";
//     public static final String SP_LEVEL = "level";
// }


import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import studio.androiddev.puzzle.PuzzleApplication;
import studio.androiddev.puzzle.R;
import studio.androiddev.puzzle.utils.StaticValue;
                defaultWhich = i;
            }
        }

        builder.setSingleChoiceItems(levels, defaultWhich,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        choosedLevel = which;
                    }
                });
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                levelChooseButton.setText(levels[choosedLevel]);
                changeLevel();
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.show();
    }

    private void changeLevel() {

        int level = choosedLevel + 3;
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java
// public class PuzzleApplication extends Application{
// 
//     private static Context mContext;
// 
//     private static User mUser;
// 
//     private static DishManager dm;
// 
//     public static int getLevel() {
//         return level;
//     }
// 
//     public static void setLevel(int level) {
//         if(level < 3) return;
//         PuzzleApplication.level = level;
//         initDishManager();
//     }
// 
//     private static int level = 4;
// 
//     @Override
//     public void onCreate(){
//         super.onCreate();
//         LeakCanary.install(this);
//         Bmob.initialize(this, StaticValue.bmobId);
//         if(mContext == null) mContext = getApplicationContext();
//         SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE);
//         setLevel(pref.getInt(StaticValue.SP_LEVEL, 4));
//     }
// 
//     public static User getmUser() {
//         return mUser;
//     }
// 
//     public static void setmUser(User mUser) {
//         PuzzleApplication.mUser = mUser;
//     }
// 
//     public static Context getAppContext(){
//         return mContext;
//     }
// 
//     public static void initDishManager(){
//         dm = new DishManager(level);
//     }
// 
//     public static DishManager getDishManager(){
//         return dm;
//     }
// }
// 
// Path: app/src/main/java/studio/androiddev/puzzle/utils/StaticValue.java
// public class StaticValue {
//     public static String bmobId = "284420dcdca2ba4dbb2f1b2bb463fb35";
// 
//     public static final String SP_NAME = "puzzle_sp";
//     public static final String SP_LEVEL = "level";
// }


// Path: app/src/main/java/studio/androiddev/puzzle/activity/SettingActivity.java
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import studio.androiddev.puzzle.PuzzleApplication;
import studio.androiddev.puzzle.R;
import studio.androiddev.puzzle.utils.StaticValue;

                defaultWhich = i;
            }
        }

        builder.setSingleChoiceItems(levels, defaultWhich,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        choosedLevel = which;
                    }
                });
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                levelChooseButton.setText(levels[choosedLevel]);
                changeLevel();
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.show();
    }

    private void changeLevel() {

        int level = choosedLevel + 3;
        SharedPreferences.Editor editor = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE).edit();