private void updateRingtoneName(int type, Preference preference, int msg) { if (preference == null) return; Context context = getActivity(); if (context == null) return; Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type); CharSequence summary = context.getString(com.android.internal.R.string.ringtone_unknown); // Is it a silent ringtone? if (ringtoneUri == null) { summary = context.getString(com.android.internal.R.string.ringtone_silent); } else { // Fetch the ringtone title from the media provider try { Cursor cursor = context .getContentResolver() .query(ringtoneUri, new String[] {MediaStore.Audio.Media.TITLE}, null, null, null); if (cursor != null) { if (cursor.moveToFirst()) { summary = cursor.getString(0); } cursor.close(); } } catch (SQLiteException sqle) { // Unknown title for the ringtone } } mHandler.sendMessage(mHandler.obtainMessage(msg, summary)); }
public void alarmFacebookUserComming(Message callbackMessage) { Log.d(TAG, "alarmFacebookUserComming"); Message msg = handler.obtainMessage(FACEBOOK_FRIENDS_GET); if (callbackMessage != null) { msg.getData().putParcelable(CALLBACK, callbackMessage); msg.getData().putLong("hisuid", callbackMessage.getData().getLong("hisuid", -1)); } handler.sendMessageDelayed(msg, 1 * 1000); long nexttime = System.currentTimeMillis() + getFriendsTimeout() * 1000L; if (SNSService.TEST_LOOP) { nexttime = System.currentTimeMillis() + 90 * 1000; } AlarmManager alarmMgr = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(); i.setClassName("com.ast.free", "com.ast.free.service.SNSService"); i.setAction("com.ast.free.intent.action.FACEBOOK_USER"); PendingIntent userpi = PendingIntent.getService( mContext.getApplicationContext(), 0, i, PendingIntent.FLAG_CANCEL_CURRENT); alarmMgr.set(AlarmManager.RTC_WAKEUP, nexttime, userpi); }
@Override public void run() { // TODO Auto-generated method stub super.run(); if (url.equals(ForceTvUtils.paramurl)) { LogUtils.write(TAG, "no switch_chan"); Message msg = handler.obtainMessage(); msg.obj = playurl; msg.what = ForceTvsuc; handler.sendMessage(msg); } else { String xml = HttpClientHelper.DoGet(url); if (isrun) { LogUtils.write(TAG, "" + xml); boolean flag = DomUtils.ParseForceTvXml(xml); Message msg = handler.obtainMessage(); if (flag) { msg.obj = playurl; msg.what = ForceTvsuc; ForceTvUtils.paramurl = url; } else { msg.what = ForceTvfail; } handler.sendMessage(msg); } } }
@Override public void run() { ArrayList<NameValuePair> postData = new ArrayList<NameValuePair>(); postData.add(new BasicNameValuePair("userId", String.valueOf(mUserId))); postData.add(new BasicNameValuePair("userName", mUserName)); try { HttpResponse response = Util.sendPost(URL, postData); String res = Util.convertResponseToString(response); if (Config.DEBUG) Log.d(Constants.APP_NAME, "[Follow] response : " + res); if (res != null) { JSONObject json = new JSONObject(res); if (!json.getBoolean("error")) { Message msg = mHandler.obtainMessage(Constants.USER_FOLLOWED); mHandler.sendMessage(msg); } else { Message msg = mHandler.obtainMessage(Constants.USER_FOLLOW_FAILED); mHandler.sendMessage(msg); } } } catch (Exception e) { e.printStackTrace(); Message msg = mHandler.obtainMessage(Constants.USER_FOLLOW_FAILED); mHandler.sendMessage(msg); } }
/** * Performs the appropriate action for a post-dial char, but does not notify application. returns * false if the character is invalid and should be ignored */ private boolean processPostDialChar(char c) { if (PhoneNumberUtils.is12Key(c)) { owner.cm.sendDtmf(c, h.obtainMessage(EVENT_DTMF_DONE)); } else if (c == PhoneNumberUtils.PAUSE) { setPostDialState(PostDialState.PAUSE); // TBD check why it is not in Gsm /* * From TS 22.101: It continues... Upon the called party answering * the UE shall send the DTMF digits automatically to the network * after a delay of 3 seconds(plus/minus 20 %). The digits shall be * sent according to the procedures and timing specified in 3GPP TS * 24.008 [13]. The first occurrence of the * "DTMF Control Digits Separator" shall be used by the ME to * distinguish between the addressing digits (i.e. the phone number) * and the DTMF digits. Upon subsequent occurrences of the * separator, the UE shall pause again for 3 seconds before sending * any further DTMF digits. */ // TBD 3s for gsm n 2s for cdma check specs h.sendMessageDelayed(h.obtainMessage(EVENT_PAUSE_DONE), PAUSE_DELAY_MILLIS); } else if (c == PhoneNumberUtils.WAIT) { setPostDialState(PostDialState.WAIT); } else if (c == PhoneNumberUtils.WILD) { setPostDialState(PostDialState.WILD); } else { return false; } return true; }
@Override public void run() { this.setName("V8Engine"); System.loadLibrary("bgjs"); if (BuildConfig.DEBUG) { try { sleep(30); if (DEBUG) { Log.d(TAG, "Debugger can connect now"); } } catch (InterruptedException e) { Log.e(TAG, "Cannot sleep while waiting for debugger to settle", e); } } Looper.prepare(); mHandler = new Handler(this); initializeV8(assetManager); assetManager = null; ClientAndroid.load(mNativePtr, scriptPath); ClientAndroid.run(mNativePtr); mHandler.sendMessageAtFrontOfQueue(mHandler.obtainMessage(MSG_READY)); mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CLEANUP), DELAY_CLEANUP); Looper.loop(); }
private void evaluatePredict(int mask) { Leg.i(TAG, "evaluatePredict(" + mask + ")"); calculatePredict(mask); Leg.i(TAG, "calculated predict: " + mPredict); if ((mPredict & START_PRD_SB_SV) == START_PRD_SB_SV) { Leg.i(TAG, "prediction: foreground surface"); Surface surface = mSurfaceHolder.getSurface(); if (surface != null && surface.isValid()) { mPlaybackService.setForegroundSurfaceHolder(mSurfaceHolder); } else { mPlaybackService.setForegroundSurfaceHolder(null); } } if ((mPredict & START_PRD_SI_SB_SV) == START_PRD_SI_SB_SV) { Leg.i(TAG, "prediction: send start playback message"); mHandler.removeMessages(START_PLAY_BACK); mHandler.removeMessages(STOP_PLAY_BACK); if (!mPlaybackService.isPlaying()) { mHandler.obtainMessage(STOP_PLAY_BACK).sendToTarget(); mHandler.obtainMessage(START_PLAY_BACK).sendToTarget(); } } }
public boolean check_connect_status() { try { // Message ma=main_thread_handler.obtainMessage(1,"try!"); // main_thread_handler.sendMessage(ma); ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo network_info = cm.getActiveNetworkInfo(); if (network_info == null || network_info.isConnected() == false) { // Toast.makeText(this, "網路狀態:關閉", Toast.LENGTH_SHORT).show(); Message m = main_thread_handler.obtainMessage(4, "請開啟網路"); main_thread_handler.sendMessage(m); return false; } else { // Toast.makeText(this, "網路狀態:開啟", Toast.LENGTH_SHORT).show(); } if (connect_to_server("/project/mobilephone/check_connect.php", null).equals("1")) { // Toast.makeText(this, "可連接至主機", Toast.LENGTH_SHORT).show(); return true; } else { // Toast.makeText(this, "not connect", Toast.LENGTH_SHORT).show(); return false; } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { Message m = main_thread_handler.obtainMessage(4, "無法連接至主機"); main_thread_handler.sendMessage(m); e.printStackTrace(); } return false; }
private void pollForHrefAndImageSrcOnUiThread( final String expectedHref, final String expectedAnchorText, final String expectedImageSrc) throws Throwable { pollUiThread( new Callable<Boolean>() { @Override public Boolean call() { AwContents.HitTestData data = mAwContents.getLastHitTestResult(); return stringEquals(expectedHref, data.href) && stringEquals(expectedAnchorText, data.anchorText) && stringEquals(expectedImageSrc, data.imgSrc); } }); Handler dummyHandler = new Handler(); final Message focusNodeHrefMsg = dummyHandler.obtainMessage(); final Message imageRefMsg = dummyHandler.obtainMessage(); ThreadUtils.runOnUiThreadBlocking( new Runnable() { @Override public void run() { mAwContents.requestFocusNodeHref(focusNodeHrefMsg); mAwContents.requestImageRef(imageRefMsg); } }); assertEquals(expectedHref, focusNodeHrefMsg.getData().getString("url")); assertEquals(expectedAnchorText, focusNodeHrefMsg.getData().getString("title")); assertEquals(expectedImageSrc, focusNodeHrefMsg.getData().getString("src")); assertEquals(expectedImageSrc, imageRefMsg.getData().getString("url")); }
public void sendMessage(String destination, String message) { try { BluetoothSocket myBsock = btSockets.get(destination); if (myBsock != null) { OutputStream outStream = myBsock.getOutputStream(); byte[] stringAsBytes = (message + " ").getBytes(); stringAsBytes[stringAsBytes.length - 1] = 0; // Add a stop marker outStream.write(stringAsBytes); DebugLog.i(TAG, "successful sendMessage - Dest:" + destination + ", Msg:" + message); Message msg = mHandler.obtainMessage(DynamicAppBluetooth.MESSAGE_WRITE); Bundle bundle = new Bundle(); bundle.putBoolean(DynamicAppBluetooth.SEND_RESULT, true); msg.setData(bundle); mHandler.sendMessage(msg); } else { Message msg = mHandler.obtainMessage(DynamicAppBluetooth.MESSAGE_WRITE); Bundle bundle = new Bundle(); bundle.putBoolean(DynamicAppBluetooth.SEND_RESULT, false); msg.setData(bundle); mHandler.sendMessage(msg); } } catch (IOException e) { DebugLog.e(TAG, "IOException in sendMessage - Dest:" + destination + ", Msg:" + message); Message msg = mHandler.obtainMessage(DynamicAppBluetooth.MESSAGE_WRITE); Bundle bundle = new Bundle(); bundle.putBoolean(DynamicAppBluetooth.SEND_RESULT, false); msg.setData(bundle); mHandler.sendMessage(msg); } return; }
@Override public boolean handleMessage(Message msg) { switch (msg.what) { case MSG_GET_USERINFO_COMPLATE: mUserInfo = mUserService.getUserInfo(mUserid); if (mUserInfo == null) { // 如果没有找到这个userInfo,就发送错误消息 mMsgHandler.obtainMessage(BaseService.MSG_ERROR).sendToTarget(); return true; } updateUserInfo(); break; case UserService.MSG_SYNC_USERINFO_SUCCESS: case UserService.MSG_SYNC_USERINFO_FAILD: mMsgHandler.obtainMessage(MSG_GET_USERINFO_COMPLATE).sendToTarget(); break; case BaseService.MSG_ERROR: // 当没有网络的时候允许 if (msg.obj != null && msg.obj instanceof NoConnectionError) { mMsgHandler.obtainMessage(MSG_GET_USERINFO_COMPLATE).sendToTarget(); break; } // TODO 发生错误! showToast(getString(R.string.personalinfo_get_userinfo_faild)); finish(); break; case UserService.MSG_UPDATE_USERINFO_FAILD: showToast(R.string.personalinfo_update_faild); break; default: break; } return true; }
public void run() { try { TransferActivity.bdt.createServer(); XML info = new XML(); byte[] receive = TransferActivity.bdt.read(); Log.i(TAG, "1"); String xml = info.productSentenceXML("转账成功"); Log.i(TAG, "2"); TransferActivity.bdt.write(xml); Log.i(TAG, "3"); Message msg = handler.obtainMessage(); msg.what = 1; Log.i(TAG, "4"); msg.obj = receive; Log.i(TAG, "5"); msg.sendToTarget(); try { TransferActivity.bdt.close(); } catch (Exception e) { Log.i(TAG, "已关闭连接"); } Log.i(TAG, "7"); } catch (Exception e) { Message msg = handler.obtainMessage(); msg.what = 0; msg.sendToTarget(); TransferActivity.bdt.close(); } }
void dispatchResumeTag(Object tag, long millis) { if (millis > 0) { handler.sendMessageDelayed(handler.obtainMessage(TAG_RESUME, tag), millis); } else { handler.sendMessage(handler.obtainMessage(TAG_RESUME, tag)); } }
void dispatchSubmit(Action<?> action, long delayMillis) { if (delayMillis > 0) { handler.sendMessageDelayed(handler.obtainMessage(REQUEST_SUBMIT, action), delayMillis); } else { handler.sendMessage(handler.obtainMessage(REQUEST_SUBMIT, action)); } }
/** * Record the detailed state of a network, and if it is a change from the previous state, send a * notification to any listeners. * * @param state the new @{code DetailedState} * @param reason a {@code String} indicating a reason for the state change, if one was supplied. * May be {@code null}. * @param extraInfo optional {@code String} providing extra information about the state change * @param simId 0 for sim1 and 1 for sim2 */ public void setDetailedStateGemini( NetworkInfo.DetailedState state, String reason, String extraInfo, int simId) { if (DBG) log( "setDetailed state, old =" + mNetworkInfo.getDetailedState() + " and new state=" + state + " simId is " + simId); if (state != mNetworkInfo.getDetailedState()) { boolean wasConnecting = (mNetworkInfo.getState() == NetworkInfo.State.CONNECTING); String lastReason = mNetworkInfo.getReason(); /* * If a reason was supplied when the CONNECTING state was entered, and no * reason was supplied for entering the CONNECTED state, then retain the * reason that was supplied when going to CONNECTING. */ if (wasConnecting && state == NetworkInfo.DetailedState.CONNECTED && reason == null && lastReason != null) reason = lastReason; mNetworkInfo.setDetailedStateGemini(state, reason, extraInfo, simId); Message msg = mTarget.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); } else if (reason != null && (reason.equals(PhoneConstants.REASON_NO_SUCH_PDP) || reason.equals(Phone.REASON_APN_FAILED)) && state == DetailedState.DISCONNECTED) { mNetworkInfo.setDetailedStateGemini(state, reason, extraInfo, simId); Message msg = mTarget.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); } }
private void sendCommand(String[] command, int msg) { if (FeatureOption.MTK_GEMINI_SUPPORT) { mGeminiPhone.invokeOemRilRequestStringsGemini( command, mCommandHander.obtainMessage(msg), PhoneConstants.GEMINI_SIM_1); } else { mPhone.invokeOemRilRequestStrings(command, mCommandHander.obtainMessage(msg)); } }
/** * Sets the game mode. That is, whether we are running, paused, in the failure state, in the * victory state, etc. * * @param mode one of the STATE_* constants * @param message string to add to screen or null */ public void setState(int mode, CharSequence message) { /* * This method optionally can cause a text message to be displayed * to the user when the mode changes. Since the View that actually * renders that text is part of the main View hierarchy and not * owned by this thread, we can't touch the state of that View. * Instead we use a Message + Handler to relay commands to the main * thread, which updates the user-text View. */ synchronized (mSurfaceHolder) { System.out.println("State transition " + mMode + "->" + mode); mMode = mode; if (mMode == STATE_RUNNING) { Message msg = mHandler.obtainMessage(); Bundle b = new Bundle(); b.putString("text", ""); b.putInt("viz", View.INVISIBLE); b.putInt("mode", mMode); msg.setData(b); mHandler.sendMessage(msg); } else { mRotating = 0; mEngineFiring = false; 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.getString(R.string.mode_win_prefix) + mWinsInARow + " " + res.getString(R.string.mode_win_suffix); } if (message != null) { str = message + "\n" + str; } if (mMode == STATE_LOSE) mWinsInARow = 0; Message msg = mHandler.obtainMessage(); Bundle b = new Bundle(); b.putString("text", str.toString()); b.putInt("viz", View.VISIBLE); b.putInt("mode", mMode); b.putInt("score", mScore); msg.setData(b); mHandler.sendMessage(msg); } } }
/** * Sets a TTY mode option.{@link Phone#setTTYMode(int, Message)}, {@link * GeminiPhone#setTTYModeGemini(int, Message, int)} * * @param phone * @param radioMode * @param handler * @param messageId */ public static void setTTYMode(Phone phone, int radioMode, Handler handler, int messageId) { if (GeminiUtils.isGeminiSupport()) { GeminiPhone gPhone = (GeminiPhone) phone; final int[] geminiSlots = GeminiUtils.getSlots(); for (int gs : geminiSlots) { gPhone.setTTYModeGemini(radioMode, handler.obtainMessage(messageId), gs); } } else { phone.setTTYMode(radioMode, handler.obtainMessage(messageId)); } }
/** * Configures the service according to a ringer mode. * * @param ringerMode The device ringer mode. */ private void configureForRingerMode(int ringerMode) { if (ringerMode == AudioManager.RINGER_MODE_SILENT) { // use only an earcon to announce ringer state change mHandler.obtainMessage(WHAT_PLAY_EARCON, INDEX_RINGER_SILENT, 0).sendToTarget(); } else if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) { // use only an earcon to announce ringer state change mHandler.obtainMessage(WHAT_PLAY_EARCON, INDEX_RINGER_VIBRATE, 0).sendToTarget(); } else if (ringerMode == AudioManager.RINGER_MODE_NORMAL) { // use only an earcon to announce ringer state change mHandler.obtainMessage(WHAT_PLAY_EARCON, INDEX_RINGER_NORMAL, 0).sendToTarget(); } }
@Override public void onRun(String action, JsonElement config) { // Run on handler thread if (ACTION_ARCHIVE.equals(action)) { handler.obtainMessage(ARCHIVE, config).sendToTarget(); } else if (ACTION_UPLOAD.equals(action)) { handler.obtainMessage(UPLOAD, config).sendToTarget(); } else if (ACTION_UPDATE.equals(action)) { handler.obtainMessage(UPDATE, config).sendToTarget(); } }
public synchronized void stopReverseTether(String iface) { NetworkUtils.stopDhcp(iface); mLinkProperties.clear(); mNetworkInfo.setIsAvailable(false); mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, null); Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); }
public void update(int current, int total) { Log.v(TAG.MMI, "[DmMmiProgress] update " + DmService.sSessionType); if (DmService.sSessionType == DmService.SESSION_TYPE_FUMO || DmService.sSessionType == DmService.SESSION_TYPE_LAWMO) { Handler h = DmService.getInstance().mHandler; h.sendMessage(h.obtainMessage(IDmPersistentValues.MSG_DLPKGUPGRADE, current, total)); } else if (DmService.sSessionType == DmService.SESSION_TYPE_SCOMO) { Handler h = DmService.getInstance().getScomoHandler(); h.sendMessage(h.obtainMessage(IDmPersistentValues.MSG_SCOMO_DL_PKG_UPGRADE, current, total)); } else { Log.w(TAG.MMI, "unknown session type in DmMmiProgress.update"); return; } }
private Message getNext() { txCount++; Intent intent = new Intent(); intent.setAction("uk.ac.cam.cusf.intent.ALIVE"); context.sendBroadcast(intent); if (landed) { return handler.obtainMessage(RTTY); } else if (txCount % (TX_RATIO + 1) == TX_RATIO) { return handler.obtainMessage(SSTV); } else { return handler.obtainMessage(RTTY); } }
/** * Start the ConnectedThread to begin managing a Bluetooth connection * * @param socket The BluetoothSocket on which the connection was made * @param device The BluetoothDevice that has been connected */ public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) { if (D) Log.d(TAG, "connected"); // Cancel the thread that completed the connection if (mConnectThread != null) { mConnectThread.cancel(); mConnectThread = null; } // Cancel any thread currently running a connection if (mConnectedThread != null) { mConnectedThread.cancel(); mConnectedThread = null; } // Cancel the accept thread because we only want to connect to one device if (mAcceptThread != null) { mAcceptThread.cancel(); mAcceptThread = null; } // Start the thread to manage the connection and perform transmissions mConnectedThread = new ConnectedThread(socket); mConnectedThread.start(); // Send the name of the connected device back to the UI Activity // mHandler.obtainMessage(),Returns a new Message from the global message pool, and // also sets the what member of the returned Message. // 為msg 貼上what的tag Message msg = mHandler.obtainMessage(MainService.MESSAGE_DEVICE_NAME); Log.i(TAG, "device.getName() : " + device.getName()); DeviceMappingAdapter deviceMappingAdapter = new DeviceMappingAdapter(mainContext); String deviceSn = deviceMappingAdapter.getDeviceSnById(device.getName()); if (deviceSn != null) { Log.i(TAG, "泰博跑到陽明血壓計"); setState(STATE_LISTEN); mHandler.obtainMessage(MainService.MESSAGE_CONNECTION_CLOSE, 1, -1).sendToTarget(); } else { Bundle bundle = new Bundle(); bundle.putString(MainService.DEVICE_NAME, device.getName()); msg.setData(bundle); mHandler.sendMessage(msg); setState(STATE_CONNECTED); } }
public void FoundNameCallback(String busName) { Log.e("SimpleClient", String.format("Found name %s", busName)); Message msg = handler.obtainMessage(0); msg.arg1 = BUSNAMEITEM_FOUND; msg.obj = new BusNameItem(busName, true); handler.sendMessage(msg); }
/** * Set the current state of the chat connection * * @param state An integer defining the current connection state */ private synchronized void setState(int state) { if (D) Log.d(TAG, "setState() " + mState + " -> " + state); mState = state; // Give the new state to the Handler so the UI Activity can update mHandler.obtainMessage(BluetoothChat.MESSAGE_STATE_CHANGE, state, -1).sendToTarget(); }
/** * Start the ConnectedThread to begin managing a Bluetooth connection * * @param socket The BluetoothSocket on which the connection was made * @param device The BluetoothDevice that has been connected */ public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) { if (D) Log.d(TAG, "connected"); // Cancel the thread that completed the connection if (mConnectThread != null) { mConnectThread.cancel(); mConnectThread = null; } // Cancel any thread currently running a connection if (mConnectedThread != null) { mConnectedThread.cancel(); mConnectedThread = null; } // Cancel the accept thread because we only want to connect to one device if (mAcceptThread != null) { mAcceptThread.cancel(); mAcceptThread = null; } // Start the thread to manage the connection and perform transmissions mConnectedThread = new ConnectedThread(socket); mConnectedThread.start(); // Send the name of the connected device back to the UI Activity Message msg = mHandler.obtainMessage(BluetoothChat.MESSAGE_DEVICE_NAME); Bundle bundle = new Bundle(); bundle.putString(BluetoothChat.DEVICE_NAME, device.getName()); msg.setData(bundle); mHandler.sendMessage(msg); setState(STATE_CONNECTED); }
private void save() { final String oldName; final boolean oldHide; final Context context = this; Log.d(TAG, "Saving context!"); // Must have a name if (_name.length() <= 0) { Log.w(TAG, "Attempted to save with no name"); Toast.makeText(context, R.string.ERR_savecontext_baddata, Toast.LENGTH_LONG).show(); return; } if (_context == null) { Log.d(TAG, "Creating a new context"); _context = new TodoContext(_name.getText().toString(), 0, _hide.isChecked()); oldName = _context.getName(); oldHide = _context.isHidden(); } else { Log.d(TAG, "Updating an existing context"); oldName = _context.setName(_name.getText().toString()); oldHide = _context.setHidden(_hide.isChecked()); } final ProgressDialog p = ProgressDialog.show(context, "", getString(R.string.MSG_saving), true); TracksAction a = new TracksAction( TracksAction.ActionType.UPDATE_CONTEXT, _context, new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case TracksCommunicator.SUCCESS_CODE: Log.d(TAG, "Saved successfully"); _context.setOutdated(false); TodoContext.save(_context); p.dismiss(); setResult(SAVED); finish(); break; case TracksCommunicator.UPDATE_FAIL_CODE: Log.w(TAG, "Save failed"); _context.setOutdated(true); TodoContext.save(_context); p.dismiss(); // Toast.makeText(context, R.string.ERR_savecontext_general, // Toast.LENGTH_LONG).show(); // Reset task data to stay synced with server. // _context.setName(oldName); // _context.setHidden(oldHide); setResult(SAVED); finish(); break; } } }); _commHandler.obtainMessage(0, a).sendToTarget(); }
protected boolean onTap(int index) { // System.out.println("item onTap: "+index); Bitmap[] bmps = new Bitmap[3]; if (index % 2 == 0) { try { bmps[0] = BitmapFactory.decodeStream(mContext.getAssets().open("marker1.png")); bmps[1] = BitmapFactory.decodeStream(mContext.getAssets().open("marker2.png")); bmps[2] = BitmapFactory.decodeStream(mContext.getAssets().open("marker3.png")); } catch (IOException e) { e.printStackTrace(); } } else { try { bmps[2] = BitmapFactory.decodeStream(mContext.getAssets().open("marker1.png")); bmps[1] = BitmapFactory.decodeStream(mContext.getAssets().open("marker2.png")); bmps[0] = BitmapFactory.decodeStream(mContext.getAssets().open("marker3.png")); } catch (IOException e) { e.printStackTrace(); } } // pop.showPopup(bmps, getItem(index).getPoint(), 32); // if (null == mToast) // mToast = Toast.makeText(mContext, getItem(index).getTitle(), Toast.LENGTH_SHORT); // else mToast.setText(getItem(index).getTitle()); // mToast.show(); if (mH != null) { mH.dispatchMessage(mH.obtainMessage(LocationOverlayDemo.MSG_HANDLE_ITEM_TOUCH + index)); } return true; }
private void h() { if (!B.p()) { l.e(k, "changeToCastMode error, chromecast is not connected"); return; } if (p != null) { p.hide(); } m(); A = 1; o.setVisibility(0); if (q == null) { q = new kk(this, this); if (r == null) { r = new kt(this); B.a(r); B.a(r); B.a(r); } q.setMediaPlayer(r); q.setAnchorView(o); } ((ImageView)z.findViewById(2131624054)).setImageResource(2130838531); if ((B.r() > 0) && (B.r() != 2)) { b.setVisibility(0); } J.sendMessageDelayed(J.obtainMessage(5), 1000L); }