Search in sources :

Example 1 with IndeterminateProgressDrawable

use of me.zhanghai.android.materialprogressbar.IndeterminateProgressDrawable in project material-dialogs by afollestad.

the class DialogInit method setupProgressDialog.

private static void setupProgressDialog(final MaterialDialog dialog) {
    final MaterialDialog.Builder builder = dialog.builder;
    if (builder.indeterminateProgress || builder.progress > -2) {
        dialog.progressBar = (ProgressBar) dialog.view.findViewById(android.R.id.progress);
        if (dialog.progressBar == null) {
            return;
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            if (builder.indeterminateProgress) {
                if (builder.indeterminateIsHorizontalProgress) {
                    IndeterminateHorizontalProgressDrawable d = new IndeterminateHorizontalProgressDrawable(builder.getContext());
                    d.setTint(builder.widgetColor);
                    dialog.progressBar.setProgressDrawable(d);
                    dialog.progressBar.setIndeterminateDrawable(d);
                } else {
                    IndeterminateProgressDrawable d = new IndeterminateProgressDrawable(builder.getContext());
                    d.setTint(builder.widgetColor);
                    dialog.progressBar.setProgressDrawable(d);
                    dialog.progressBar.setIndeterminateDrawable(d);
                }
            } else {
                HorizontalProgressDrawable d = new HorizontalProgressDrawable(builder.getContext());
                d.setTint(builder.widgetColor);
                dialog.progressBar.setProgressDrawable(d);
                dialog.progressBar.setIndeterminateDrawable(d);
            }
        } else {
            MDTintHelper.setTint(dialog.progressBar, builder.widgetColor);
        }
        if (!builder.indeterminateProgress || builder.indeterminateIsHorizontalProgress) {
            dialog.progressBar.setIndeterminate(builder.indeterminateProgress && builder.indeterminateIsHorizontalProgress);
            dialog.progressBar.setProgress(0);
            dialog.progressBar.setMax(builder.progressMax);
            dialog.progressLabel = (TextView) dialog.view.findViewById(R.id.md_label);
            if (dialog.progressLabel != null) {
                dialog.progressLabel.setTextColor(builder.contentColor);
                dialog.setTypeface(dialog.progressLabel, builder.mediumFont);
                dialog.progressLabel.setText(builder.progressPercentFormat.format(0));
            }
            dialog.progressMinMax = (TextView) dialog.view.findViewById(R.id.md_minMax);
            if (dialog.progressMinMax != null) {
                dialog.progressMinMax.setTextColor(builder.contentColor);
                dialog.setTypeface(dialog.progressMinMax, builder.regularFont);
                if (builder.showMinMax) {
                    dialog.progressMinMax.setVisibility(View.VISIBLE);
                    dialog.progressMinMax.setText(String.format(builder.progressNumberFormat, 0, builder.progressMax));
                    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) dialog.progressBar.getLayoutParams();
                    lp.leftMargin = 0;
                    lp.rightMargin = 0;
                } else {
                    dialog.progressMinMax.setVisibility(View.GONE);
                }
            } else {
                builder.showMinMax = false;
            }
        }
    }
    if (dialog.progressBar != null) {
        fixCanvasScalingWhenHardwareAccelerated(dialog.progressBar);
    }
}
Also used : IndeterminateProgressDrawable(me.zhanghai.android.materialprogressbar.IndeterminateProgressDrawable) IndeterminateHorizontalProgressDrawable(me.zhanghai.android.materialprogressbar.IndeterminateHorizontalProgressDrawable) HorizontalProgressDrawable(me.zhanghai.android.materialprogressbar.HorizontalProgressDrawable) ViewGroup(android.view.ViewGroup) IndeterminateHorizontalProgressDrawable(me.zhanghai.android.materialprogressbar.IndeterminateHorizontalProgressDrawable)

Aggregations

ViewGroup (android.view.ViewGroup)1 HorizontalProgressDrawable (me.zhanghai.android.materialprogressbar.HorizontalProgressDrawable)1 IndeterminateHorizontalProgressDrawable (me.zhanghai.android.materialprogressbar.IndeterminateHorizontalProgressDrawable)1 IndeterminateProgressDrawable (me.zhanghai.android.materialprogressbar.IndeterminateProgressDrawable)1