예제 #1
0
 /**
  * 创建Dialog
  *
  * @param context
  * @return
  */
 public static CustomProgressDialog createDialog(Context context, Activity activity) {
   mContext = context;
   allDialog = new ArrayList<CustomProgressDialog>();
   customProgressDialog = new CustomProgressDialog(context, R.style.CustomProgressDialog);
   CustomProgressDialog.activity = activity;
   customProgressDialog.setContentView(R.layout.customprogressdialog);
   customProgressDialog.getWindow().getAttributes().gravity = Gravity.CENTER;
   // tv = (TextView) customProgressDialog
   // .findViewById(R.id.id_tv_loadingmsg);
   // tv.setText("正在拼命加载...");
   return customProgressDialog;
 }
예제 #2
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     if (customProgressDialog != null) {
       if (activity != null) {
         activity.finish();
       }
       if (customProgressDialog.isShowing()) {
         customProgressDialog.stopProgressDialog(customProgressDialog);
         customProgressDialog = null;
         return true;
       }
     }
   }
   return super.onKeyDown(keyCode, event);
 }
예제 #3
0
 public void onWindowFocusChanged(boolean hasFocus) {
   if (customProgressDialog == null) {
     return;
   }
   ImageView imageView = (ImageView) customProgressDialog.findViewById(R.id.loadingImageView);
   AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
   animationDrawable.start();
 }
예제 #4
0
 /** 停止 */
 public void stopProgressDialog(CustomProgressDialog customProgressDialog) {
   if (customProgressDialog != null) {
     customProgressDialog.dismiss();
     // customProgressDialog=null;
     allDialog.remove(customProgressDialog);
     System.gc();
   }
 }
예제 #5
0
 /** 开始 */
 public void startProgressDialog(CustomProgressDialog customProgressDialog) {
   if (customProgressDialog != null) {
     if (isNetWorkAvailable.isNetWork(activity)) {
       customProgressDialog.show();
       allDialog.add(customProgressDialog);
     }
   }
 }