List of usage examples for android.app Activity isFinishing
public boolean isFinishing()
From source file:Main.java
public static void displayAlert4Choice(Context context, String title, String message, String positiveBtnText, DialogInterface.OnClickListener positionOnclick, String negativeBtnText, DialogInterface.OnClickListener negativeOnclick) { if (null == context || !(context instanceof Activity)) { return;// w ww. j av a 2 s. c o m } final Activity activity = (Activity) context; Builder builder = new AlertDialog.Builder(activity); builder.setCancelable(true); builder.setTitle(title); builder.setMessage(message); if (null == positionOnclick) { positionOnclick = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }; } builder.setPositiveButton(positiveBtnText, positionOnclick); if (null == negativeOnclick) { negativeOnclick = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }; } builder.setNegativeButton(negativeBtnText, negativeOnclick); if (!activity.isFinishing()) { builder.create().show(); } }
From source file:ca.liquidlabs.android.speedtestvisualizer.fragments.BaseGraphFragment.java
/** * Shows progress animation in ActioBar. *//* w w w . ja v a 2s.c om*/ protected void showProgressIndicator() { final Activity activity = getActivity(); if (activity.isFinishing()) { return; } activity.setProgressBarIndeterminateVisibility(true); activity.setProgressBarIndeterminate(true); }
From source file:ca.liquidlabs.android.speedtestvisualizer.fragments.BaseGraphFragment.java
/** * Hides progress animation in ActionBar. *//* www.j av a 2 s . c o m*/ protected void hideProgressIndicator() { final Activity activity = getActivity(); if (activity.isFinishing()) { return; } activity.setProgressBarIndeterminateVisibility(false); activity.setProgressBarIndeterminate(false); }
From source file:com.hellofyc.base.app.activity.ActivityStack.java
public void closeAllActivities() { if (mActivityStack.empty()) return;/*from w ww .j a v a 2 s. c o m*/ for (Activity a : mActivityStack) { if (a == null || a.isFinishing()) continue; ActivityCompat.finishAffinity(a); } mActivityStack.clear(); }
From source file:com.propaneapps.tomorrow.base.BasePresenterFragment.java
@Override public void onDestroy() { super.onDestroy(); Activity activity = getActivity(); if (activity != null && activity.isFinishing()) { presenter.onDestroy();// w ww . j a v a 2s . co m } }
From source file:com.vv.androidreview.ui.activites.AppStartActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ?/*from w w w . j a v a 2 s . c o m*/ Activity aty = AppManager.getActivity(MainActivity.class); if (aty != null && !aty.isFinishing()) { finish(); } setContentView(R.layout.activity_app_start); mPermissionsChecker = new PermissionsChecker(this); }
From source file:de.ub0r.android.smsdroid.ConversationListActivity.java
/** * Delete messages with a given {@link Uri}. * /*from w w w . j a v a 2s. com*/ * @param context * {@link Context} * @param uri * {@link Uri} * @param title * title of Dialog * @param message * message of the Dialog * @param activity * {@link Activity} to finish when deleting. */ static void deleteMessages(final Context context, final Uri uri, final int title, final int message, final Activity activity) { Log.i(TAG, "deleteMessages(..," + uri + " ,..)"); final Builder builder = new Builder(context); builder.setTitle(title); builder.setMessage(message); builder.setNegativeButton(android.R.string.no, null); builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final int ret = context.getContentResolver().delete(uri, null, null); Log.d(TAG, "deleted: " + ret); if (activity != null && !activity.isFinishing()) { activity.finish(); } if (ret > 0) { Conversation.flushCache(); Message.flushCache(); SmsReceiver.updateNewMessageNotification(context, null); } } }); builder.show(); }
From source file:org.onebusaway.android.util.UIUtils.java
/** * Returns true if the activity is still active and dialogs can be managed (i.e., displayed * or dismissed), or false if it is// w w w.j a v a 2 s.co m * not * * @param activity Activity to check for displaying/dismissing a dialog * @return true if the activity is still active and dialogs can be managed, or false if it is * not */ public static boolean canManageDialog(Activity activity) { if (activity == null) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return !activity.isFinishing() && !activity.isDestroyed(); } else { return !activity.isFinishing(); } }
From source file:com.just.agentweb.VideoImpl.java
@Override public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity; if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return;/*from ww w. j av a 2 s . com*/ } mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Window mWindow = mActivity.getWindow(); Pair<Integer, Integer> mPair = null; // ???? if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mFlags.add(mPair); } if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mFlags.add(mPair); } if (mMoiveView != null) { callback.onCustomViewHidden(); return; } if (mWebView != null) { mWebView.setVisibility(View.GONE); } if (mMoiveParentView == null) { FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); mMoiveParentView = new FrameLayout(mActivity); mMoiveParentView.setBackgroundColor(Color.BLACK); mDecorView.addView(mMoiveParentView); } this.mCallback = callback; mMoiveParentView.addView(this.mMoiveView = view); mMoiveParentView.setVisibility(View.VISIBLE); }
From source file:me.wizos.loread.view.webview.VideoImpl.java
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity; if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return;//from ww w . j a v a 2 s . c om } // ? mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Window mWindow = mActivity.getWindow(); Pair<Integer, Integer> mPair; // ???? if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mFlags.add(mPair); } if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mFlags.add(mPair); } if (videoView != null) { callback.onCustomViewHidden(); return; } // KLog.e("" + mWebView + " " + videoParentView); if (mWebView != null) { mWebView.setVisibility(View.GONE); } if (videoParentView == null) { FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); videoParentView = new FrameLayout(mActivity); videoParentView.setBackgroundColor(Color.BLACK); videoParentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); // ? mDecorView.addView(videoParentView); } // KLog.e("" + mWebView.getVisibility() + " " + videoParentView); this.mCallback = callback; this.videoView = view; videoParentView.addView(videoView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); videoParentView.setVisibility(View.VISIBLE); isPlaying = true; }