public static void showAuthErrorView(Activity activity, int titleResId, int messageResId) {
    final String ALERT_TAG = "alert_ask_credentials";
    if (activity.isFinishing()) {
      return;
    }

    // WP.com errors will show the sign in activity
    if (WordPress.getCurrentBlog() == null
        || (WordPress.getCurrentBlog() != null && WordPress.getCurrentBlog().isDotcomFlag())) {
      Intent signInIntent = new Intent(activity, SignInActivity.class);
      signInIntent.putExtra(SignInActivity.ARG_IS_AUTH_ERROR, true);
      signInIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
      activity.startActivityForResult(signInIntent, SignInActivity.REQUEST_CODE);
      return;
    }

    // abort if the dialog is already visible
    if (activity.getFragmentManager().findFragmentByTag(ALERT_TAG) != null) {
      return;
    }

    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    AuthErrorDialogFragment authAlert = new AuthErrorDialogFragment();
    authAlert.setWPComTitleMessage(titleResId, messageResId);
    ft.add(authAlert, ALERT_TAG);
    ft.commitAllowingStateLoss();
  }
Ejemplo n.º 2
1
  private void jumpToCancel() {
    if (myActivity != null && !myActivity.isFinishing()) {
      try {
        AlipayApplication application = (AlipayApplication) myActivity.getApplication();
        application
            .getDataHelper()
            .showDialog(
                myActivity,
                0,
                "",
                myActivity.getResources().getString(R.string.CancelDownload),
                myActivity.getResources().getString(R.string.Yes),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    mCanceled = true;
                    endProcess();
                  }
                },
                myActivity.getResources().getString(R.string.No),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                  }
                },
                null,
                null);
      } catch (Exception e) {

      }
    }
  }
 public void onProgressChanged(WebView webView, int progress) {
   if (!mActivity.isFinishing()) {
     mActivity.setTitle(webView.getTitle());
   }
   if (progress == 100) {
     mProgressBar.setVisibility(View.GONE);
   } else {
     mProgressBar.setVisibility(View.VISIBLE);
     mProgressBar.setProgress(progress);
   }
 }
Ejemplo n.º 4
0
 @SuppressLint("NewApi")
 public static boolean isActivityValid(@Nullable final Activity activity) {
   if (activity == null) {
     return false;
   } else {
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
       return !activity.isFinishing() && !activity.isDestroyed();
     } else {
       return !activity.isFinishing();
     }
   }
 }
 /** 在拖动的时候执行 */
 @Override
 protected void onScrollChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
   // TODO Auto-generated method stub
   super.onScrollChanged(paramInt1, paramInt2, paramInt3, paramInt4);
   shade_ShowOrHide();
   if (!activity.isFinishing()
       && ll_content != null
       && leftImage != null
       && rightImage != null
       && ll_more != null
       && rl_column != null) {
     if (ll_content.getWidth() <= mScreenWitdh) {
       leftImage.setVisibility(View.GONE);
       rightImage.setVisibility(View.GONE);
     }
   } else {
     return;
   }
   if (paramInt1 == 0) {
     leftImage.setVisibility(View.GONE);
     rightImage.setVisibility(View.VISIBLE);
     return;
   }
   if (ll_content.getWidth() - paramInt1 + ll_more.getWidth() + rl_column.getLeft()
       == mScreenWitdh) {
     leftImage.setVisibility(View.VISIBLE);
     rightImage.setVisibility(View.GONE);
     return;
   }
   leftImage.setVisibility(View.VISIBLE);
   rightImage.setVisibility(View.VISIBLE);
 }
Ejemplo n.º 6
0
 /** 结束指定的Activity */
 public void finishActivity(Activity activity) {
   if (activity != null && !activity.isFinishing()) {
     activityStack.remove(activity);
     activity.finish();
     activity = null;
   }
 }
    @Override
    protected void onPostExecute(Void v) {
      if (mContextHost instanceof Activity) {
        Log.i(TAG, "[onPostExecute]: activity find");
        Activity activity = (Activity) mContextHost;
        if (activity.isFinishing()) {
          Log.i(TAG, "[onPostExecute]: activity finish");
          return;
        }
      }

      Drawable icon =
          mContext.getResources().getDrawable(R.drawable.ic_menu_look_simstorage_holo_light);
      String string = mContext.getResources().getString(R.string.look_simstorage);
      sInstance = null;
      if (!mIsCancelled && !mIsException) {
        new AlertDialog.Builder(mContextHost)
            .setIcon(icon)
            .setTitle(string)
            .setMessage(mDlgContent)
            .setPositiveButton(android.R.string.ok, null)
            .setCancelable(true)
            .create()
            .show();
      }
      mIsCancelled = false;
      mIsException = false;
    }
Ejemplo n.º 8
0
  @Override
  protected void onPostExecute(Void aVoid) {
    super.onPostExecute(aVoid);

    if (!activity.isFinishing() && progress_dialog.isShowing()) {
      progress_dialog.dismiss();
    }

    if (passExporter.exception != null) {
      App.component()
          .tracker()
          .trackException("passExporterException", passExporter.exception, false);
      Toast.makeText(activity, "could not export pass " + passExporter.exception, Toast.LENGTH_LONG)
          .show();
      return;
    }

    if (share_after_export) {
      final Intent it = new Intent(Intent.ACTION_SEND);
      it.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.passbook_is_shared_subject));
      it.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + passExporter.fullZipFileName));
      it.setType("application/vnd.apple.pkpass");
      activity.startActivity(
          Intent.createChooser(it, activity.getString(R.string.passbook_share_chooser_title)));
    }
  }
Ejemplo n.º 9
0
  /**
   * 显示进度条对话框
   *
   * @param activity
   * @param popupWindow
   * @param title
   */
  public static void showProgressDialog(
      Activity activity, LoadingPopupWindow popupWindow, String title) {
    if ((activity == null || activity.isFinishing()) || (popupWindow == null)) {
      return;
    }

    final LoadingPopupWindow tmpPopupWindow = popupWindow;
    View popupView = popupWindow.getContentView();
    if (popupView != null) {
      TextView tvTitlename = (TextView) popupView.findViewById(R.id.tv_titlename);
      if (tvTitlename != null && !title.isEmpty()) {
        tvTitlename.setText(title);
      }
    }

    if (popupWindow != null && !popupWindow.isShowing()) {
      final View rootView1 =
          ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
      rootView1.post(
          new Runnable() {

            @Override
            public void run() {
              try {
                tmpPopupWindow.showAtLocation(rootView1, Gravity.CENTER, 0, 0);
                tmpPopupWindow.startAnimation();
              } catch (Exception e) {
                Global.errorLog(e);
              }
            }
          });
    }
  }
Ejemplo n.º 10
0
 public static void finishAll() {
   for (Activity activity : activities) {
     if (!activity.isFinishing()) {
       activity.finish();
     }
   }
 }
 /** 判断左右阴影的显示隐藏效果 */
 public void shade_ShowOrHide() {
   if (!activity.isFinishing() && ll_content != null) {
     measure(0, 0);
     // 如果整体宽度小于屏幕宽度的话,那左右阴影都隐藏
     if (mScreenWitdh >= getMeasuredWidth()) {
       leftImage.setVisibility(View.GONE);
       rightImage.setVisibility(View.GONE);
     }
   } else {
     return;
   }
   // 如果滑动在最左边时候,左边阴影隐藏,右边显示
   if (getLeft() == 0) {
     leftImage.setVisibility(View.GONE);
     rightImage.setVisibility(View.VISIBLE);
     return;
   }
   // 如果滑动在最右边时候,左边阴影显示,右边隐藏
   if (getRight() == getMeasuredWidth() - mScreenWitdh) {
     leftImage.setVisibility(View.VISIBLE);
     rightImage.setVisibility(View.GONE);
     return;
   }
   // 否则,说明在中间位置,左、右阴影都显示
   leftImage.setVisibility(View.VISIBLE);
   rightImage.setVisibility(View.VISIBLE);
 }
Ejemplo n.º 12
0
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 protected boolean isValidContext(Activity a) {
   if (Build.VERSION.SDK_INT >= 17) {
     if (a.isDestroyed() || a.isFinishing()) {
       return false;
     } else {
       return true;
     }
   } else {
     if (a.isFinishing()) {
       return false;
     } else {
       return true;
     }
   }
 }
Ejemplo n.º 13
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 防止第三方跳转时出现双实例
    Activity aty = AppManager.getActivity(MainActivity.class);
    if (aty != null && !aty.isFinishing()) {
      finish();
    }

    final View view = View.inflate(this, R.layout.app_start, null);
    setContentView(view);
    // 渐变展示启动屏
    AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f);
    aa.setDuration(800);
    view.startAnimation(aa);
    aa.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationEnd(Animation arg0) {
            redirectTo();
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationStart(Animation animation) {}
        });
  }
Ejemplo n.º 14
0
 /** Activity被销毁时,从Activities中移除 */
 public synchronized void unregister(Activity activity) {
   if (activities.size() != 0) {
     activities.remove(activity);
     if (!activity.isFinishing()) {
       activity.finish();
     }
   } else {
   }
 }
Ejemplo n.º 15
0
 public static ProgressDialog showSpinnerDialog(Activity activity) {
   ProgressDialog dialog = new ProgressDialog(activity);
   dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   dialog.setCancelable(true);
   dialog.setMessage(activity.getString(R.string.chat_utils_hardLoading));
   if (!activity.isFinishing()) {
     dialog.show();
   }
   return dialog;
 }
Ejemplo n.º 16
0
  @Test
  public void onKeyUp_callsOnBackPressedWhichFinishesTheActivity() throws Exception {
    Activity activity = new Activity();
    boolean consumed =
        activity.onKeyUp(
            KeyEvent.KEYCODE_BACK, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK));

    assertTrue(consumed);
    assertTrue(shadowOf(activity).onKeyUpWasCalled());
    assertTrue(activity.isFinishing());
  }
 public void LoopThenExit() {
   for (Activity activity : activityList) {
     if (!activity.isFinishing()) {
       activity.finish();
     }
   }
   activityList = null;
   this.multicastLock.release();
   DeviceSocket.getInstance().unInit();
   Process.killProcess(Process.myPid());
 }
 public void removeAllActivity() {
   for (Activity ac : activityList) {
     if (null != ac) {
       if (!ac.isFinishing()) {
         ac.finish();
       }
       ac = null;
     }
   }
   activityList.clear();
 }
Ejemplo n.º 19
0
  protected void auth() {

    if (act.isFinishing()) return;

    boolean ok = sso();

    AQUtility.debug("authing", ok);

    if (!ok) {
      webAuth();
    }
  }
Ejemplo n.º 20
0
  public synchronized boolean join(long timeout) throws InterruptedException {
    Activity act = getActivity();
    long start = System.currentTimeMillis();

    while (!act.isFinishing()) {
      if (timeout >= 0 && System.currentTimeMillis() >= start + timeout) {
        return false;
      }
      wait(50L);
    }

    return true;
  }
Ejemplo n.º 21
0
  @Override
  public void onDestroyView() {
    super.onDestroyView();
    Activity context = getActivity();
    if (context != null) {
      subscriber.unsubscribe();

      if (!context.isFinishing())
        ((GetStorage) context)
            .storage()
            .put(TimetableDataFragment.LAST_PAGE, mViewPager.getCurrentItem());
    }
  }
Ejemplo n.º 22
0
 public boolean hidePopUpWindow() {
   if (!context.isFinishing()) {
     if (menu != null) {
       menu.dismiss();
     }
     if (menuBg != null) {
       menuBg.dismiss();
     }
     isShow = false;
     return true;
   }
   return false;
 }
 public final void run()
 {
   baf localbaf = this$0;
   Activity localActivity = val$activity;
   bau localbau = val$shakeReporter;
   String str = val$screenshotFilename;
   if ((localActivity.isFinishing()) || (!ReleaseManager.c()))
   {
     Toast.makeText(SnapchatApplication.b(), "Previous activity " + localActivity.getClass().getSimpleName() + " already finished. Could not attach bug report.", 1).show();
     return;
   }
   new AlertDialog.Builder(localActivity).setTitle("Shake To Report").setMessage("Please describe the issue in the coming pop-up screen. Every bug/request you file will help prevent a user from experiencing that pain!").setCancelable(true).setPositiveButton("Send Feedback", new baf.5(localbaf, localActivity, str)).setNegativeButton("Cancel", new baf.4(localbaf, localbau)).setOnCancelListener(new baf.3(localbaf, localbau)).show();
 }
Ejemplo n.º 24
0
  private void setProcessStep(int length) {
    if (myActivity != null && !myActivity.isFinishing()) {
      if (length != -1) {
        mProgress.setMax(length / 1024);
      }

      mHandler.post(
          new Runnable() {
            public void run() {
              mProgress.show();
            }
          });
    }
  }
Ejemplo n.º 25
0
  void showErrorMessage(int strId) {
    if (myActivity != null && !myActivity.isFinishing()) {
      AlipayApplication application = (AlipayApplication) myActivity.getApplication();
      application
          .getDataHelper()
          .showDialog(
              myActivity,
              0,
              myActivity.getResources().getString(R.string.ErrorString),
              myActivity.getResources().getString(strId),
              myActivity.getResources().getString(R.string.Ensure),
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  // TODO Auto-generated method stub
                }
              },
              null,
              null,
              null,
              null);
      /* StyleAlertDialog dialog = new StyleAlertDialog(myActivity, 0,
          		myActivity.getResources().getString(R.string.ErrorString),
          		myActivity.getResources().getString(strId),
          		myActivity.getResources().getString(R.string.Ensure),new DialogInterface.OnClickListener() {
      	@Override public void onClick(DialogInterface dialog,
      			int which)
      	{
      		// TODO Auto-generated method stub
      	}
      },
          		null,null, null);
              dialog.show();*/

      //		AlertDialog.Builder tDialog = new AlertDialog.Builder(myActivity);
      //		// tDialog.setIcon(R.drawable.quit_bg);
      //		tDialog.setTitle(myActivity.getResources().getString(
      //				R.string.ErrorString));
      //		tDialog.setMessage(myActivity.getResources().getString(strId));
      //		tDialog.setPositiveButton(R.string.Ensure,
      //				new DialogInterface.OnClickListener() {
      //					@Override public void onClick(DialogInterface dialog,
      //							int which)
      //					{
      //						// TODO Auto-generated method stub
      //					}
      //				});
      //		tDialog.show();
    }
  }
Ejemplo n.º 26
0
 /**
  * @param pActivity
  * @param pMessage
  * @note prefer {@link NetworkManager#showToast(Activity, int)} instead
  */
 public static void showToast(final Activity pActivity, final String pMessage) {
   if (pMessage == null || pMessage.trim().length() == 0 || pActivity.isFinishing()) {
     return;
   }
   pActivity.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           if (pActivity.isFinishing()) {
             return;
           }
           Toast.makeText(pActivity, pMessage.trim(), Toast.LENGTH_SHORT).show();
         }
       });
 }
Ejemplo n.º 27
0
 public Boolean a(Km paramKm) {
   boolean bool2 = true;
   Activity localActivity = a.D().b();
   boolean bool1 = bool2;
   if (localActivity != null) {
     bool1 = bool2;
     if (!localActivity.isFinishing()) {
       bool1 = bool2;
       if (a.v()) {
         bool1 = ah.a(a, localActivity, c);
       }
     }
   }
   return Boolean.valueOf(bool1);
 }
Ejemplo n.º 28
0
  /** 移除当前所有已创建的Activiy, 并逐个销毁 */
  public synchronized void removeAll() {
    if (activities.size() != 0) {
      Activity activity = null;
      Iterator<Activity> iterator = activities.iterator();

      while (iterator.hasNext()) {
        activity = iterator.next();
        if (!activity.isFinishing()) {
          activity.finish();
          iterator.remove();
        }
      }
    } else {
      Log.i(TAG, "No Activity in pool!");
    }
  }
Ejemplo n.º 29
0
 public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
   try {
     Log.d("syncPrefs", "onChanged");
     if (activity.isFinishing()) {
       // Setting the summary now would crash it with
       // IllegalStateException since we are not attached to a view
     } else {
       if (KEY_SYNC_ENABLE.equals(key)) {
         toggleSync(prefs);
       } else if (KEY_BACKGROUND_SYNC.equals(key)) {
         setSyncInterval(activity, prefs);
       } else if (KEY_ACCOUNT.equals(key)) {
         Log.d("syncPrefs", "account");
         prefAccount.setTitle(prefs.getString(KEY_ACCOUNT, ""));
       } else if (KEY_SD_ENABLE.equals(key)) {
         // Restart the sync service
         OrgSyncService.stop(getActivity());
       } else if (KEY_SD_DIR.equals(key)) {
         setSdDirSummary(prefs);
       } else if (KEY_DROPBOX_ENABLE.equals(key)) {
         // TODO
         if (mDropboxHelper == null) {
           mDropboxHelper = new DropboxSyncHelper(getActivity());
         }
         if (prefs.getBoolean(key, false)) {
           // authorize the user
           mDropboxHelper.linkAccount();
           //                        DropboxSynchronizer.linkAccount(this,
           //                                DROPBOX_LINK_CODE);
         } else {
           mDropboxHelper.unlinkAccount();
           //                        DropboxSynchronizer.unlink(getActivity());
         }
         // Restart sync service
         OrgSyncService.stop(getActivity());
       } else if (KEY_DROPBOX_DIR.equals(key)) {
         setDropboxDirSummary(prefs);
       }
     }
   } catch (IllegalStateException e) {
     // This is just in case the "isFinishing" wouldn't be enough
     // The isFinishing will try to prevent us from doing something
     // stupid
     // This catch prevents the app from crashing if we do something
     // stupid
   }
 }
 public final void onResume(Activity activity) {
   Iterator iterator = getFilterGroup(activity).iterator();
   do {
     ActivityFilter activityfilter;
     label0:
     {
       if (iterator.hasNext()) {
         activityfilter = (ActivityFilter) iterator.next();
         if (!activity.isFinishing()) {
           break label0;
         }
       }
       return;
     }
     activityfilter.onResume();
   } while (true);
 }