android.app.ActivityGroup Java Examples

The following examples show how to use android.app.ActivityGroup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivityProxy.java    From GPT with Apache License 2.0 6 votes vote down vote up
/**
     * changeLocalActivityManager
     *
     * @param context Context
     */
    private void changeLocalActivityManager(Context context) {
        if (mProxyLocalActivityManager == null && !(mTargetActivity instanceof ActivityProxy)) {
            try {
                ActivityGroup tabActivity = (ActivityGroup) mTargetActivity;
                mProxyLocalActivityManager = new LocalActivityManagerProxy(tabActivity.getLocalActivityManager(),
                        mTargetPackageName);
                JavaCalls.setField(tabActivity, "mLocalActivityManager", mProxyLocalActivityManager);
//                Field field = ActivityGroup.class.getDeclaredField("mLocalActivityManager");
//                field.setAccessible(true);
//                field.set(tabActivity, mProxyLocalActivityManager);
            } catch (Exception e) {
                if (DEBUG) {
                    e.printStackTrace();
                }
            }

        }
    }
 
Example #2
Source File: ScreenUtil.java    From PicKing with Apache License 2.0 5 votes vote down vote up
/**
 * 获取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;
}
 
Example #3
Source File: ScreenUtil.java    From SweetTips with Apache License 2.0 5 votes vote down vote up
/**
 * 获取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;
}
 
Example #4
Source File: ScreenUtil.java    From SnackbarUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取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;
}
 
Example #5
Source File: ScreenUtil.java    From SweetTips with Apache License 2.0 5 votes vote down vote up
/**
 * 获取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;
}
 
Example #6
Source File: ScreenUtils.java    From YiZhi with Apache License 2.0 4 votes vote down vote up
/**
 * 获取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;
}