<commit_before>package com.unipad.common;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;

import com.unipad.AppContext;
import com.unipad.IOperateGame;
import com.unipad.brain.AbsBaseGameService;
import com.unipad.brain.App;
import com.unipad.brain.BasicActivity;
import com.unipad.brain.R;
import com.unipad.brain.absPic.view.AbsFigureFragment;
import com.unipad.brain.home.bean.RuleGame;
import com.unipad.brain.home.dao.HomeGameHandService;
import com.unipad.brain.number.NumberRightFragment;
import com.unipad.brain.portraits.view.HeadPortraitFragment;
import com.unipad.brain.virtual.VirtualRightFragment;
import com.unipad.brain.words.view.WordRightFragment;
import com.unipad.common.widget.HIDDialog;
import com.unipad.io.mina.SocketThreadManager;
import com.unipad.observer.IDataObserver;
import com.unipad.utils.LogUtil;
import com.unipad.utils.ToastUtil;

/**
 * Created by Wbj on 2016/4/7.
 */
public class CommonActivity extends BasicActivity implements IDataObserver,IOperateGame{
    private CommonFragment mCommonFragment = new CommonFragment();
    private AbsBaseGameService service;
    public String getMatchId() {
        return matchId;
    }
    private Handler handler;
    private BasicCommonFragment gameFragment;
    public void setMatchId(String matchId) {
        this.matchId = matchId;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    private String matchId;

    private String projectId;

    private HIDDialog dialog;
    long startTime;

    private static final int STRAT_GAME = 0;
    private static final int DOWNLOAD_QUESTION = 1;
    private static final int PAUSE_GAME = 2;
    private static final int RESTAT_GAME = 3;
    private static final int FINISH_GAME = 4;
    private static final int INIT_DATA_FINISH = 5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.common_aty);
        startTime = System.currentTimeMillis();
        matchId = getIntent().getStringExtra("matchId");
        projectId = getIntent().getStringExtra("projectId");
        service = (AbsBaseGameService) AppContext.instance().getGameServiceByProject(projectId);
        service.setOperateGame(this);
        handler  = new Handler() {
            @Override
            public void dispatchMessage(Message msg) {
                int what = msg.what;
                switch (msg.what) {
                    case STRAT_GAME:
                        HIDDialog.dismissAll();
                        gameFragment.startGame();
                        mCommonFragment.startGame();
                        break;
                    case DOWNLOAD_QUESTION:
                        if (dialog == null) {
                            dialog = ToastUtil.createTipDialog(CommonActivity.this, Constant.SHOW_GAME_PAUSE, "下载试题中");
                        }
                        else {
                            ((TextView)dialog.findViewById(R.id.dialog_tip_content)).setText("下载试题中");
                        }
                        dialog.show();
                        break;

                    case PAUSE_GAME:
                        if (dialog == null) {
                            dialog = ToastUtil.createTipDialog(CommonActivity.this, Constant.SHOW_GAME_PAUSE, "比赛暂停");
                        }
                        else {
                            ((TextView)dialog.findViewById(R.id.dialog_tip_content)).setText("比赛暂停");
                        }
                        dialog.show();
                        gameFragment.pauseGame();
                        mCommonFragment.pauseGame();
                        break;
                    case RESTAT_GAME:
                        HIDDialog.dismissAll();
                        gameFragment.reStartGame();
                        mCommonFragment.reStartGame();
                        break;
                    case FINISH_GAME:
                        gameFragment.finishGame();
                        mCommonFragment.finishGame();
                        break;
                    case INIT_DATA_FINISH:
                        gameFragment.initDataFinished();
                        mCommonFragment.initDataFinished();
                        ((TextView) HIDDialog.getExistDialog(Constant.SHOW_GAME_PAUSE).findViewById(R.id.dialog_tip_content)).setText("等待裁判准备开始");
                        break;
                }
            }
        };

        handler.post(new Runnable() {
                         @Override
                         public void run() {
                             dialog = ToastUtil.createTipDialog(CommonActivity.this, Constant.SHOW_GAME_PAUSE, "签到，等待裁判下发试题");
                             dialog.show();
                         }
                     }
        );
                new Thread(new Runnable() {<commit_msg>gongkna<commit_after>package com.unipad.common;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;

import com.unipad.AppContext;
import com.unipad.IOperateGame;
import com.unipad.brain.AbsBaseGameService;
import com.unipad.brain.App;
import com.unipad.brain.BasicActivity;
import com.unipad.brain.R;
import com.unipad.brain.absPic.view.AbsFigureFragment;
import com.unipad.brain.home.bean.RuleGame;
import com.unipad.brain.home.dao.HomeGameHandService;
import com.unipad.brain.number.NumberRightFragment;
import com.unipad.brain.portraits.view.HeadPortraitFragment;
import com.unipad.brain.virtual.VirtualRightFragment;
import com.unipad.brain.words.view.WordRightFragment;
import com.unipad.common.widget.HIDDialog;
import com.unipad.io.mina.SocketThreadManager;
import com.unipad.observer.IDataObserver;
import com.unipad.utils.LogUtil;
import com.unipad.utils.ToastUtil;

/**
 * Created by Wbj on 2016/4/7.
 */
public class CommonActivity extends BasicActivity implements IDataObserver,IOperateGame{
    private CommonFragment mCommonFragment = new CommonFragment();
    private AbsBaseGameService service;
    public String getMatchId() {
        return matchId;
    }
    private Handler handler;
    private BasicCommonFragment gameFragment;
    public void setMatchId(String matchId) {
        this.matchId = matchId;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    private String matchId;

    private String projectId;

    private HIDDialog dialog;
    long startTime;

    private static final int STRAT_GAME = 0;
    private static final int DOWNLOAD_QUESTION = 1;
    private static final int PAUSE_GAME = 2;
    private static final int RESTAT_GAME = 3;
    private static final int FINISH_GAME = 4;
    private static final int INIT_DATA_FINISH = 5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.common_aty);
        startTime = System.currentTimeMillis();
        matchId = getIntent().getStringExtra("matchId");
        projectId = getIntent().getStringExtra("projectId");
        service = (AbsBaseGameService) AppContext.instance().getGameServiceByProject(projectId);
        service.setOperateGame(this);
        handler  = new Handler() {
            @Override
            public void dispatchMessage(Message msg) {
                int what = msg.what;
                switch (msg.what) {
                    case STRAT_GAME:
                        HIDDialog.dismissAll();
                        gameFragment.startGame();
                        mCommonFragment.startGame();
                        break;
                    case DOWNLOAD_QUESTION:
                        if (dialog == null) {
                            dialog = ToastUtil.createTipDialog(CommonActivity.this, Constant.SHOW_GAME_PAUSE, "下载试题中");
                        }
                        else {
                            ((TextView)dialog.findViewById(R.id.dialog_tip_content)).setText("下载试题中");
                        }
                        dialog.show();
                        break;

                    case PAUSE_GAME:
                        if (dialog == null) {
                            dialog = ToastUtil.createTipDialog(CommonActivity.this, Constant.SHOW_GAME_PAUSE, "比赛暂停");
                        }
                        else {
                            ((TextView)dialog.findViewById(R.id.dialog_tip_content)).setText("比赛暂停");
                        }
                        dialog.show();
                        gameFragment.pauseGame();
                        mCommonFragment.pauseGame();
                        break;
                    case RESTAT_GAME:
                        HIDDialog.dismissAll();
                        gameFragment.reStartGame();
                        mCommonFragment.reStartGame();
                        break;
                    case FINISH_GAME:
                        gameFragment.finishGame();
                        mCommonFragment.finishGame();
                        break;
                    case INIT_DATA_FINISH:
                        gameFragment.initDataFinished();
                        mCommonFragment.initDataFinished();
                        ((TextView) HIDDialog.getExistDialog(Constant.SHOW_GAME_PAUSE).findViewById(R.id.dialog_tip_content)).setText("等待裁判准备开始");
                        break;
                }
            }
        };

       /** handler.post(new Runnable() {
                         @Override
                         public void run() {
                             dialog = ToastUtil.createTipDialog(CommonActivity.this, Constant.SHOW_GAME_PAUSE, "签到，等待裁判下发试题");
                             dialog.show();
                         }
                     }
        );*/
                new Thread(new Runnable() {
{'fraction_non_alphanumeric': 0.08345591840737472, 'fraction_numerical': 0.0023536334215945864, 'mean_word_length': 1.7659343639815568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1559664', 'n_tokens_mistral': 2774, 'n_tokens_neox': 2619, 'n_words': 482}