Esempio n. 1
0
  public static ProgressDialog buildProgressDialog(Context context, boolean cancelble) {
    final ProgressDialog dialog =
        new ProgressDialog(context, ResourceUtils.getStyleId(context, "LoadingDialog"));
    // 设置window type
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
    } else {
      dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
    }

    try {
      if (context instanceof Activity) {
        if (!((Activity) context).isFinishing()) {
          dialog.show();
        }
      } else {
        dialog.show();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    dialog.setContentView(ResourceUtils.getLayoutId(context, "pj_layout_progressbar"));
    ImageView loading = (ImageView) dialog.findViewById(ResourceUtils.getId(context, "iv_loading"));
    AnimationDrawable anim = (AnimationDrawable) loading.getBackground();
    anim.start();
    dialog.setCancelable(cancelble);
    return dialog;
  }
 @Override
 protected void onPreExecute() {
   pDialog = new ProgressDialog(mContext);
   pDialog.setMessage("Loading...");
   pDialog.show();
   TextView tv1 = (TextView) pDialog.findViewById(android.R.id.message);
   tv1.setTypeface(Typeface.SANS_SERIF);
   tv1.setTextColor(mRes.getColor(R.color.white));
   if (titleProgressBar != null) titleProgressBar.setVisibility(View.VISIBLE);
 }
Esempio n. 3
0
 public static ProgressDialog buildProgressDialog(Context context, String msg, boolean cancelble) {
   final ProgressDialog dialog =
       new ProgressDialog(context, ResourceUtils.getStyleId(context, "LoadingDialog"));
   // 设置window type
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
     dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
   } else {
     dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
   }
   dialog.show();
   dialog.setContentView(ResourceUtils.getLayoutId(context, "pj_layout_progressbar"));
   ImageView loading = (ImageView) dialog.findViewById(ResourceUtils.getId(context, "iv_loading"));
   AnimationDrawable anim = (AnimationDrawable) loading.getBackground();
   anim.start();
   ((TextView) dialog.findViewById(ResourceUtils.getId(context, "tv_progressbar_message")))
       .setText(msg);
   dialog.setCancelable(cancelble);
   return dialog;
 }
 @Override
 protected void onPreExecute() {
   super.onPreExecute();
   progressDialog = new ProgressDialog(context);
   progressDialog.setCancelable(false);
   progressDialog.setIndeterminate(false);
   progressDialog.show();
   progressDialog.setContentView(R.layout.custom_progress_bar);
   tvCommand = (TextView) progressDialog.findViewById(R.id.tvCommand);
   tvCommand.setText(context.getString(R.string.uploading));
 }
Esempio n. 5
0
  public static ProgressDialog createProgressDialogWithMessage(Context mContext, String msg) {
    ProgressDialog dialog = new ProgressDialog(mContext);
    try {
      dialog.show();
    } catch (WindowManager.BadTokenException e) {

    }
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.progressdialog);

    CustomTextView lblLoadingMessage = (CustomTextView) dialog.findViewById(R.id.lblLoadingMessage);
    lblLoadingMessage.setVisibility(View.VISIBLE);

    lblLoadingMessage.setText(msg);

    Window window = dialog.getWindow();
    WindowManager.LayoutParams windowParams = window.getAttributes();

    windowParams.dimAmount = 0.90f;
    windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    window.setAttributes(windowParams);
    // dialog.setMessage(Message);
    return dialog;
  }