/**
  * 创建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;
 }
 @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);
 }
 public void onWindowFocusChanged(boolean hasFocus) {
   if (customProgressDialog == null) {
     return;
   }
   ImageView imageView = (ImageView) customProgressDialog.findViewById(R.id.loadingImageView);
   AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
   animationDrawable.start();
 }
 /** 停止 */
 public void stopProgressDialog(CustomProgressDialog customProgressDialog) {
   if (customProgressDialog != null) {
     customProgressDialog.dismiss();
     // customProgressDialog=null;
     allDialog.remove(customProgressDialog);
     System.gc();
   }
 }
 /** 开始 */
 public void startProgressDialog(CustomProgressDialog customProgressDialog) {
   if (customProgressDialog != null) {
     if (isNetWorkAvailable.isNetWork(activity)) {
       customProgressDialog.show();
       allDialog.add(customProgressDialog);
     }
   }
 }