Example usage for android.app Activity obtainStyledAttributes

List of usage examples for android.app Activity obtainStyledAttributes

Introduction

In this page you can find the example usage for android.app Activity obtainStyledAttributes.

Prototype

public final TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) 

Source Link

Document

Retrieve styled attribute information in this Context's theme.

Usage

From source file:Main.java

public static Drawable getThemeUpIndicator(Object info, Activity activity) {
    final TypedArray a = activity.obtainStyledAttributes(THEME_ATTRS);
    final Drawable result = a.getDrawable(0);
    a.recycle();//from   www  .  j a  v a  2 s  .c  o m
    return result;
}

From source file:Main.java

public static int getDimensionPixelSize(Activity activity, int attr, int defaultValue) {
    int[] attrs = new int[] { attr };
    TypedArray ta = activity.obtainStyledAttributes(attrs);
    int value = ta.getDimensionPixelSize(0, defaultValue);
    ta.recycle();//www. ja va2s .c  om
    return value;
}

From source file:com.sherlock.navigationdrawer.compat.SherlockActionBarDrawerToggleCompat.java

public static Drawable getThemeUpIndicator(Activity activity) {
    final TypedArray a = activity.obtainStyledAttributes(THEME_ATTRS);
    final Drawable result = a.getDrawable(0);
    a.recycle();//from www. jav  a 2 s .  c om
    return result;
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void overrideActivityCloseAnimation(final Activity activity) {
    TypedArray a = activity.obtainStyledAttributes(new int[] { android.R.attr.windowAnimationStyle });
    final int windowAnimationStyleResId = a.getResourceId(0, 0);
    a.recycle();/* w ww  .  java  2  s .c  om*/
    // Now retrieve the resource ids of the actual animations used in the
    // animation style pointed to by
    // the window animation resource id.
    a = activity.obtainStyledAttributes(windowAnimationStyleResId, ANIM_CLOSE_STYLE_ATTRS);
    final int activityCloseEnterAnimation = a.getResourceId(0, 0);
    final int activityCloseExitAnimation = a.getResourceId(1, 0);
    a.recycle();
    activity.overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void overrideActivityOpenAnimation(final Activity activity) {

    TypedArray a = activity.obtainStyledAttributes(new int[] { android.R.attr.windowAnimationStyle });
    final int windowAnimationStyleResId = a.getResourceId(0, 0);
    a.recycle();/*from  www .jav a2  s.  c  o m*/
    // Now retrieve the resource ids of the actual animations used in the
    // animation style pointed to by
    // the window animation resource id.
    a = activity.obtainStyledAttributes(windowAnimationStyleResId, ANIM_OPEN_STYLE_ATTRS);
    final int activityOpenEnterAnimation = a.getResourceId(0, 0);
    final int activityOpenExitAnimation = a.getResourceId(1, 0);
    a.recycle();
    activity.overridePendingTransition(activityOpenEnterAnimation, activityOpenExitAnimation);
}

From source file:Main.java

public static int getDisplayHeight(Activity activity) {
    int height = 0;
    if (activity != null && activity.getWindowManager() != null
            && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point = new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        height = point.y;//  ww  w  .jav  a 2 s . c  om
    }

    Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);

    if (isSupportSmartBar) {
        int smartBarHeight = getSmartBarHeight(activity);
        Log.e(TAG, "smartBarHeight:" + smartBarHeight);
        height -= smartBarHeight;
    }

    if (activity != null && activity.getActionBar() != null) {
        int actionbar = activity.getActionBar().getHeight();
        if (actionbar == 0) {
            TypedArray actionbarSizeTypedArray = activity
                    .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
            actionbar = (int) actionbarSizeTypedArray.getDimension(0, 0);
        }
        Log.d(TAG, "actionbar:" + actionbar);
        height -= actionbar;
    }

    int status = getStatusBarHeight(activity);
    Log.d(TAG, "status:" + status);

    height -= status;

    Log.d(TAG, "height:" + height);
    return height;
}