android.app.Activity.isFinishing()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(452)

本文整理了Java中android.app.Activity.isFinishing()方法的一些代码示例,展示了Activity.isFinishing()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.isFinishing()方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:isFinishing

Activity.isFinishing介绍

暂无

代码示例

代码示例来源:origin: bumptech/glide

private static boolean isActivityVisible(Activity activity) {
 // This is a poor heuristic, but it's about all we have. We'd rather err on the side of visible
 // and start requests than on the side of invisible and ignore valid requests.
 return !activity.isFinishing();
}

代码示例来源:origin: androidquery/androidquery

private boolean isActive(){
  if(act.isFinishing()) return false;
  return true;
}

代码示例来源:origin: androidquery/androidquery

private boolean isActive(){
  
  if(act == null) return true;
  
  Activity a = act.get();
  
  if(a == null || a.isFinishing()){					
    return false;
  }
  
  return true;
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Nullable
  private Activity getActivity() {
    Activity activity = weakReference.get();
    if (activity != null && activity.isFinishing()) {
      return null;
    } else {
      return activity;
    }
  }
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Nullable
private Activity getActivity() {
  Activity activity = weakReference.get();
  if (activity != null && activity.isFinishing()) {
    return null;
  } else {
    return activity;
  }
}

代码示例来源:origin: robolectric/robolectric

/**
 * Returns whether {@link #finish()} was called.
 *
 * @deprecated Use {@link Activity#isFinishing()} instead.
 */
@Deprecated
public boolean isFinishing() {
 return directlyOn(realActivity, Activity.class).isFinishing();
}

代码示例来源:origin: donglua/PhotoPicker

@Override public void onClick(View view) {
  if (context instanceof Activity) {
   if (!((Activity) context).isFinishing()) {
    ((Activity) context).onBackPressed();
   }
  }
 }
});

代码示例来源:origin: Justson/AgentWeb

@Deprecated
static void getUIControllerAndShowMessage(Activity activity, String message, String from) {
  if (activity == null || activity.isFinishing()) {
    return;
  }
  WebParentLayout mWebParentLayout = (WebParentLayout) activity.findViewById(R.id.web_parent_layout_id);
  AbsAgentWebUIController mAgentWebUIController = mWebParentLayout.provide();
  if (mAgentWebUIController != null) {
    mAgentWebUIController.onShowMessage(message, from);
  }
}

代码示例来源:origin: Justson/AgentWeb

private void showDialog(final File file) {
  Activity mActivity;
  if (null == (mActivity = mActivityWeakReference.get()) || mActivity.isFinishing()) {
    return;
  }
  AbsAgentWebUIController mAgentWebUIController;
  if (null != (mAgentWebUIController = this.mAgentWebUIController.get())) {
    mAgentWebUIController.onForceDownloadAlert(mUrl, createCallback(file));
  }
}

代码示例来源:origin: crazycodeboy/TakePhoto

@Override
public void onCompressSuccess(ArrayList<TImage> images) {
  if (!compressConfig.isEnableReserveRaw()) {
    deleteRawFile(images);
  }
  handleTakeCallBack(result);
  if (wailLoadDialog != null && !contextWrap.getActivity().isFinishing()) {
    wailLoadDialog.dismiss();
  }
}

代码示例来源:origin: facebook/litho

/**
 * @return the Activity representing this Context if the Context is backed by an Activity and the
 * Activity has not been finished/destroyed yet. Returns null otherwise.
 */
@Nullable
static Activity getValidActivityForContext(Context context) {
 final Activity activity = findActivityInContext(context);
 if (activity == null || activity.isFinishing() || isActivityDestroyed(activity)) {
  return null;
 }
 return activity;
}

代码示例来源:origin: RobotiumTech/robotium

void monitorActivities() {
  if(activityMonitor != null){
    Activity activity = activityMonitor.waitForActivityWithTimeout(2000L);
    if(activity != null){
      if (activitiesStoredInActivityStack.remove(activity.toString())){
        removeActivityFromStack(activity);
      }
      if(!activity.isFinishing()){
        addActivityToStack(activity);
      }
    }
  }
}

代码示例来源:origin: crazycodeboy/TakePhoto

@Override
  public void onCompressFailed(ArrayList<TImage> images, String msg) {
    if (!compressConfig.isEnableReserveRaw()) {
      deleteRawFile(images);
    }
    handleTakeCallBack(TResult.of(images),
      String.format(contextWrap.getActivity().getResources().getString(org.devio.takephoto.R.string.tip_compress_failed),
        message.length > 0 ? message[0] : "", msg, result.getImage().getCompressPath()));
    if (wailLoadDialog != null && !contextWrap.getActivity().isFinishing()) {
      wailLoadDialog.dismiss();
    }
  }
}).compress();

代码示例来源:origin: robolectric/robolectric

@Override
public ActivityResult getActivityResult() {
 checkNotNull(controller);
 checkState(controller.get().isFinishing(), "You must finish your Activity first");
 ShadowActivity shadowActivity = Shadow.extract(controller.get());
 return new ActivityResult(shadowActivity.getResultCode(), shadowActivity.getResultIntent());
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldCallFinishOnFinish() {
 Activity activity = new Activity();
 activity.finish();
 assertTrue(activity.isFinishing());
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = LOLLIPOP)
public void shouldCallFinishOnFinishAndRemoveTask() {
 Activity activity = new Activity();
 activity.finishAndRemoveTask();
 assertTrue(activity.isFinishing());
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = JELLY_BEAN)
public void shouldCallFinishOnFinishAffinity() {
 Activity activity = new Activity();
 activity.finishAffinity();
 assertTrue(activity.isFinishing());
}

代码示例来源:origin: konmik/nucleus

public void setUpIsFinishing(boolean b) {
  Activity activity = mock(Activity.class);
  when(activity.isFinishing()).thenReturn(b);
  when(activity.isChangingConfigurations()).thenReturn(!b);
  stub(method(BASE_VIEW_CLASS, "getActivity")).toReturn(activity);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldCallFinishInOnBackPressed() {
 Activity activity = new Activity();
 activity.onBackPressed();
 assertTrue(activity.isFinishing());
}

代码示例来源:origin: robolectric/robolectric

@Test
public void createActivity_noDisplayFinished_shouldFinishActivity() {
 ActivityController<Activity> controller = Robolectric.buildActivity(Activity.class);
 controller.get().setTheme(android.R.style.Theme_NoDisplay);
 controller.create();
 controller.get().finish();
 controller.start().visible().resume();
 activity = controller.get();
 assertThat(activity.isFinishing()).isTrue();
}

相关文章

Activity类方法