Example usage for android.app ProgressDialog STYLE_HORIZONTAL

List of usage examples for android.app ProgressDialog STYLE_HORIZONTAL

Introduction

In this page you can find the example usage for android.app ProgressDialog STYLE_HORIZONTAL.

Prototype

int STYLE_HORIZONTAL

To view the source code for android.app ProgressDialog STYLE_HORIZONTAL.

Click Source Link

Document

Creates a ProgressDialog with a horizontal progress bar.

Usage

From source file:com.remobile.dialogs.Notification.java

/**
 * Show the progress dialog./*from   w ww  . j  av a 2 s .  c  o m*/
 *
 * @param title   Title of the dialog
 * @param message The message of the dialog
 */
public synchronized void progressStart(final String title, final String message) {
    if (this.progressDialog != null) {
        this.progressDialog.dismiss();
        this.progressDialog = null;
    }
    final Notification notification = this;
    Runnable runnable = new Runnable() {
        public void run() {
            notification.progressDialog = createProgressDialog(); // new ProgressDialog(this.cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            notification.progressDialog.setTitle(title);
            notification.progressDialog.setMessage(message);
            notification.progressDialog.setCancelable(false);
            notification.progressDialog.setMax(100);
            notification.progressDialog.setProgress(0);
            notification.progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    notification.progressDialog = null;
                }
            });
            notification.progressDialog.show();
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:org.sufficientlysecure.keychain.ui.CertifyKeyActivity.java

private void uploadKey() {
    // Send all information needed to service to upload key in other thread
    Intent intent = new Intent(this, KeychainIntentService.class);

    intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING);

    // set data uri as path to keyring
    Uri blobUri = KeychainContract.KeyRingData.buildPublicKeyRingUri(mDataUri);
    intent.setData(blobUri);//from   w w  w.  j a va2s  . com

    // fill values for this action
    Bundle data = new Bundle();

    Spinner keyServer = (Spinner) findViewById(R.id.upload_key_keyserver);
    String server = (String) keyServer.getSelectedItem();
    data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, server);

    intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

    // Message is received after uploading is done in KeychainIntentService
    KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this,
            getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL) {
        public void handleMessage(Message message) {
            // handle messages by standard KeychainIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
                AppMsg.makeText(CertifyKeyActivity.this, R.string.key_send_success, AppMsg.STYLE_INFO).show();

                setResult(RESULT_OK);
                finish();
            }
        }
    };

    // Create a new Messenger for the communication back
    Messenger messenger = new Messenger(saveHandler);
    intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);

    // show progress dialog
    saveHandler.showProgressDialog(this);

    // start service with intent
    startService(intent);
}

From source file:com.tsp.clipsy.audio.RingdroidEditActivity.java

private void loadFromFile() {
    mFile = new File(mFilename);
    mExtension = getExtensionFromFilename(mFilename);

    SongMetadataReader metadataReader = new SongMetadataReader(this, mFilename);
    mTitle = metadataReader.mTitle;//from  w w w.  ja v a  2 s  .c o  m
    mArtist = metadataReader.mArtist;
    mAlbum = metadataReader.mAlbum;
    mYear = metadataReader.mYear;
    mGenre = metadataReader.mGenre;

    String titleLabel = mTitle;
    if (mArtist != null && mArtist.length() > 0) {
        titleLabel += " - " + mArtist;
    }
    setTitle(titleLabel);

    mLoadingStartTime = System.currentTimeMillis();
    mLoadingLastUpdateTime = System.currentTimeMillis();
    mLoadingKeepGoing = true;
    mProgressDialog = new ProgressDialog(RingdroidEditActivity.this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle(R.string.progress_dialog_loading);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            mLoadingKeepGoing = false;
        }
    });
    mProgressDialog.show();

    final CheapSoundFile.ProgressListener listener = new CheapSoundFile.ProgressListener() {
        public boolean reportProgress(double fractionComplete) {
            long now = System.currentTimeMillis();
            if (now - mLoadingLastUpdateTime > 100) {
                mProgressDialog.setProgress((int) (mProgressDialog.getMax() * fractionComplete));
                mLoadingLastUpdateTime = now;
            }
            return mLoadingKeepGoing;
        }
    };

    // Create the MediaPlayer in a background thread
    mCanSeekAccurately = false;
    new Thread() {
        public void run() {
            mCanSeekAccurately = SeekTest.CanSeekAccurately(getPreferences(Context.MODE_PRIVATE));

            System.out.println("Seek test done, creating media player.");
            try {
                MediaPlayer player = new MediaPlayer();
                player.setDataSource(mFile.getAbsolutePath());
                player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                player.prepare();
                mPlayer = player;
            } catch (final java.io.IOException e) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        handleFatalError("ReadError", getResources().getText(R.string.read_error), e);
                    }
                };
                mHandler.post(runnable);
            }
            ;
        }
    }.start();

    // Load the sound file in a background thread
    new Thread() {
        public void run() {
            try {
                mSoundFile = CheapSoundFile.create(mFile.getAbsolutePath(), listener);

                if (mSoundFile == null) {
                    mProgressDialog.dismiss();
                    String name = mFile.getName().toLowerCase();
                    String[] components = name.split("\\.");
                    String err;
                    if (components.length < 2) {
                        err = getResources().getString(R.string.no_extension_error);
                    } else {
                        err = getResources().getString(R.string.bad_extension_error) + " "
                                + components[components.length - 1];
                    }
                    final String finalErr = err;
                    Runnable runnable = new Runnable() {
                        public void run() {
                            handleFatalError("UnsupportedExtension", finalErr, new Exception());
                        }
                    };
                    mHandler.post(runnable);
                    return;
                }
            } catch (final Exception e) {
                mProgressDialog.dismiss();
                e.printStackTrace();
                mInfo.setText(e.toString());

                Runnable runnable = new Runnable() {
                    public void run() {
                        handleFatalError("ReadError", getResources().getText(R.string.read_error), e);
                    }
                };
                mHandler.post(runnable);
                return;
            }
            mProgressDialog.dismiss();
            if (mLoadingKeepGoing) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        finishOpeningSoundFile();
                    }
                };
                mHandler.post(runnable);
            } else {
                RingdroidEditActivity.this.finish();
            }
        }
    }.start();
}

From source file:com.cellbots.logger.LoggerActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    if (id != PROGRESS_ID) {
        return super.onCreateDialog(id);
    }/*w  ww . j a  v  a2s . c om*/
    final ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setCancelable(false);

    // The setMessage call must be in both onCreateDialog and
    // onPrepareDialog otherwise it will
    // fail to update the dialog in onPrepareDialog.
    progressDialog.setMessage("Processing...");

    return progressDialog;
}

From source file:com.renard.ocr.BaseDocumentActivitiy.java

@Override
protected Dialog onCreateDialog(int id, Bundle args) {
    switch (id) {

    case PDF_PROGRESS_DIALOG_ID:
        int max = args.getInt(DIALOG_ARG_MAX);
        String message = args.getString(DIALOG_ARG_MESSAGE);
        String title = args.getString(DIALOG_ARG_TITLE);
        pdfProgressDialog = new ProgressDialog(this);
        pdfProgressDialog.setMessage(message);
        pdfProgressDialog.setTitle(title);
        pdfProgressDialog.setIndeterminate(false);
        pdfProgressDialog.setMax(max);//from   ww  w . ja v a2s .  c om
        pdfProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        pdfProgressDialog.setCancelable(false);
        return pdfProgressDialog;
    case DELETE_PROGRESS_DIALOG_ID:
        max = args.getInt(DIALOG_ARG_MAX);
        message = args.getString(DIALOG_ARG_MESSAGE);
        deleteProgressDialog = new ProgressDialog(this);
        deleteProgressDialog.setMessage(message);
        deleteProgressDialog.setIndeterminate(false);
        deleteProgressDialog.setMax(max);
        deleteProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        deleteProgressDialog.setCancelable(false);
        return deleteProgressDialog;
    case EDIT_TITLE_DIALOG_ID:
        View layout = getLayoutInflater().inflate(R.layout.edit_title_dialog, null);
        final Uri documentUri = Uri.parse(args.getString(DIALOG_ARG_DOCUMENT_URI));
        final String oldTitle = args.getString(DIALOG_ARG_TITLE);
        final EditText edit = (EditText) layout.findViewById(R.id.edit_title);
        edit.setText(oldTitle);

        AlertDialog.Builder builder = new Builder(this);
        builder.setView(layout);
        builder.setTitle(R.string.edit_dialog_title);
        builder.setIcon(R.drawable.fairy_showing);
        builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                final String title = edit.getText().toString();
                saveTitle(title, documentUri);

            }
        });
        builder.setNegativeButton(R.string.cancel, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.show();
    }
    return super.onCreateDialog(id, args);
}

From source file:mobi.omegacentauri.ptimer.PTimerEditActivity.java

private void loadFromFile() {
    mFile = new File(mFilename);
    mExtension = getExtensionFromFilename(mFilename);

    SongMetadataReader metadataReader = new SongMetadataReader(this, mFilename);
    mTitle = metadataReader.mTitle;// w  w w . java  2s  . c o  m
    mArtist = metadataReader.mArtist;
    mAlbum = metadataReader.mAlbum;
    mYear = metadataReader.mYear;
    mGenre = metadataReader.mGenre;

    String titleLabel = mTitle;
    if (mArtist != null && mArtist.length() > 0) {
        titleLabel += " - " + mArtist;
    }
    setTitle(titleLabel);

    mLoadingStartTime = System.currentTimeMillis();
    mLoadingLastUpdateTime = System.currentTimeMillis();
    mLoadingKeepGoing = true;
    mProgressDialog = new ProgressDialog(PTimerEditActivity.this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle(R.string.progress_dialog_loading);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            mLoadingKeepGoing = false;
        }
    });
    mProgressDialog.show();

    final CheapSoundFile.ProgressListener listener = new CheapSoundFile.ProgressListener() {
        public boolean reportProgress(double fractionComplete) {
            long now = System.currentTimeMillis();
            if (now - mLoadingLastUpdateTime > 100) {
                mProgressDialog.setProgress((int) (mProgressDialog.getMax() * fractionComplete));
                mLoadingLastUpdateTime = now;
            }
            return mLoadingKeepGoing;
        }
    };

    // Create the MediaPlayer in a background thread
    mCanSeekAccurately = false;
    new Thread() {
        public void run() {
            mCanSeekAccurately = SeekTest.CanSeekAccurately(getPreferences(Context.MODE_PRIVATE));

            System.out.println("Seek test done, creating media player.");
            try {
                MediaPlayer player = new MediaPlayer();
                player.setDataSource(mFile.getAbsolutePath());
                player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                player.prepare();
                mPlayer = player;
            } catch (final java.io.IOException e) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        handleFatalError("ReadError", getResources().getText(R.string.read_error), e);
                    }
                };
                mHandler.post(runnable);
            }
            ;
        }
    }.start();

    // Load the sound file in a background thread
    new Thread() {
        public void run() {
            try {
                mSoundFile = CheapSoundFile.create(mFile.getAbsolutePath(), listener);

                if (mSoundFile == null) {
                    mProgressDialog.dismiss();
                    String name = mFile.getName().toLowerCase();
                    String[] components = name.split("\\.");
                    String err;
                    if (components.length < 2) {
                        err = getResources().getString(R.string.no_extension_error);
                    } else {
                        err = getResources().getString(R.string.bad_extension_error) + " "
                                + components[components.length - 1];
                    }
                    final String finalErr = err;
                    Runnable runnable = new Runnable() {
                        public void run() {
                            handleFatalError("UnsupportedExtension", finalErr, new Exception());
                        }
                    };
                    mHandler.post(runnable);
                    return;
                }
            } catch (final Exception e) {
                mProgressDialog.dismiss();
                e.printStackTrace();
                mInfo.setText(e.toString());

                Runnable runnable = new Runnable() {
                    public void run() {
                        handleFatalError("ReadError", getResources().getText(R.string.read_error), e);
                    }
                };
                mHandler.post(runnable);
                return;
            }
            mProgressDialog.dismiss();
            if (mLoadingKeepGoing) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        finishOpeningSoundFile();
                    }
                };
                mHandler.post(runnable);
            } else {
                PTimerEditActivity.this.finish();
            }
        }
    }.start();
}

From source file:com.esri.arcgisruntime.generateofflinemapoverrides.MainActivity.java

/**
 * Shows a progress dialog for the given job.
 *
 * @param job to track progress from/*from   ww w .ja va2  s  . c  o  m*/
 */
private void showProgressDialog(Job job) {
    // create a progress dialog to show download progress
    ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setTitle("Generate Offline Map Job");
    progressDialog.setMessage("Taking map offline...");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setProgress(0);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", (dialog, which) -> job.cancel());
    progressDialog.show();

    // show the job's progress with the progress dialog
    job.addProgressChangedListener(() -> progressDialog.setProgress(job.getProgress()));

    // dismiss dialog when job is done
    job.addJobDoneListener(progressDialog::dismiss);
}

From source file:com.example.linhdq.test.documents.creation.NewDocumentActivity.java

@Override
protected Dialog onCreateDialog(int id, Bundle args) {
    switch (id) {

    case PDF_PROGRESS_DIALOG_ID:
        int max = args.getInt(DIALOG_ARG_MAX);
        String message = args.getString(DIALOG_ARG_MESSAGE);
        String title = args.getString(DIALOG_ARG_TITLE);
        pdfProgressDialog = new ProgressDialog(this);
        pdfProgressDialog.setMessage(message);
        pdfProgressDialog.setTitle(title);
        pdfProgressDialog.setIndeterminate(false);
        pdfProgressDialog.setMax(max);//from   w  w  w .ja va 2s.c  o  m
        pdfProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        pdfProgressDialog.setCancelable(false);
        return pdfProgressDialog;
    case DELETE_PROGRESS_DIALOG_ID:
        max = args.getInt(DIALOG_ARG_MAX);
        message = args.getString(DIALOG_ARG_MESSAGE);
        deleteProgressDialog = new ProgressDialog(this);
        deleteProgressDialog.setMessage(message);
        deleteProgressDialog.setIndeterminate(false);
        deleteProgressDialog.setMax(max);
        deleteProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        deleteProgressDialog.setCancelable(false);
        return deleteProgressDialog;
    case EDIT_TITLE_DIALOG_ID:
        View layout = getLayoutInflater().inflate(R.layout.dialog_edit_title, null);
        final Uri documentUri = Uri.parse(args.getString(DIALOG_ARG_DOCUMENT_URI));
        final String oldTitle = args.getString(DIALOG_ARG_TITLE);
        final EditText edit = (EditText) layout.findViewById(R.id.edit_title);
        edit.setText(oldTitle);

        Builder builder = new Builder(this);
        builder.setView(layout);
        builder.setTitle(R.string.edit_dialog_title);
        builder.setIcon(R.drawable.fairy_showing);
        builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                final String title = edit.getText().toString();
                saveTitle(title, documentUri);

            }
        });
        builder.setNegativeButton(R.string.cancel, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.show();
    }
    return super.onCreateDialog(id, args);
}

From source file:com.SpeechEd.SpeechEdEditActivity.java

private void loadFromFile() {
    mFile = new File(mFilename);
    mExtension = getExtensionFromFilename(mFilename);

    SongMetadataReader metadataReader = new SongMetadataReader(this, mFilename);
    mTitle = metadataReader.mTitle;/*from  w w w.  ja  v  a 2s  .com*/
    mArtist = metadataReader.mArtist;
    mAlbum = metadataReader.mAlbum;
    mYear = metadataReader.mYear;
    mGenre = metadataReader.mGenre;

    String titleLabel = mTitle;
    if (mArtist != null && mArtist.length() > 0) {
        titleLabel += " - " + mArtist;
    }
    setTitle(titleLabel);

    mLoadingStartTime = System.currentTimeMillis();
    mLoadingLastUpdateTime = System.currentTimeMillis();
    mLoadingKeepGoing = true;
    mProgressDialog = new ProgressDialog(SpeechEdEditActivity.this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle(R.string.progress_dialog_loading);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            mLoadingKeepGoing = false;
        }
    });
    mProgressDialog.show();

    final CheapSoundFile.ProgressListener listener = new CheapSoundFile.ProgressListener() {
        public boolean reportProgress(double fractionComplete) {
            long now = System.currentTimeMillis();
            if (now - mLoadingLastUpdateTime > 100) {
                mProgressDialog.setProgress((int) (mProgressDialog.getMax() * fractionComplete));
                mLoadingLastUpdateTime = now;
            }
            return mLoadingKeepGoing;
        }
    };

    // Create the MediaPlayer in a background thread
    mCanSeekAccurately = false;
    new Thread() {
        public void run() {
            mCanSeekAccurately = SeekTest.CanSeekAccurately(getPreferences(Context.MODE_PRIVATE));

            System.out.println("Seek test done, creating media player.");
            try {
                MediaPlayer player = new MediaPlayer();
                player.setDataSource(mFile.getAbsolutePath());
                player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                player.prepare();
                mPlayer = player;
            } catch (final java.io.IOException e) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        handleFatalError("ReadError", getResources().getText(R.string.read_error), e);
                    }
                };
                mHandler.post(runnable);
            }
            ;
        }
    }.start();

    // Load the sound file in a background thread
    new Thread() {
        public void run() {
            try {
                mSoundFile = CheapSoundFile.create(mFile.getAbsolutePath(), listener);

                if (mSoundFile == null) {
                    mProgressDialog.dismiss();
                    String name = mFile.getName().toLowerCase();
                    String[] components = name.split("\\.");
                    String err;
                    if (components.length < 2) {
                        err = getResources().getString(R.string.no_extension_error);
                    } else {
                        err = getResources().getString(R.string.bad_extension_error) + " "
                                + components[components.length - 1];
                    }
                    final String finalErr = err;
                    Runnable runnable = new Runnable() {
                        public void run() {
                            handleFatalError("UnsupportedExtension", finalErr, new Exception());
                        }
                    };
                    mHandler.post(runnable);
                    return;
                }
            } catch (final Exception e) {
                mProgressDialog.dismiss();
                e.printStackTrace();
                mInfo.setText(e.toString());

                Runnable runnable = new Runnable() {
                    public void run() {
                        handleFatalError("ReadError", getResources().getText(R.string.read_error), e);
                    }
                };
                mHandler.post(runnable);
                return;
            }
            mProgressDialog.dismiss();
            if (mLoadingKeepGoing) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        finishOpeningSoundFile();
                    }
                };
                mHandler.post(runnable);
            } else {
                SpeechEdEditActivity.this.finish();
            }
        }
    }.start();
}

From source file:com.ringdroid.RingdroidEditActivity.java

private void loadFromFile() {
    mFile = new File(mFilename);
    mExtension = getExtensionFromFilename(mFilename);

    SongMetadataReader metadataReader = new SongMetadataReader(this, mFilename);
    mTitle = metadataReader.mTitle;/*ww w.j  ava  2  s  .c o m*/
    mArtist = metadataReader.mArtist;
    mAlbum = metadataReader.mAlbum;
    mYear = metadataReader.mYear;
    mGenre = metadataReader.mGenre;

    String titleLabel = mTitle;
    if (mArtist != null && mArtist.length() > 0) {
        titleLabel += " - " + mArtist;
    }
    setTitle(Utils.convertGBK(titleLabel));

    mLoadingStartTime = System.currentTimeMillis();
    mLoadingLastUpdateTime = System.currentTimeMillis();
    mLoadingKeepGoing = true;
    mProgressDialog = new ProgressDialog(RingdroidEditActivity.this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setTitle(R.string.progress_dialog_loading);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            mLoadingKeepGoing = false;
        }
    });
    mProgressDialog.show();

    final CheapSoundFile.ProgressListener listener = new CheapSoundFile.ProgressListener() {
        public boolean reportProgress(double fractionComplete) {
            long now = System.currentTimeMillis();
            if (now - mLoadingLastUpdateTime > 100) {
                mProgressDialog.setProgress((int) (mProgressDialog.getMax() * fractionComplete));
                mLoadingLastUpdateTime = now;
            }
            return mLoadingKeepGoing;
        }
    };

    // Create the MediaPlayer in a background thread
    mCanSeekAccurately = false;
    new Thread() {
        public void run() {
            mCanSeekAccurately = SeekTest.CanSeekAccurately(getPreferences(Context.MODE_PRIVATE));

            System.out.println("Seek test done, creating media player.");
            try {
                MediaPlayer player = new MediaPlayer();
                player.setDataSource(mFile.getAbsolutePath());
                player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                player.prepare();
                mPlayer = player;
            } catch (final java.io.IOException e) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        handleFatalError("ReadError", getResources().getText(R.string.read_error), e);
                    }
                };
                mHandler.post(runnable);
            }
            ;
        }
    }.start();

    // Load the sound file in a background thread
    new Thread() {
        public void run() {
            try {
                mSoundFile = CheapSoundFile.create(mFile.getAbsolutePath(), listener);

                if (mSoundFile == null) {
                    String name = mFile.getName().toLowerCase();
                    String[] components = name.split("\\.");
                    String err;
                    if (components.length < 2) {
                        err = getResources().getString(R.string.no_extension_error);
                    } else {
                        err = getResources().getString(R.string.bad_extension_error) + " "
                                + components[components.length - 1];
                    }
                    final String finalErr = err;
                    Runnable runnable = new Runnable() {
                        public void run() {
                            mProgressDialog.dismiss();
                            handleFatalError("UnsupportedExtension", finalErr, new Exception());
                        }
                    };
                    mHandler.post(runnable);
                    return;
                }
            } catch (final Exception e) {
                e.printStackTrace();

                Runnable runnable = new Runnable() {
                    public void run() {
                        mProgressDialog.dismiss();
                        mInfo.setText(e.toString());
                        handleFatalError("ReadError", getResources().getText(R.string.read_error), e);
                    }
                };
                mHandler.post(runnable);
                return;
            }
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    mProgressDialog.dismiss();
                }

            });
            if (mLoadingKeepGoing) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        finishOpeningSoundFile();
                    }
                };
                mHandler.post(runnable);
            } else {
                RingdroidEditActivity.this.finish();
            }
        }
    }.start();
}