List of usage examples for android.os Handler post
public final boolean post(Runnable r)
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void createRemoteFileList(String remurl, String remdir, final NotifyEvent p_event, boolean readSubDirCnt) { final ArrayList<TreeFilelistItem> remoteFileList = new ArrayList<TreeFilelistItem>(); final ThreadCtrl tc = new ThreadCtrl(); tc.setEnabled();//ww w . j ava 2 s. c om tc.setThreadResultSuccess(); // ?? final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.progress_spin_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.progress_spin_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.progress_spin_dlg_title_view); final TextView title = (TextView) dialog.findViewById(R.id.progress_spin_dlg_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(R.string.msgs_progress_spin_dlg_filelist_getting); final Button btn_cancel = (Button) dialog.findViewById(R.id.progress_spin_dlg_btn_cancel); btn_cancel.setText(R.string.msgs_progress_spin_dlg_filelist_cancel); // (dialog.context.findViewById(R.id.progress_spin_dlg)).setVisibility(TextView.GONE); // (dialog.context.findViewById(R.id.progress_spin_dlg)).setEnabled(false); CommonDialog.setDlgBoxSizeCompact(dialog); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { tc.setDisabled();//disableAsyncTask(); btn_cancel.setText(mContext.getString(R.string.msgs_progress_dlg_canceling)); btn_cancel.setEnabled(false); util.addDebugMsg(1, "W", "Sharelist is cancelled."); } }); dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); // dialog.show(); showDelayedProgDlg? final Handler hndl = new Handler(); NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { hndl.post(new Runnable() { @Override public void run() { dialog.dismiss(); String err; util.addDebugMsg(1, "I", "FileListThread result=" + tc.getThreadResult() + "," + "msg=" + tc.getThreadMessage() + ", enable=" + tc.isEnabled()); if (tc.isThreadResultSuccess()) { p_event.notifyToListener(true, new Object[] { remoteFileList }); } else { if (tc.isThreadResultCancelled()) err = mContext.getString(R.string.msgs_filelist_cancel); else err = mContext.getString(R.string.msgs_filelist_error) + "\n" + tc.getThreadMessage(); p_event.notifyToListener(false, new Object[] { err }); } } }); } @Override public void negativeResponse(Context c, Object[] o) { } }); Thread tf = new Thread(new ReadSmbFilelist(mContext, tc, remurl, remdir, remoteFileList, smbUser, smbPass, ntfy, true, readSubDirCnt, mGp)); tf.start(); // showDelayedProgDlg(200,dialog, tc); dialog.show(); }
From source file:com.android.mms.ui.MessageUtils.java
public static void resizeImageAsync(final Context context, final Uri imageUri, final Handler handler, final ResizeImageResultCallback cb, final boolean append) { // Show a progress toast if the resize hasn't finished // within one second. // Stash the runnable for showing it away so we can cancel // it later if the resize completes ahead of the deadline. final Runnable showProgress = new Runnable() { @Override/*from www. j a va2s . c o m*/ public void run() { Toast.makeText(context, R.string.compressing, Toast.LENGTH_SHORT).show(); } }; // Schedule it for one second from now. handler.postDelayed(showProgress, 1000); new Thread(new Runnable() { @Override public void run() { final PduPart part; try { UriImage image = new UriImage(context, imageUri); int widthLimit = MmsConfig.getMaxImageWidth(); int heightLimit = MmsConfig.getMaxImageHeight(); // In mms_config.xml, the max width always been declared larger than the max // height. Swap the width and height limits if necessary so scale the picture // as little as possible. if (image.getHeight() > image.getWidth()) { int temp = widthLimit; widthLimit = heightLimit; heightLimit = temp; } // / M: Code analyze 027, new feature, to improve the // performance of Mms. @{ /*part = image.getResizedImageAsPart( widthLimit, heightLimit, MmsConfig.getMaxMessageSize() - MESSAGE_OVERHEAD); */ part = image.getResizedImageAsPart(widthLimit, heightLimit, MmsConfig.getUserSetMmsSizeLimit(true) - MESSAGE_OVERHEAD); handler.post(new Runnable() { @Override public void run() { cb.onResizeResult(part, append); } }); } catch (IllegalArgumentException e) { MmsLog.e(TAG, "Unexpected IllegalArgumentException.", e); } finally { /// M: Cancel pending show of the progress toast if necessary. handler.removeCallbacks(showProgress); } /// @} } }, "MessageUtils.resizeImageAsync").start(); }
From source file:fiskinfoo.no.sintef.fiskinfoo.MapFragment.java
private void notifyUserOfProximityAlert() { Handler mainHandler = new Handler(getActivity().getMainLooper()); Runnable myRunnable = new Runnable() { @Override//from w ww . j a v a 2 s .c o m public void run() { final Dialog dialog = dialogInterface.getDialog(getActivity(), R.layout.dialog_proximity_alert_warning, R.string.proximity_alert_warning); Button okButton = (Button) dialog.findViewById(R.id.proximity_alert_warning_ok_button); Button showOnMapButton = (Button) dialog .findViewById(R.id.proximity_alert_warning_show_on_map_button); Button dismissAlertButton = (Button) dialog .findViewById(R.id.proximity_alert_warning_dismiss_button); long[] pattern = { 0, 500, 200, 200, 300, 200, 200 }; vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(pattern, 0); mediaPlayer = MediaPlayer.create(getActivity(), R.raw.proximity_warning_sound); if (mediaPlayer == null) { return; } mediaPlayer.setLooping(true); mediaPlayer.start(); okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alarmFiring = false; vibrator.cancel(); vibrator = null; proximityAlertWatcher.cancel(true); proximityAlertWatcher = null; mediaPlayer.stop(); mediaPlayer.release(); dialog.dismiss(); runScheduledAlarm(getResources().getInteger(R.integer.sixty), getResources().getInteger(R.integer.proximity_alert_interval_time_seconds)); } }); showOnMapButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alarmFiring = false; vibrator.cancel(); vibrator = null; proximityAlertWatcher.cancel(true); proximityAlertWatcher = null; mediaPlayer.stop(); mediaPlayer.release(); browser.loadUrl("javascript:zoomToUserPosition()"); dialog.dismiss(); runScheduledAlarm(getResources().getInteger(R.integer.sixty), getResources().getInteger(R.integer.proximity_alert_interval_time_seconds)); } }); dismissAlertButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alarmFiring = false; vibrator.cancel(); vibrator = null; proximityAlertWatcher.cancel(true); proximityAlertWatcher = null; mediaPlayer.stop(); mediaPlayer.release(); dialog.dismiss(); } }); dialog.show(); } // This is your code }; mainHandler.post(myRunnable); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void startRemoteNetworkScanThread(final Handler handler, final ThreadCtrl tc, final Dialog dialog, final NotifyEvent p_ntfy, final ListView lv_ipaddr, final AdapterScanAddressResultList adap, final TextView tvmsg, final String addr, final ArrayList<ScanAddressResultListItem> ipAddressList, final String scan_port) { final String scan_prog = mContext.getString(R.string.msgs_ip_address_scan_progress); Thread th = new Thread(new Runnable() { @Override/*from w w w. j av a 2s .co m*/ public void run() { if (isIpAddrSmbHost(addr, scan_port)) { final String srv_name = getSmbHostName(addr); handler.post(new Runnable() {// UI thread @Override public void run() { synchronized (mLockScanCompleteCount) { mScanCompleteCount++; ScanAddressResultListItem li = new ScanAddressResultListItem(); li.server_address = addr; li.server_name = srv_name; ipAddressList.add(li); Collections.sort(ipAddressList, new Comparator<ScanAddressResultListItem>() { @Override public int compare(ScanAddressResultListItem lhs, ScanAddressResultListItem rhs) { return lhs.server_address.compareTo(rhs.server_address); } }); } } }); } else { synchronized (mLockScanCompleteCount) { mScanCompleteCount++; } } handler.post(new Runnable() {// UI thread @Override public void run() { synchronized (mLockScanCompleteCount) { lv_ipaddr.setSelection(lv_ipaddr.getCount()); adap.notifyDataSetChanged(); String p_txt = String.format(scan_prog, (mScanCompleteCount * 100) / mScanAddrCount); tvmsg.setText(p_txt); if (mScanCompleteCount >= mScanAddrCount) { closeScanRemoteNetworkProgressDlg(dialog, p_ntfy, lv_ipaddr, adap, tvmsg); } } } }); } }); th.start(); }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void processPickResult(final Intent data) { // The EXTRA_PHONE_URIS stores the phone's urls that were selected by user in the // multiple phone picker. final Parcelable[] uris = data.getParcelableArrayExtra(Intents.EXTRA_PHONE_URIS); final int recipientCount = uris != null ? uris.length : 0; final int recipientLimit = MmsConfig.getRecipientLimit(); if (recipientLimit != Integer.MAX_VALUE && recipientCount > recipientLimit) { new AlertDialog.Builder(this) .setMessage(getString(R.string.too_many_recipients, recipientCount, recipientLimit)) .setPositiveButton(android.R.string.ok, null).create().show(); return;/*from w ww. ja v a2 s. co m*/ } final Handler handler = new Handler(); final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle(getText(R.string.pick_too_many_recipients)); progressDialog.setMessage(getText(R.string.adding_recipients)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); final Runnable showProgress = new Runnable() { @Override public void run() { progressDialog.show(); } }; // Only show the progress dialog if we can not finish off parsing the return data in 1s, // otherwise the dialog could flicker. handler.postDelayed(showProgress, 1000); new Thread(new Runnable() { @Override public void run() { final ContactList list; try { list = ContactList.blockingGetByUris(uris); } finally { handler.removeCallbacks(showProgress); progressDialog.dismiss(); } // TODO: there is already code to update the contact header widget and recipients // editor if the contacts change. we can re-use that code. final Runnable populateWorker = new Runnable() { @Override public void run() { mRecipientsEditor.populate(list); updateTitle(list); } }; handler.post(populateWorker); } }, "ComoseMessageActivity.processPickResult").start(); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void startRemoteNetworkScanThread(final Handler handler, final ThreadCtrl tc, final Dialog dialog, final NotifyEvent p_ntfy, final ListView lv_ipaddr, final AdapterScanAddressResultList adap, final TextView tvmsg, final String addr, final ArrayList<ScanAddressResultListItem> ipAddressList, final String scan_port) { final String scan_prog = mContext.getString(R.string.msgs_ip_address_scan_progress); Thread th = new Thread(new Runnable() { @Override/*w w w. ja v a2s . c om*/ public void run() { if (isIpAddrSmbHost(addr, scan_port)) { synchronized (mLockScanCompleteCount) { mScanCompleteCount++; String srv_name = getSmbHostName(addr); ScanAddressResultListItem li = new ScanAddressResultListItem(); li.server_address = addr; li.server_name = srv_name; ipAddressList.add(li); Collections.sort(ipAddressList, new Comparator<ScanAddressResultListItem>() { @Override public int compare(ScanAddressResultListItem lhs, ScanAddressResultListItem rhs) { return lhs.server_address.compareTo(rhs.server_address); } }); } } else { synchronized (mLockScanCompleteCount) { mScanCompleteCount++; } } handler.post(new Runnable() {// UI thread @Override public void run() { synchronized (mLockScanCompleteCount) { lv_ipaddr.setSelection(lv_ipaddr.getCount()); adap.notifyDataSetChanged(); String p_txt = String.format(scan_prog, (mScanCompleteCount * 100) / mScanAddrCount); tvmsg.setText(p_txt); if (mScanCompleteCount >= mScanAddrCount) { closeScanRemoteNetworkProgressDlg(dialog, p_ntfy, lv_ipaddr, adap, tvmsg); } } } }); } }); th.start(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void scanRemoteNetwork(final Dialog dialog, final ListView lv_ipaddr, final AdapterScanAddressResultList adap, final ArrayList<ScanAddressResultListItem> ipAddressList, final String subnet, final int begin_addr, final int end_addr, final NotifyEvent p_ntfy) { final Handler handler = new Handler(); final ThreadCtrl tc = new ThreadCtrl(); final LinearLayout ll_addr = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_scan_address); final LinearLayout ll_prog = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_progress); final TextView tvmsg = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_progress_msg); final Button btn_scan = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_ok); final Button btn_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_cancel); final Button scan_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_progress_cancel); final CheckedTextView ctv_use_port_number = (CheckedTextView) dialog .findViewById(R.id.scan_remote_ntwk_ctv_use_port); final EditText et_port_number = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_port_number); tvmsg.setText(""); scan_cancel.setText(R.string.msgs_scan_progress_spin_dlg_addr_cancel); ll_addr.setVisibility(LinearLayout.GONE); ll_prog.setVisibility(LinearLayout.VISIBLE); btn_scan.setVisibility(Button.GONE); btn_cancel.setVisibility(Button.GONE); adap.setButtonEnabled(false);/* www . j a v a2 s.com*/ scan_cancel.setEnabled(true); dialog.setOnKeyListener(new DialogBackKeyListener(mContext)); dialog.setCancelable(false); // CANCEL? scan_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { scan_cancel.setText(mContext.getString(R.string.msgs_progress_dlg_canceling)); scan_cancel.setEnabled(false); util.addDebugMsg(1, "W", "IP Address list creation was cancelled"); tc.setDisabled(); } }); dialog.show(); util.addDebugMsg(1, "I", "Scan IP address ransge is " + subnet + "." + begin_addr + " - " + end_addr); final String scan_prog = mContext.getString(R.string.msgs_ip_address_scan_progress); String p_txt = String.format(scan_prog, 0); tvmsg.setText(p_txt); new Thread(new Runnable() { @Override public void run() {//non UI thread mScanCompleteCount = 0; mScanAddrCount = end_addr - begin_addr + 1; int scan_thread = 60; String scan_port = ""; if (ctv_use_port_number.isChecked()) scan_port = et_port_number.getText().toString(); for (int i = begin_addr; i <= end_addr; i += scan_thread) { if (!tc.isEnabled()) break; boolean scan_end = false; for (int j = i; j < (i + scan_thread); j++) { if (j <= end_addr) { startRemoteNetworkScanThread(handler, tc, dialog, p_ntfy, lv_ipaddr, adap, tvmsg, subnet + "." + j, ipAddressList, scan_port); } else { scan_end = true; } } if (!scan_end) { for (int wc = 0; wc < 210; wc++) { if (!tc.isEnabled()) break; SystemClock.sleep(30); } } } if (!tc.isEnabled()) { handler.post(new Runnable() {// UI thread @Override public void run() { closeScanRemoteNetworkProgressDlg(dialog, p_ntfy, lv_ipaddr, adap, tvmsg); } }); } else { handler.postDelayed(new Runnable() {// UI thread @Override public void run() { closeScanRemoteNetworkProgressDlg(dialog, p_ntfy, lv_ipaddr, adap, tvmsg); } }, 10000); } } }).start(); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void scanRemoteNetwork(final Dialog dialog, final ListView lv_ipaddr, final AdapterScanAddressResultList adap, final ArrayList<ScanAddressResultListItem> ipAddressList, final String subnet, final int begin_addr, final int end_addr, final NotifyEvent p_ntfy) { final Handler handler = new Handler(); final ThreadCtrl tc = new ThreadCtrl(); final LinearLayout ll_addr = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_scan_address); final LinearLayout ll_prog = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_progress); final TextView tvmsg = (TextView) dialog.findViewById(R.id.scan_remote_ntwk_progress_msg); final Button btn_scan = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_ok); final Button btn_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_cancel); final Button scan_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_progress_cancel); final CheckBox cb_use_port_number = (CheckBox) dialog.findViewById(R.id.scan_remote_ntwk_use_port); final EditText et_port_number = (EditText) dialog.findViewById(R.id.scan_remote_ntwk_port_number); tvmsg.setText(""); scan_cancel.setText(R.string.msgs_progress_spin_dlg_addr_cancel); ll_addr.setVisibility(LinearLayout.GONE); ll_prog.setVisibility(LinearLayout.VISIBLE); btn_scan.setEnabled(false);//from www . jav a 2s. c o m btn_cancel.setEnabled(false); adap.setButtonEnabled(false); scan_cancel.setEnabled(true); dialog.setOnKeyListener(new DialogBackKeyListener(mContext)); dialog.setCancelable(false); // CANCEL? scan_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { scan_cancel.setText(mContext.getString(R.string.msgs_progress_dlg_canceling)); scan_cancel.setEnabled(false); sendDebugLogMsg(1, "W", "IP Address list creation was cancelled"); tc.setDisabled(); } }); dialog.show(); sendDebugLogMsg(1, "I", "Scan IP address ransge is " + subnet + "." + begin_addr + " - " + end_addr); final String scan_prog = mContext.getString(R.string.msgs_ip_address_scan_progress); String p_txt = String.format(scan_prog, 0); tvmsg.setText(p_txt); new Thread(new Runnable() { @Override public void run() {//non UI thread mScanCompleteCount = 0; mScanAddrCount = end_addr - begin_addr + 1; int scan_thread = 50; String scan_port = ""; if (cb_use_port_number.isChecked()) scan_port = et_port_number.getText().toString(); for (int i = begin_addr; i <= end_addr; i += scan_thread) { if (!tc.isEnabled()) break; boolean scan_end = false; for (int j = i; j < (i + scan_thread); j++) { if (j <= end_addr) { startRemoteNetworkScanThread(handler, tc, dialog, p_ntfy, lv_ipaddr, adap, tvmsg, subnet + "." + j, ipAddressList, scan_port); } else { scan_end = true; } } if (!scan_end) { for (int wc = 0; wc < 210; wc++) { if (!tc.isEnabled()) break; SystemClock.sleep(30); } } } if (!tc.isEnabled()) { handler.post(new Runnable() {// UI thread @Override public void run() { closeScanRemoteNetworkProgressDlg(dialog, p_ntfy, lv_ipaddr, adap, tvmsg); } }); } else { handler.postDelayed(new Runnable() {// UI thread @Override public void run() { closeScanRemoteNetworkProgressDlg(dialog, p_ntfy, lv_ipaddr, adap, tvmsg); } }, 10000); } } }).start(); }
From source file:com.tct.mail.compose.ComposeActivity.java
private int sendOrSaveInternal(Context context, ReplyFromAccount replyFromAccount, Message message, final Message refMessage, final CharSequence quotedText, SendOrSaveCallback callback, Handler handler, boolean save, int composeMode, ReplyFromAccount draftAccount, final ContentValues extraValues) { final ContentValues values = new ContentValues(); final String refMessageId = refMessage != null ? refMessage.uri.toString() : ""; MessageModification.putToAddresses(values, message.getToAddresses()); MessageModification.putCcAddresses(values, message.getCcAddresses()); MessageModification.putBccAddresses(values, message.getBccAddresses()); MessageModification.putCustomFromAddress(values, message.getFrom()); //[FEATURE]-Add-BEGIN by TSCD.chao zhang,04/17/2014,FR 631895(porting from FR514398) MessageModification.putPriority(values, message.mPriority); //[FEATURE]-Add-END by TSCD.chao zhang MessageModification.putSubject(values, message.subject); // TS: tao.gan 2015-12-25 EMAIL FEATURE-1239148 ADD_S MessageModification.putRepylToAddress(values, message.getReplyTo()); // TS: tao.gan 2015-12-25 EMAIL FEATURE-1239148 ADD_E // bodyHtml already have the composing spans removed. final String htmlBody = message.bodyHtml; final String textBody = message.bodyText; // fullbody will contain the actual body plus the quoted text. final String fullBody; final String quotedString; final boolean hasQuotedText = !TextUtils.isEmpty(quotedText); if (hasQuotedText) { // The quoted text is HTML at this point. quotedString = quotedText.toString(); fullBody = htmlBody + quotedString; MessageModification.putForward(values, composeMode == ComposeActivity.FORWARD); MessageModification.putAppendRefMessageContent(values, true /* include quoted */); } else {/* www. ja v a 2 s.c om*/ fullBody = htmlBody; quotedString = null; } // Only take refMessage into account if either one of its html/text is not empty. if (refMessage != null && !(TextUtils.isEmpty(refMessage.bodyHtml) && TextUtils.isEmpty(refMessage.bodyText))) { // The code below might need to be revisited. The quoted text position is different // between text/html and text/plain parts and they should be stored seperately and // the right version should be used in the UI. text/html should have preference // if both exist. Issues like this made me file b/14256940 to make sure that we // properly handle the existing of both text/html and text/plain parts and to verify // that we are not making some assumptions that break if there is no text/html part. int quotedTextPos = -1; //[FEATURE]-Add-BEGIN by TSNJ,Zhenhua.Fan,06/11/2014,FR-622609 1471 if (EmailApplication.isOrangeImapFeatureOn() && message.serverId != null) { values.put(UIProvider.MessageColumns.SERVER_ID, message.serverId); } //[FEATURE]-Add-END by TSNJ,Zhenhua.Fan if (!TextUtils.isEmpty(refMessage.bodyHtml)) { MessageModification.putBodyHtml(values, fullBody.toString()); if (hasQuotedText) { quotedTextPos = htmlBody.length() + QuotedTextView.getQuotedTextOffset(quotedString); } } if (!TextUtils.isEmpty(refMessage.bodyText)) { MessageModification.putBody(values, Utils.convertHtmlToPlainText(fullBody.toString())); if (hasQuotedText && (quotedTextPos == -1)) { quotedTextPos = textBody.length(); } } if (quotedTextPos != -1) { // The quoted text pos is the text/html version first and the text/plan version // if there is no text/html part. The reason for this is because preference // is given to text/html in the compose window if it exists. In the future, we // should calculate the index for both since the user could choose to compose // explicitly in text/plain. MessageModification.putQuoteStartPos(values, quotedTextPos); } } else { MessageModification.putBodyHtml(values, fullBody.toString()); MessageModification.putBody(values, Utils.convertHtmlToPlainText(fullBody.toString())); } int draftType = getDraftType(composeMode); MessageModification.putDraftType(values, draftType); MessageModification.putAttachments(values, message.getAttachments()); if (!TextUtils.isEmpty(refMessageId)) { MessageModification.putRefMessageId(values, refMessageId); } if (extraValues != null) { values.putAll(extraValues); } SendOrSaveMessage sendOrSaveMessage = new SendOrSaveMessage(context, replyFromAccount, values, refMessageId, message.getAttachments(), save); SendOrSaveTask sendOrSaveTask = new SendOrSaveTask(context, sendOrSaveMessage, callback, draftAccount); callback.initializeSendOrSave(sendOrSaveTask); // Do the send/save action on the specified handler to avoid possible // ANRs handler.post(sendOrSaveTask); return sendOrSaveMessage.requestId(); }