本文整理了Java中android.app.Activity.isDestroyed()
方法的一些代码示例,展示了Activity.isDestroyed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.isDestroyed()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:isDestroyed
暂无
代码示例来源:origin: facebook/litho
private static boolean isActivityDestroyed(Activity activity) {
if (SDK_INT >= JELLY_BEAN_MR1) {
return activity.isDestroyed();
}
// If we cannot guarantee that the activity is not destroyed we prefer to assume that it is.
// This might only happen on ICS.
return true;
}
}
代码示例来源:origin: bumptech/glide
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static void assertNotDestroyed(@NonNull Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed()) {
throw new IllegalArgumentException("You cannot start a load for a destroyed activity");
}
}
代码示例来源:origin: bluelinelabs/Conductor
@Override
public boolean isDestroyed() {
return isDestroying || super.isDestroyed();
}
}
代码示例来源:origin: square/assertj-android
@TargetApi(JELLY_BEAN_MR1)
public S isDestroyed() {
isNotNull();
assertThat(actual.isDestroyed()) //
.overridingErrorMessage("Expected to be destroyed but was not destroyed.") //
.isTrue();
return myself;
}
代码示例来源:origin: square/assertj-android
@TargetApi(JELLY_BEAN_MR1)
public S isNotDestroyed() {
isNotNull();
assertThat(actual.isDestroyed()) //
.overridingErrorMessage("Expected not to be destroyed but was destroyed.") //
.isFalse();
return myself;
}
代码示例来源:origin: bumptech/glide
@Test
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void testDoesNotThrowIfAskedToGetManagerForActivityPreJellYBeanMr1() {
Util.setSdkVersionInt(Build.VERSION_CODES.JELLY_BEAN);
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
Activity spyActivity = Mockito.spy(activity);
when(spyActivity.isDestroyed()).thenThrow(new NoSuchMethodError());
assertNotNull(retriever.get(spyActivity));
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void shouldReportDestroyedStatus() {
ActivityController<DialogCreatingActivity> controller = Robolectric.buildActivity(DialogCreatingActivity.class);
activity = controller.get();
controller.destroy();
assertThat(activity.isDestroyed()).isTrue();
}
代码示例来源:origin: guolindev/giffun
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static void assertNotDestroyed(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed()) {
throw new IllegalArgumentException("You cannot start a load for a destroyed activity");
}
}
代码示例来源:origin: TakWolf/CNode-Material-Design
public static boolean isAlive(@Nullable Activity activity) {
return activity != null && !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed()) && !activity.isFinishing();
}
代码示例来源:origin: syncthing/syncthing-android
/**
* Make sure that dialog is showing and activity is valid before dismissing dialog, to prevent
* various crashes.
*/
public static void dismissDialogSafe(Dialog dialog, Activity activity) {
if (dialog == null || !dialog.isShowing())
return;
if (activity.isFinishing())
return;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN && activity.isDestroyed())
return;
dialog.dismiss();
}
代码示例来源:origin: GeekGhost/Ghost
public static void load(Activity activity, String url, ImageView iv) { //使用Glide加载圆形ImageView(如头像)时,不要使用占位图
if (!activity.isDestroyed()) {
Glide.with(activity).load(url).crossFade().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv);
}
}
代码示例来源:origin: GeekGhost/Ghost
public static void loadAll(Activity activity, String url, ImageView iv) { //不缓存,全部从网络加载
if (!activity.isDestroyed()) {
Glide.with(activity).load(url).crossFade().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(iv);
}
}
}
代码示例来源:origin: iqiyi/Neptune
/**
* 判断Activity是否已经销毁或正在销毁,这时候就不再调用Activity.finish方法
* 防止插件重写finish方法造成循环调用
*/
public static boolean isFinished(Activity activity) {
boolean isFinished = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
isFinished = activity.isDestroyed();
}
return isFinished || activity.isFinishing();
}
代码示例来源:origin: iqiyi/Neptune
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public boolean isDestroyed() {
return mOriginActivity.isDestroyed();
}
代码示例来源:origin: JumeiRdGroup/Router
public static boolean isValid(Activity activity) {
return activity != null
&& !activity.isFinishing()
&& !(Build.VERSION.SDK_INT >= 17 && activity.isDestroyed());
}
代码示例来源:origin: ManbangGroup/Phantom
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public boolean isDestroyed() {
return mContentProxy.getContext().isDestroyed();
}
代码示例来源:origin: hsllany/HtmlNative
@Override
public void onViewLoaded(View v) {
if (mActivity != null && !mActivity.isDestroyed()) {
mActivity.setContentView(v);
}
}
代码示例来源:origin: hsllany/HtmlNative
@Override
public void onViewLoaded(@Nullable View v) {
Activity act = mWeakRef.get();
if (act != null && !act.isDestroyed() && v != null) {
act.setContentView(v);
}
}
代码示例来源:origin: com.squareup.assertj/assertj-android
@TargetApi(JELLY_BEAN_MR1)
public S isDestroyed() {
isNotNull();
assertThat(actual.isDestroyed()) //
.overridingErrorMessage("Expected to be destroyed but was not destroyed.") //
.isTrue();
return myself;
}
代码示例来源:origin: com.albedinsky.android/ui-transition
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (!caller.isDestroyed() && !caller.isFinishing()) {
onFinishCaller(caller);
}
} else if (!caller.isFinishing()) {
onFinishCaller(caller);
}
}
}, delay);
内容来源于网络,如有侵权,请联系作者删除!