<commit_before>package com.deng.flashingmath;

import java.util.HashMap;
import java.util.Random;

import com.umeng.analytics.MobclickAgent;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.AssetManager;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

    private TextView num1Tv;
    private TextView num2Tv;
    private TextView opTv;
    private TextView resultTv;
    private TextView equalsOp;
    private ProgressBar progress;
    private RelativeLayout container;
    private TableLayout table;
    private TextView bestScoreTv;
    private TextView currentScoreTv;
    private TextView title;
    private TextView bestTitle;
    private TextView scoreTitle;
    private TextView numOfRightTv;
    private CustomProgressDialog loadingPd;

    private int SLEEP_TIME = 20;
    private int MAX_SLEEP_TIME = 20;
    private int numOfRight = 0;

    private int currentScore = 0;
    private int highestSore = 0;
    private Button[] btns = new Button[9];

    int[] nums = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6};
    char[] ops = new char[]{'+', '-', '×', '÷', '+', '-', '×', '÷', '×', '÷'};

    private ExpressionThread myThread;
    private SharedPreferences myPerf;
    private Expression currentExpression;

    private SoundPool soundPool;
    private int buttonRightSoundId = -1;
    private int buttonSoundId = -1;
    private int victorySoundId = -1;
    private boolean soundEnabled = true;
    private boolean viberateEanbled = true;
    private Typeface tf;
    private Vibrator mVibrator;  //声明一个振动器对象
    private Handler myUiHandler = new Handler() {
        public void handleMessage(Message m) {
            if (m.what == 1111) {
                num1Tv.setText(currentExpression.num1 + "");
                num2Tv.setText(currentExpression.num2 + "");
                opTv.setText(currentExpression.op + "");
                resultTv.setText("?");
                resultTv.setTextColor(Color.rgb(0xff, 0xff, 0xff));
                progress.setProgress(100);
            } else if (m.what == 1112) {
                progress.setProgress((Integer) m.obj);
                //if((Integer) m.obj==90)autoTest();
            } else if (m.what == 1113) {
                showDialog();//游戏结束
            }
        }
    };

//	private int[] nightColors=new int[]{Color.rgb(0xff, 0x66, 0x66),
//			Color.rgb(0xff, 0xff, 0x00),
//			Color.rgb(0xff, 0x66, 0x99),
//			Color.rgb(0xff, 0x99, 0x66),
//			Color.rgb(0xff, 0xff, 0xcc),
//			Color.rgb(0x00, 0x66, 0xcc),
//			Color.rgb(0x33, 0x99, 0x33),
//			Color.rgb(0xff, 0xcc, 0x33),
//			Color.rgb(0x33, 0x66, 0x99),
//			Color.rgb(0xff, 0x99, 0x00),
//			Color.rgb(0xff, 0x66, 0x00),
//			Color.rgb(0xcc, 0xcc, 0x33),
//			Color.rgb(0x99, 0xcc, 0x33),
//			Color.rgb(0x00, 0x99, 0xcc),
//			Color.rgb(0x99, 0xcc, 0xcc),
//			Color.rgb(0xff, 0x00, 0x33),
//			Color.rgb(0x33, 0x33, 0x99),
//			Color.rgb(0xcc, 0xcc, 0x00),
//			Color.rgb(0x33, 0xcc, 0x99)};

    private int[] nightColors = new int[]{
            0xffffffcc, 0xffccffff, 0xffffcccc,
            0xffffff99, 0xffccccff, 0xffff9966,
            0xffcccccc, 0xffccffcc, 0xff99cccc,
            0xffccff99, 0xff99ccff, 0xff66cccc,
            0xff66ccff, 0xffccff66
    };

    private int reserveColor(int c) {
        //c^=0xffffffff;
        //return Color.rgb((c>>16)&0xff, (c>>8)&0xff, c&0xff);
        return c ^ 0xffffff;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);

        AssetManager mgr = getAssets();//得到AssetManager
        tf = Typeface.createFromAsset(mgr, "fonts/fontss.TTF");//根据路径得到Typeface

        initUi();
        myPerf = this.getSharedPreferences("com.example.react_preferences", MODE_PRIVATE);<commit_msg>Update MainActivity.java<commit_after>package com.deng.flashingmath;

import java.util.HashMap;
import java.util.Random;

import com.umeng.analytics.MobclickAgent;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.AssetManager;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

    private TextView num1Tv;
    private TextView num2Tv;
    private TextView opTv;
    private TextView resultTv;
    private TextView equalsOp;
    private ProgressBar progress;
    private RelativeLayout container;
    private TableLayout table;
    private TextView bestScoreTv;
    private TextView currentScoreTv;
    private TextView title;
    private TextView bestTitle;
    private TextView scoreTitle;
    private TextView numOfRightTv;
    private CustomProgressDialog loadingPd;

    private int SLEEP_TIME = 20;
    private int MAX_SLEEP_TIME = 20;
    private int numOfRight = 0;

    private int currentScore = 0;
    private int highestSore = 0;
    private Button[] btns = new Button[9];

    int[] nums = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6};
    char[] ops = new char[]{'+', '-', '×', '÷', '+', '-', '×', '÷', '×', '÷'};

    private ExpressionThread myThread;
    private SharedPreferences myPerf;
    private Expression currentExpression;

    private SoundPool soundPool;
    private int buttonRightSoundId = -1;
    private int buttonSoundId = -1;
    private int victorySoundId = -1;
    private boolean soundEnabled = true;
    private boolean viberateEanbled = true;
    private Typeface tf;
    private Vibrator mVibrator;  //声明一个振动器对象
    private Handler myUiHandler = new Handler() {
        public void handleMessage(Message m) {
            if (m.what == 1111) {
                num1Tv.setText(currentExpression.num1 + "");
                num2Tv.setText(currentExpression.num2 + "");
                opTv.setText(currentExpression.op + "");
                resultTv.setText("?");
                resultTv.setTextColor(Color.rgb(0xff, 0xff, 0xff));
                progress.setProgress(100);
            } else if (m.what == 1112) {
                progress.setProgress((Integer) m.obj);
                //if((Integer) m.obj==90)autoTest();
            } else if (m.what == 1113) {
                showDialog();//游戏结束
            }
        }
    };

    private int[] nightColors = new int[]{
            0xffffffcc, 0xffccffff, 0xffffcccc,
            0xffffff99, 0xffccccff, 0xffff9966,
            0xffcccccc, 0xffccffcc, 0xff99cccc,
            0xffccff99, 0xff99ccff, 0xff66cccc,
            0xff66ccff, 0xffccff66
    };

    private int reserveColor(int c) {
        return c ^ 0xffffff;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);

        AssetManager mgr = getAssets();//得到AssetManager
        tf = Typeface.createFromAsset(mgr, "fonts/fontss.TTF");//根据路径得到Typeface

        initUi();
        myPerf = this.getSharedPreferences("com.example.react_preferences", MODE_PRIVATE);
{'fraction_non_alphanumeric': 0.11158146097905135, 'fraction_numerical': 0.03234559861065885, 'mean_word_length': 3.246082949308756, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5890055', 'n_tokens_mistral': 3122, 'n_tokens_neox': 2885, 'n_words': 655}