Java 类android.app.ActivityGroup 实例源码

项目:appcan-plugin-pdfreader-android    文件:EUExPdf.java   
public void close(String[] args)
{
    LocalActivityManager mgr = ((ActivityGroup) mContext)
            .getLocalActivityManager();
    ViewerActivity viewerActivity = (ViewerActivity) mgr.getActivity(TAG);
    if(viewerActivity != null){
        View view = viewerActivity.getWindow().getDecorView();
        removeViewFromCurrentWindow(view);
        viewerActivity.finish();
        viewerActivity = null;
        view = null;
    }


    if(isOpen){
        isOpen=!isOpen;
    }

}
项目:PicKing    文件:ScreenUtil.java   
/**
 * 获取actionbar的像素高度,默认使用android官方兼容包做actionbar兼容
 *
 * @return
 */
public static int getActionBarHeight(Context context) {
    int actionBarHeight = 0;
    if (context instanceof AppCompatActivity && ((AppCompatActivity) context).getSupportActionBar() != null) {
        Log.d("isAppCompatActivity", "==AppCompatActivity");
        actionBarHeight = ((AppCompatActivity) context).getSupportActionBar().getHeight();
    } else if (context instanceof Activity && ((Activity) context).getActionBar() != null) {
        Log.d("isActivity", "==Activity");
        actionBarHeight = ((Activity) context).getActionBar().getHeight();
    } else if (context instanceof ActivityGroup) {
        Log.d("ActivityGroup", "==ActivityGroup");
        if (((ActivityGroup) context).getCurrentActivity() instanceof AppCompatActivity && ((AppCompatActivity) ((ActivityGroup) context).getCurrentActivity()).getSupportActionBar() != null) {
            actionBarHeight = ((AppCompatActivity) ((ActivityGroup) context).getCurrentActivity()).getSupportActionBar().getHeight();
        } else if (((ActivityGroup) context).getCurrentActivity() instanceof Activity && ((Activity) ((ActivityGroup) context).getCurrentActivity()).getActionBar() != null) {
            actionBarHeight = ((Activity) ((ActivityGroup) context).getCurrentActivity()).getActionBar().getHeight();
        }
    }
    if (actionBarHeight != 0)
        return actionBarHeight;
    final TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true)) {
        if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true))
            actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
            actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
    } else {
        if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true))
            actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
    }
    Log.d("actionBarHeight", "====" + actionBarHeight);
    return actionBarHeight;
}
项目:FullRobolectricTestSample    文件:ActivityGroupTest.java   
@Test
public void getCurrentActivity_shouldReturnTheProvidedCurrentActivity() throws Exception {
ActivityGroup activityGroup = new ActivityGroup();
Activity activity = new Activity();
shadowOf(activityGroup).setCurrentActivity(activity);

  assertThat(activityGroup.getCurrentActivity()).isSameAs(activity);
}
项目:YiZhi    文件:ScreenUtils.java   
/**
 * 获取actionbar的像素高度,默认使用android官方兼容包做actionbar兼容
 *
 * @return
 */
public static int getActionBarHeight(Context context) {
    int actionBarHeight = 0;
    if (context instanceof AppCompatActivity && ((AppCompatActivity) context)
            .getSupportActionBar() != null) {
        Log.d("isAppCompatActivity", "==AppCompatActivity");
        actionBarHeight = ((AppCompatActivity) context).getSupportActionBar().getHeight();
    } else if (context instanceof Activity && ((Activity) context).getActionBar() != null) {
        Log.d("isActivity", "==Activity");
        actionBarHeight = ((Activity) context).getActionBar().getHeight();
    } else if (context instanceof ActivityGroup) {
        Log.d("ActivityGroup", "==ActivityGroup");
        if (((ActivityGroup) context).getCurrentActivity() instanceof AppCompatActivity && (
                (AppCompatActivity) ((ActivityGroup) context).getCurrentActivity())
                .getSupportActionBar() != null) {
            actionBarHeight = ((AppCompatActivity) ((ActivityGroup) context)
                    .getCurrentActivity()).getSupportActionBar().getHeight();
        } else if (((ActivityGroup) context).getCurrentActivity() instanceof Activity && (
                (Activity) ((ActivityGroup) context).getCurrentActivity()).getActionBar() !=
                null) {
            actionBarHeight = ((Activity) ((ActivityGroup) context).getCurrentActivity())
                    .getActionBar().getHeight();
        }
    }
    if (actionBarHeight != 0)
        return actionBarHeight;
    final TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr
            .actionBarSize, tv, true)) {
        if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr
                .actionBarSize, tv, true))
            actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context
                    .getResources().getDisplayMetrics());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
            actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context
                    .getResources().getDisplayMetrics());
    } else {
        if (context.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr
                .actionBarSize, tv, true))
            actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context
                    .getResources().getDisplayMetrics());
    }
    Log.d("actionBarHeight", "====" + actionBarHeight);
    return actionBarHeight;
}
项目:FullRobolectricTestSample    文件:Robolectric.java   
public static ShadowActivityGroup shadowOf(ActivityGroup instance) {
  return (ShadowActivityGroup) shadowOf_(instance);
}