14.06.2011

setState

posted by Karsten

//Send messages to View/Activity thread public void setState(int mode) { synchronized (mSurfaceHolder) { setState(mode, null); } } public void setState(int mode, CharSequence message) { synchronized (mSurfaceHolder) { mMode = mode; if (mMode == STATE_RUNNING) { Message msg = mHandler.obtainMessage(); Bundle b = new Bundle(); b.putString("text", ""); b.putInt("viz", View.INVISIBLE); b.putBoolean("showAd", false); msg.setData(b); mHandler.sendMessage(msg); } else { Message msg = mHandler.obtainMessage(); Bundle b = new Bundle(); Resources res = mContext.getResources(); CharSequence str = ""; if (mMode == STATE_READY) str = res.getText(R.string.mode_ready); else if (mMode == STATE_PAUSE) str = res.getText(R.string.mode_pause); else if (mMode == STATE_LOSE) str = res.getText(R.string.mode_lose); else if (mMode == STATE_WIN) { str = res.getText(R.string.mode_win); } if (message != null) { str = message + "n" + str; } b.putString("text", str.toString()); b.putInt("viz", View.VISIBLE); msg.setData(b); mHandler.sendMessage(msg); } } }

Share

Place your comment

Please fill your data and comment below.
Name
Email
Website
Your comment