Methods Summary |
---|
public int | getMax()
if (mProgress != null) {
return mProgress.getMax();
}
return mMax;
|
public int | getProgress()
if (mProgress != null) {
return mProgress.getProgress();
}
return mProgressVal;
|
public int | getSecondaryProgress()
if (mProgress != null) {
return mProgress.getSecondaryProgress();
}
return mSecondaryProgressVal;
|
public void | incrementProgressBy(int diff)
if (mProgress != null) {
mProgress.incrementProgressBy(diff);
onProgressChanged();
} else {
mIncrementBy += diff;
}
|
public void | incrementSecondaryProgressBy(int diff)
if (mProgress != null) {
mProgress.incrementSecondaryProgressBy(diff);
onProgressChanged();
} else {
mIncrementSecondaryBy += diff;
}
|
private void | initFormats()
mProgressNumberFormat = "%1d/%2d";
mProgressPercentFormat = NumberFormat.getPercentInstance();
mProgressPercentFormat.setMaximumFractionDigits(0);
|
public boolean | isIndeterminate()
if (mProgress != null) {
return mProgress.isIndeterminate();
}
return mIndeterminate;
|
protected void | onCreate(android.os.Bundle savedInstanceState)
LayoutInflater inflater = LayoutInflater.from(mContext);
TypedArray a = mContext.obtainStyledAttributes(null,
com.android.internal.R.styleable.AlertDialog,
com.android.internal.R.attr.alertDialogStyle, 0);
if (mProgressStyle == STYLE_HORIZONTAL) {
/* Use a separate handler to update the text views as they
* must be updated on the same thread that created them.
*/
mViewUpdateHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
/* Update the number and percent */
int progress = mProgress.getProgress();
int max = mProgress.getMax();
if (mProgressNumberFormat != null) {
String format = mProgressNumberFormat;
mProgressNumber.setText(String.format(format, progress, max));
} else {
mProgressNumber.setText("");
}
if (mProgressPercentFormat != null) {
double percent = (double) progress / (double) max;
SpannableString tmp = new SpannableString(mProgressPercentFormat.format(percent));
tmp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
0, tmp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mProgressPercent.setText(tmp);
} else {
mProgressPercent.setText("");
}
}
};
View view = inflater.inflate(a.getResourceId(
com.android.internal.R.styleable.AlertDialog_horizontalProgressLayout,
R.layout.alert_dialog_progress), null);
mProgress = (ProgressBar) view.findViewById(R.id.progress);
mProgressNumber = (TextView) view.findViewById(R.id.progress_number);
mProgressPercent = (TextView) view.findViewById(R.id.progress_percent);
setView(view);
} else {
View view = inflater.inflate(a.getResourceId(
com.android.internal.R.styleable.AlertDialog_progressLayout,
R.layout.progress_dialog), null);
mProgress = (ProgressBar) view.findViewById(R.id.progress);
mMessageView = (TextView) view.findViewById(R.id.message);
setView(view);
}
a.recycle();
if (mMax > 0) {
setMax(mMax);
}
if (mProgressVal > 0) {
setProgress(mProgressVal);
}
if (mSecondaryProgressVal > 0) {
setSecondaryProgress(mSecondaryProgressVal);
}
if (mIncrementBy > 0) {
incrementProgressBy(mIncrementBy);
}
if (mIncrementSecondaryBy > 0) {
incrementSecondaryProgressBy(mIncrementSecondaryBy);
}
if (mProgressDrawable != null) {
setProgressDrawable(mProgressDrawable);
}
if (mIndeterminateDrawable != null) {
setIndeterminateDrawable(mIndeterminateDrawable);
}
if (mMessage != null) {
setMessage(mMessage);
}
setIndeterminate(mIndeterminate);
onProgressChanged();
super.onCreate(savedInstanceState);
|
private void | onProgressChanged()
if (mProgressStyle == STYLE_HORIZONTAL) {
if (mViewUpdateHandler != null && !mViewUpdateHandler.hasMessages(0)) {
mViewUpdateHandler.sendEmptyMessage(0);
}
}
|
public void | onStart()
super.onStart();
mHasStarted = true;
|
protected void | onStop()
super.onStop();
mHasStarted = false;
|
public void | setIndeterminate(boolean indeterminate)
if (mProgress != null) {
mProgress.setIndeterminate(indeterminate);
} else {
mIndeterminate = indeterminate;
}
|
public void | setIndeterminateDrawable(android.graphics.drawable.Drawable d)
if (mProgress != null) {
mProgress.setIndeterminateDrawable(d);
} else {
mIndeterminateDrawable = d;
}
|
public void | setMax(int max)
if (mProgress != null) {
mProgress.setMax(max);
onProgressChanged();
} else {
mMax = max;
}
|
public void | setMessage(java.lang.CharSequence message)
if (mProgress != null) {
if (mProgressStyle == STYLE_HORIZONTAL) {
super.setMessage(message);
} else {
mMessageView.setText(message);
}
} else {
mMessage = message;
}
|
public void | setProgress(int value)
if (mHasStarted) {
mProgress.setProgress(value);
onProgressChanged();
} else {
mProgressVal = value;
}
|
public void | setProgressDrawable(android.graphics.drawable.Drawable d)
if (mProgress != null) {
mProgress.setProgressDrawable(d);
} else {
mProgressDrawable = d;
}
|
public void | setProgressNumberFormat(java.lang.String format)Change the format of the small text showing current and maximum units
of progress. The default is "%1d/%2d".
Should not be called during the number is progressing.
mProgressNumberFormat = format;
onProgressChanged();
|
public void | setProgressPercentFormat(java.text.NumberFormat format)Change the format of the small text showing the percentage of progress.
The default is
{@link NumberFormat#getPercentInstance() NumberFormat.getPercentageInstnace().}
Should not be called during the number is progressing.
mProgressPercentFormat = format;
onProgressChanged();
|
public void | setProgressStyle(int style)
mProgressStyle = style;
|
public void | setSecondaryProgress(int secondaryProgress)
if (mProgress != null) {
mProgress.setSecondaryProgress(secondaryProgress);
onProgressChanged();
} else {
mSecondaryProgressVal = secondaryProgress;
}
|
public static android.app.ProgressDialog | show(android.content.Context context, java.lang.CharSequence title, java.lang.CharSequence message)
return show(context, title, message, false);
|
public static android.app.ProgressDialog | show(android.content.Context context, java.lang.CharSequence title, java.lang.CharSequence message, boolean indeterminate)
return show(context, title, message, indeterminate, false, null);
|
public static android.app.ProgressDialog | show(android.content.Context context, java.lang.CharSequence title, java.lang.CharSequence message, boolean indeterminate, boolean cancelable)
return show(context, title, message, indeterminate, cancelable, null);
|
public static android.app.ProgressDialog | show(android.content.Context context, java.lang.CharSequence title, java.lang.CharSequence message, boolean indeterminate, boolean cancelable, OnCancelListener cancelListener)
ProgressDialog dialog = new ProgressDialog(context);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setIndeterminate(indeterminate);
dialog.setCancelable(cancelable);
dialog.setOnCancelListener(cancelListener);
dialog.show();
return dialog;
|