Example usage for android.os Handler postDelayed

List of usage examples for android.os Handler postDelayed

Introduction

In this page you can find the example usage for android.os Handler postDelayed.

Prototype

public final boolean postDelayed(Runnable r, long delayMillis) 

Source Link

Document

Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses.

Usage

From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java

private void pauseVideoRecording() {
    if (!isRecording)
        return;//from  w  ww. ja  v a2  s  .c o  m

    // Continue video recording
    if (this.modeDRO()) {
        long now = SystemClock.uptimeMillis();
        long delta = now - mRecordingStartTime;
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            public void run() {
                pauseDRORecording();
            }
        }, 1500 - delta);
    } else {
        if (lockPauseButton) {
            return;
        }

        if (onPause) {
            startVideoRecording();
            onPause = false;
        }
        // Pause video recording, merge files and remove last.
        else {
            lockPauseButton = true;
            long now = SystemClock.uptimeMillis();
            long delta = now - mRecordingStartTime;
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    pauseRecording();
                    Toast.makeText(ApplicationScreen.instance,
                            ApplicationScreen.instance.getString(R.string.video_paused), Toast.LENGTH_SHORT)
                            .show();
                }
            }, 1500 - delta);
        }
    }
}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

final private void confirmLogFileRotation() {
    NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override//from  w  ww .  ja  va  2 s . c o m
        public void positiveResponse(Context c, Object[] o) {
            mGlblParms.util.rotateLogFile();
            Handler hndl = new Handler();
            hndl.postDelayed(new Runnable() {
                @Override
                public void run() {
                    setControlTabBtnStatus();
                }
            }, 100);
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
        }

    });
    mGlblParms.commonDlg.showCommonDialog(true, "W", getString(R.string.msgs_control_tab_confirm_log_rotate),
            "", ntfy);
}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

final private void confirmLogFileDelete(final Button btn_logfile_delete, final Button btn_logfile_send) {
    NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override//from w  w  w .  j  a v a2 s. c  o  m
        public void positiveResponse(Context c, Object[] o) {
            mGlblParms.util.deleteLogFile();
            Handler hndl = new Handler();
            hndl.postDelayed(new Runnable() {
                @Override
                public void run() {
                    //                  if (!mGlblParms.util.isLogFileExists()) {
                    //                     btn_logfile_delete.setEnabled(false);
                    //                     btn_logfile_send.setEnabled(false);
                    //                  }
                    setControlTabBtnStatus();
                }
            }, 100);
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
        }
    });
    mGlblParms.commonDlg.showCommonDialog(true, "W", getString(R.string.msgs_control_tab_confirm_log_delete),
            "", ntfy);
}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

final private void confirmSettingsLogOption(final boolean enabled, final Button btn_logfile_rotate,
        final Button btn_log_option) {
    NotifyEvent ntfy = new NotifyEvent(mContext);
    ntfy.setListener(new NotifyEventListener() {
        @Override/*  w  ww  .j a  va  2s .c  o m*/
        public void positiveResponse(Context c, Object[] o) {
            btn_logfile_rotate.setEnabled(true);
            if (enabled)
                btn_log_option.setText(getString(R.string.msgs_control_tab_log_option_disabled));
            else
                btn_log_option.setText(getString(R.string.msgs_control_tab_log_option_enabled));
            mGlblParms.util.setSettingsLogOption(enabled);
            applySettingParms();
            Handler hndl = new Handler();
            hndl.postDelayed(new Runnable() {
                @Override
                public void run() {
                    setControlTabBtnStatus();
                }
            }, 100);
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
        }
    });
    String msg = "";
    if (enabled)
        msg = getString(R.string.msgs_control_tab_confirm_log_option_change_enable);
    else
        msg = getString(R.string.msgs_control_tab_confirm_log_option_change_disable);
    mGlblParms.commonDlg.showCommonDialog(true, "W", msg, "", ntfy);
}

From source file:au.com.infiniterecursion.vidiom.utils.PublishingUtils.java

public void getYouTubeAuthTokenWithPermissionAndUpload(final Activity activity, String accountName,
        final String path, final Handler handler, final String emailAddress, final long sdrecord_id) {

    // Make the progress bar view visible.
    ((VidiomActivity) activity).startedUploading(PublishingUtils.TYPE_YT);

    this.youTubeName = accountName;

    this.authorizer = new GlsAuthorizer.GlsAuthorizerFactory().getAuthorizer(activity,
            GlsAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE);

    this.authorizer.fetchAuthToken(accountName, activity, new AuthorizationListener<String>() {
        public void onCanceled() {

            Log.d(TAG, " Cancelled in fetchAuthToken! ");

        }/*from  w  w w.ja  v a  2 s .  c  om*/

        public void onError(Exception e) {

            Log.d(TAG, " Error in fetchAuthToken! ");

            mainapp.removeSDFileRecordIDfromUploadingTrack(sdrecord_id, TYPE_YT);

            // Use the handler to execute a Runnable on the
            // main thread in order to have access to the
            // UI elements.
            handler.postDelayed(new Runnable() {
                public void run() {
                    // Update UI

                    // Indicate back to calling activity the result!
                    // update uploadInProgress state also.

                    ((VidiomActivity) activity).finishedUploading(false);
                    ((VidiomActivity) activity)
                            .createNotification(res.getString(R.string.upload_to_youtube_host_failed_));

                }
            }, 0);

        }

        public void onSuccess(String result) {
            PublishingUtils.this.clientLoginToken = result;
            File file = new File(path);
            // Launch Async YouTube video upload.
            asyncYouTubeUpload(activity, file, handler, emailAddress, sdrecord_id);
        }
    });
}

From source file:de.sauernetworks.stm32_bluetooth_flashloader.BluetoothUpdaterFragment.java

/**
 * Set up the UI and background operations for chat.
 *//*from   www  .  ja v a2 s  .c  om*/
private void setupUI() {
    mLog.Log(9, "setupUI()");

    mBootloaderButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            mCommands.setAuto_read_out(false);
            mCommands.setAuto_write_to(false);
            mLog.Log(3, "Sending Bootloader jump command");
            LogTextView(3, "Sending Bootloader jump command");
            mBluetoothService.send_ml_packet(0x03, "y 0 0");
        }
    });

    mInitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            if (!mBootloader.isCommandRunning()) {
                LogTextView(8, "Init Sequence in Progress!");
                try {
                    if (mBootloader.init()) {
                        mLog.Log(3, "Init sequence complete!");
                        LogTextView(3, "Init Sequence complete!");
                    } else {
                        mLog.Log(Constants.ERROR, "Init sequence failed or already sent!");
                        LogTextView(Constants.ERROR, "Init Sequence failed or already sent!");
                    }
                } catch (IOException e) {
                    mLog.Log(Constants.ERROR, "Init sequence I/O exception!");
                    Toast.makeText(getActivity(), R.string.toast_error_input_output, Toast.LENGTH_SHORT).show();
                    e.printStackTrace();
                }
            } else {
                Toast.makeText(getActivity(), R.string.toast_error_command_running, Toast.LENGTH_SHORT).show();
            }
        }
    });

    mGetCmdButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }
            if (!mBootloader.isCommandRunning()) {
                try {
                    if (mBootloader.getCommands()) {
                        String[] ver = byteToHex(mBootloader.getBootloaderVersion()).split("(?!^)");
                        String temp = String.format("Bootloader Version: %s.%s (%02x)", ver[0], ver[1],
                                mBootloader.getBootloaderVersion());
                        LogTextView(3, temp);
                        mLog.Log(temp);
                        for (byte cmd : mBootloader.getBootloaderCommands()) {
                            String getCommand = String.format("Command: (0x%02x) %s", cmd,
                                    mCommands.getCommandName(cmd));
                            LogTextView(5, getCommand);
                            mLog.Log(5, getCommand);
                        }
                    } else {
                        Toast.makeText(getActivity(), "Failed to get supported commands from Bootloader!",
                                Toast.LENGTH_SHORT).show();
                        mLog.Log(Constants.ERROR, "Failed to get supported commands from Bootloader!");
                    }
                } catch (IOException e) {
                    mLog.Log(Constants.ERROR, "GET Command I/O exception!");
                    Toast.makeText(getActivity(), R.string.toast_error_input_output, Toast.LENGTH_SHORT).show();
                    e.printStackTrace();
                }
            } else {
                Toast.makeText(getActivity(), R.string.toast_error_command_running, Toast.LENGTH_SHORT).show();
            }
        }
    });

    mGvrpButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            if (!mBootloader.isCommandRunning()) {
                try {
                    if (mBootloader.getReadProtection()) {
                        String getCommand = String.format("Read Protection: 0x%02x 0x%02x",
                                mBootloader.getBootloaderReadProtection()[0],
                                mBootloader.getBootloaderReadProtection()[0]);
                        LogTextView(5, getCommand);
                        mLog.Log(5, getCommand);
                    } else {
                        Toast.makeText(getActivity(), "Failed to Read Protection Status from Bootloader!",
                                Toast.LENGTH_SHORT).show();
                        mLog.Log(Constants.ERROR, "Failed to Read Protection Status from Bootloader!");
                    }
                } catch (IOException e) {
                    mLog.Log(Constants.ERROR, "GVRP Command I/O exception!");
                    Toast.makeText(getActivity(), R.string.toast_error_input_output, Toast.LENGTH_SHORT).show();
                    e.printStackTrace();
                }
            }
        }
    });

    mGidButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            if (!mBootloader.isCommandRunning()) {
                try {
                    if (mBootloader.getDeviceInfo()) {
                        int gidBuf = mBootloader.getBootloaderProductId();
                        String gid = String.format("Product ID: 0x%04x", gidBuf);
                        String name = String.format("Product Name: %s", mBootloader.getBootloaderProductName());
                        String flash_size = new String("Flash Size: " + String.valueOf(
                                mBootloader.getDevices().getFlashSize(mBootloader.getBootloaderProductId()))
                                + " kb");
                        LogTextView(2, gid);
                        LogTextView(2, name);
                        LogTextView(2, flash_size);
                        mLog.Log(2, gid);
                        mLog.Log(2, name);
                        mLog.Log(2, flash_size);
                    } else {
                        Toast.makeText(getActivity(), "Failed to get device information from Bootloader!",
                                Toast.LENGTH_SHORT).show();
                        mLog.Log(Constants.ERROR, "Failed to get device information from Bootloader!");
                    }
                } catch (IOException e) {
                    mLog.Log(Constants.ERROR, "GID Command I/O exception!");
                    Toast.makeText(getActivity(), R.string.toast_error_input_output, Toast.LENGTH_SHORT).show();
                    e.printStackTrace();
                }
            }
        }
    });

    mGoCmdButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            if (!mBootloader.isCommandRunning()) {
                try {
                    if (mBootloader.doJump()) {
                        mLog.Log(2, "GO Command complete! Reset done!");
                        LogTextView(2, "GO Command complete! Reset done!");
                    } else {
                        Toast.makeText(getActivity(), "Failed to send a jump command to Bootloader!",
                                Toast.LENGTH_SHORT).show();
                        mLog.Log(Constants.ERROR, "Failed to send a jump command to Bootloader!");
                    }
                } catch (IOException e) {
                    mLog.Log(Constants.ERROR, "GO Command I/O exception!");
                    Toast.makeText(getActivity(), R.string.toast_error_input_output, Toast.LENGTH_SHORT).show();
                    e.printStackTrace();
                }
            }
        }
    });

    mReadMemoryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            if (!mBootloader.isCommandRunning() && !readMemoryRunning) {
                new ReadMemoryOperation().execute();
            }
        }
    });

    mEraseMemoryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            if (!mBootloader.isCommandRunning()) {
                new ExtendedEraseMemoryOperation().execute();
            }
        }
    });

    mWriteMemoryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            if (!mBootloader.isCommandRunning()) {
                fileWriteDialog.addFileListener(new FileDialog.FileSelectedListener() {
                    public void fileSelected(File file) {
                        if (!writeMemoryRunning) {
                            mLog.Log(7, "selected file " + file.toString());
                            firmware_upload_size = getFileSize(file.toString());
                            new WriteMemoryOperation().execute(file.toString());
                        } else {
                            mLog.Log(1, "Writing already in progress!");
                        }
                    }
                });
                fileWriteDialog.showDialog();
            }
        }
    });

    mCheckUpdateButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            LogTextView(3, "Getting running Firmware Version");
            mBluetoothService.getVersion();
        }
    });

    mDownloadMemoryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            final Handler handler = new Handler();
            long initDelay = 1000;
            long initDelayPref = Integer.parseInt(getPrefBootloaderInitDelay());
            if (initDelayPref > -1 && initDelayPref < 2001) {
                mLog.Log(8, "Setting Init delay value to " + getPrefBootloaderInitDelay());
                initDelay = initDelayPref;
            } else {
                mLog.Log(8, "Init Delay not in Range. Setting default value of 1000ms");
            }
            final long finalInitDelay = initDelay;
            /*fileReadDialog.addDirectoryListener(new FileDialog.DirectorySelectedListener() {
              public void directorySelected(File directory) {
                  mLog.Log(7, "Selected dir: " + directory.toString());
                    
              }
            });
            fileReadDialog.showDialog();*/
            mCommands.setAuto_read_out(true);
            if (isPrefSendBootloaderCommand()) {
                //mBluetoothService.getVersion(); // MagicLight specific command
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mBluetoothService.send_ml_packet(0x03, "y 0 0");
                    }
                }, 500);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            mBootloader.init();
                        } catch (IOException e) {
                            e.printStackTrace();
                            Toast.makeText(getActivity(), R.string.toast_error_command_running,
                                    Toast.LENGTH_SHORT).show();
                        }
                    }
                }, finalInitDelay + 1);
            } else {
                mLog.Log(5, "Starting Bootloader info dialog");
                createDialog(DIALOG_START_BOOTLOADER_INFO);
            }
        }
    });

    mUploadMemoryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Check that we're actually connected before trying anything
            if (mBluetoothService.getState() != BluetoothService.STATE_CONNECTED) {
                Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
                return;
            }

            final Handler handler = new Handler();
            long initDelay = 1000;
            long initDelayPref = Integer.parseInt(getPrefBootloaderInitDelay());
            if (initDelayPref > -1 && initDelayPref < 2001) {
                mLog.Log(8, "Setting Init delay value to " + getPrefBootloaderInitDelay());
                initDelay = initDelayPref;
            } else {
                mLog.Log(8, "Init Delay not in Range. Setting default value of 1000ms");
            }
            final long finalInitDelay = initDelay;
            fileWriteDialog.addFileListener(new FileDialog.FileSelectedListener() {
                public void fileSelected(File file) {
                    mLog.Log(7, "selected file " + file.toString());
                    mBluetoothService.setMemoryFilename(file.toString());
                    mCommands.setAuto_write_to(true);
                    if (isPrefSendBootloaderCommand()) {
                        mBluetoothService.getVersion();
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                mBluetoothService.send_ml_packet(0x03, "y 0 0");
                            }
                        }, 500);
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    mBootloader.init();
                                } catch (IOException e) {
                                    e.printStackTrace();
                                    Toast.makeText(getActivity(), R.string.toast_error_command_running,
                                            Toast.LENGTH_SHORT).show();
                                }
                            }
                        }, finalInitDelay + 1);
                    } else {
                        mLog.Log(5, "Starting Bootloader info dialog");
                        createDialog(DIALOG_START_BOOTLOADER_INFO);
                    }
                }
            });
            fileWriteDialog.showDialog();
            /*
            mCommands.setAuto_write_to(true);
            mBluetoothService.getVersion();
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mBluetoothService.send_ml_packet(0x03, "y 0 0");
            }
            }, 500);
            handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mBluetoothService.sendInit();
            }
            }, 1000);
            */
        }
    });

    // Initialize the BluetoothService to perform bluetooth connections
    mBluetoothService = new BluetoothService(getActivity(), mHandler, mCommands, mLog);

}

From source file:com.plusot.senselib.SenseMain.java

/**
 * Shows the splash screen over the full Activity
 *//*from  ww  w . ja v a2  s.  c  o m*/
protected void showSplashScreen(boolean startApp) {
    mSplashDialog = new SplashDialog(this, false);
    mSplashDialog.show();

    if (startApp) {
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                //               while (creating) try {
                //                  Thread.sleep(1000);
                //               } catch (InterruptedException e) {
                //               }
                removeSplashScreen();
                //enableAnt();

                new SleepAndWake(new SleepAndWake.Listener() {

                    @Override
                    public void onWake() {
                        if (System.currentTimeMillis() < TimeUtil.MIN_TIME) {
                            startActivityForResult(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS),
                                    RESULT_TIMESET);
                        } else
                            checkGPS();

                    }
                }, 1000);
            }
        }, 4000);
    }
}

From source file:com.yaniv.online.MainActivity.java

private void displayToastForLimitTime(String message, long time) {
    Log.d(TAG, "displayToastForLimitTime() mes:" + message + " time:" + time);

    final Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT);
    toast.show();//  w ww  . ja v  a2  s. com

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            toast.cancel();
        }
    }, time);
}

From source file:com.yaniv.online.MainActivity.java

void startGame(boolean multiplayer) {

    mMultiplayer = multiplayer;//from ww w  . ja v  a  2s  . co  m
    drawMyCards();
    switchToScreen(R.id.screen_game);
    if (!mMultiplayer) {
        cleanUI();
        Log.d(TAG, "singlePlayer()");
        mMyId = "ID";
        getNumOfPC();

    }
    // run the gameTick() method every second to update the game.
    final Handler h = new Handler();
    h.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (mSecondsLeft <= 0)
                return;
            gameTick();
            h.postDelayed(this, 1000);
        }
    }, 1000);
}

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 w ww.jav  a  2 s .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();
}