Search in sources :

Example 1 with BaseProgressDialog

use of com.yuan.dependonlibrary._11___Widget.promptBox.BaseProgressDialog in project developmentDependencyLibrary by MatchlessBrother.

the class PromptBoxTools method showLoadingDialog.

/**
 **与服务器开始通讯时默认弹出的对话框1:代表的是圆圈旋转进度框,2:代表的是飞机飞行进度框****
 */
public static BaseProgressDialog showLoadingDialog(Context context, String msg, int themeStyleValue, boolean isCanceledOnTouchOutside, BaseProgressDialog.OnClickOutsideListener onClickOutsideListener) {
    BaseProgressDialog progressDialog = new BaseProgressDialog(context);
    progressDialog.setCanceledOnTouchOutside(isCanceledOnTouchOutside);
    progressDialog.setMessage(msg.trim());
    progressDialog.show();
    View contentView = null;
    ImageView imageView = null;
    AnimationDrawable animation = null;
    if (themeStyleValue == 1) {
        contentView = ResourceTools.generateView(context, R.layout.inflater_progressdialogdefault);
        imageView = (ImageView) contentView.findViewById(R.id.defaultthemeimg);
        animation = new AnimationDrawable();
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault1), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault2), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault3), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault4), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault5), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault6), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault7), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault8), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault9), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault10), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault11), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault12), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault13), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault14), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault15), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault16), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault17), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault18), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault19), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault20), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault21), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault22), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault23), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault24), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault25), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault26), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault27), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault28), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault29), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogdefault30), 45);
        animation.setOneShot(false);
        imageView.setBackgroundDrawable(animation);
        if (animation != null && !animation.isRunning())
            animation.start();
    } else {
        contentView = ResourceTools.generateView(context, R.layout.inflater_progressdialogplane);
        imageView = (ImageView) contentView.findViewById(R.id.planethemeimg);
        animation = new AnimationDrawable();
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane1), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane2), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane3), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane4), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane5), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane6), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane7), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane8), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane9), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane10), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane11), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane12), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane13), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane14), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane15), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane16), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane17), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane18), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane19), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane20), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane21), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane22), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane23), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane24), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane25), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane26), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane27), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane28), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane29), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane30), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane31), 45);
        animation.addFrame(context.getResources().getDrawable(R.drawable.progressdialogplane32), 45);
        animation.setOneShot(false);
        imageView.setBackgroundDrawable(animation);
        if (animation != null && !animation.isRunning())
            animation.start();
    }
    progressDialog.setContentView(contentView);
    if (null != onClickOutsideListener)
        progressDialog.setOnClickOutsideListener(onClickOutsideListener);
    Window window = progressDialog.getWindow();
    window.getDecorView().setPadding(0, 0, 0, 0);
    window.getDecorView().setBackgroundResource(R.color.transparent);
    DisplayMetrics displayMetrics = new DisplayMetrics();
    ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(displayMetrics);
    WindowManager.LayoutParams params = window.getAttributes();
    params.width = PixelConvertedTools.dpTpx(context, 110);
    params.gravity = Gravity.CENTER;
    window.setAttributes(params);
    return progressDialog;
}
Also used : Window(android.view.Window) AnimationDrawable(android.graphics.drawable.AnimationDrawable) ImageView(android.widget.ImageView) BaseProgressDialog(com.yuan.dependonlibrary._11___Widget.promptBox.BaseProgressDialog) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

Aggregations

AnimationDrawable (android.graphics.drawable.AnimationDrawable)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 Window (android.view.Window)1 WindowManager (android.view.WindowManager)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BaseProgressDialog (com.yuan.dependonlibrary._11___Widget.promptBox.BaseProgressDialog)1