APISonar


android.content.Context.getTheme

> android > content > Context > getTheme
android APIs content APIs Context APIs getTheme APIs

Example 1
private Theme getTheme() {
        Context c = mContext.get();
        return c != null ? c.getTheme() : null;
    }
Example 2
private final Context mContext;

    public void onUiModeChanged() {
        mContext.getTheme().applyStyle(mContext.getThemeResId(), true);
        if (mDialog != null && mDialog.isShowing()) {
            mDialog.refreshDialog();
        }
    }
Example 3
public void setUp() {
        Context context = InstrumentationRegistry.getTargetContext();
        mTheme = context.getTheme();

    }
Example 4
public SimpleStringRecyclerViewAdapter(Context context, String[] strings) {
        TypedValue val = new TypedValue();
        if (context.getTheme() != null) {
            context.getTheme().resolveAttribute(R.attr.selectableItemBackground, val, true);
        }
        mBackground = val.resourceId;
        mValues = new ArrayList<>();
        Collections.addAll(mValues, strings);
    }
Example 5
private void initXmlAttributes(Context context, AttributeSet attrs) {
        if (attrs == null) return;
        // parse the xml attributes by resolving resource references
        final TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
                R.styleable.tw__TweetView, 0, 0);
        try {
            setXmlDataAttributes(a);
            setStyleAttributes(a);
        } finally {
            a.recycle();
        }
    }
Example 6
private final Context context;

  private Drawable loadDrawable(@DrawableRes int resourceId) {
    Theme theme =
        requestOptions.getTheme() != null ? requestOptions.getTheme() : context.getTheme();
    return DrawableDecoderCompat.getDrawable(glideContext, resourceId, theme);
  }
Example 7
private Context mBase;

    private void initializeTheme() {
        final boolean first = mTheme == null;
        if (first) {
            mTheme = getResources().newTheme();
            Resources.Theme theme = mBase.getTheme();
            if (theme != null) {
                mTheme.setTo(theme);
            }
        }
        onApplyThemeResource(mTheme, mThemeResource, first);
    }
Example 8
void setUpProps(Context context, AttributeSet attributes) {
        super.setUpProps(context, attributes);
        flavourAttributes = context.getTheme().obtainStyledAttributes(
                attributes, R.styleable.TouchScrollBar, 0, 0);
    }
Example 9
private void parseAttributes(Context context, AttributeSet attrs) {
        TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.MultiToggleImageButton,
            0, 0);
        int imageIds = a.getResourceId(R.styleable.MultiToggleImageButton_imageIds, 0);
        if (imageIds > 0) {
            overrideImageIds(imageIds);
        }
        a.recycle();
    }
Example 10
public WatchedBox(Context context, AttributeSet attrs) {
        super(context, attrs);
        mEpisodeFlag = EpisodeFlags.UNWATCHED;
        mResIdWatchDrawable = Utils.resolveAttributeToResourceId(context.getTheme(),
                R.attr.drawableWatch);
        mResIdWatchedDrawable = Utils.resolveAttributeToResourceId(context.getTheme(),
                R.attr.drawableWatched);
        mResIdWatchSkippedDrawable = Utils.resolveAttributeToResourceId(context.getTheme(),
                R.attr.drawableWatchSkipped);
        updateStateImage();
    }
Example 11
private TileColorPicker(Context context) {
        mColorStateList = context.getResources().
                getColorStateList(R.color.tint_color_selector, context.getTheme());
    }
Example 12
public SubheaderListItem(Context context, String text) {

        mContext = context;
        mText = text;
        mTextStartMarginType = TEXT_START_MARGIN_TYPE_NONE;

        TypedArray a = context.getTheme().obtainStyledAttributes(R.styleable.ListItem);
        mListItemSubheaderTextAppearance = a.getResourceId(
                R.styleable.ListItem_listItemSubheaderTextAppearance,
                R.style.TextAppearance_Car_Subheader);
        a.recycle();

        markDirty();
    }
Example 13
protected int getActionBarSize(Context context) {
        int[] attrs = {android.R.attr.actionBarSize};
        TypedArray values = context.getTheme().obtainStyledAttributes(attrs);
        try {
            return values.getDimensionPixelSize(0, 0);
        } finally {
            values.recycle();
        }
    }
Example 14
private static void resolveMaxWindowSize(Context context, Point outPoint) {
        context.getDisplay().getSize(outPoint);
        final TypedValue typedValue = sTempTypedValue;
        context.getTheme().resolveAttribute(R.attr.autofillDatasetPickerMaxWidth,
                typedValue, true);
        outPoint.x = (int) typedValue.getFraction(outPoint.x, outPoint.x);
        context.getTheme().resolveAttribute(R.attr.autofillDatasetPickerMaxHeight,
                typedValue, true);
        outPoint.y = (int) typedValue.getFraction(outPoint.y, outPoint.y);
    }
Example 15
private float getVerticalScrollFactorCompat() {
        if(this.mVerticalScrollFactor == 0.0F) {
            TypedValue outValue = new TypedValue();
            Context context = this.getContext();
            if(!context.getTheme().resolveAttribute(16842829, outValue, true)) {
                throw new IllegalStateException("Expected theme to define listPreferredItemHeight.");
            }

            this.mVerticalScrollFactor = outValue.getDimension(context.getResources().getDisplayMetrics());
        }

        return this.mVerticalScrollFactor;
    }
Example 16
private void init(Context context, AttributeSet attrs) {
		TypedArray styledAttrs = context.getTheme().obtainStyledAttributes(
			attrs, R.styleable.AbsCustomSlider, 0, 0);
		try {
			inVerticalOrientation = styledAttrs.getBoolean(
				R.styleable.AbsCustomSlider_inVerticalOrientation, inVerticalOrientation);
		} finally {
			styledAttrs.recycle();
		}
	}
Example 17
private final Context mContext;

    private void resolveThemeColors() {
        TypedValue outValue = new TypedValue();
        mContext.getTheme().resolveAttribute(R.attr.drawerOpenHeaderColor, outValue, true);
        mOpenDrawerHeaderColor = mContext.getColor(outValue.resourceId);

        mContext.getTheme().resolveAttribute(R.attr.drawerClosedHeaderColor, outValue, true);
        mClosedDrawerHeaderColor = mContext.getColor(outValue.resourceId);
    }
Example 18
private Context mContext;

    public void testChildVectorItem() {
        AnimatedStateListDrawableCompat asld = AnimatedStateListDrawableCompat.create(mContext,
                R.drawable.asl_heart_embedded, mContext.getTheme());
        // Check that 4 drawables were parsed
        assertEquals(4, asld.getStateCount());
    }
Example 19
public void setTextAppearance(@NonNull Context context, int resId) {
    super.setTextAppearance(context, resId);

    if (canApplyTextAppearanceLineHeight(context)) {
      applyLineHeightFromViewAppearance(context.getTheme(), resId);
    }
  }
Example 20
public Context context;

    public void setUpLayout() {

        layout = R.layout.person;

        TypedArray b = context.getTheme().obtainStyledAttributes(new int[]{R.attr.circleBorder});

        border = b.getResourceId(0, 0);
        b.recycle();

        mCache = App.getInstance(context).getBitmapCache();
    }
Example 21
private final Context mContext;

    public int getIconAttributeResId(int attrId) {
        TypedValue out = new TypedValue();
        mContext.getTheme().resolveAttribute(attrId, out, true);
        return out.resourceId;
    }
Example 22
private Context mContext;

    public void testConstructor() {
        new ContextThemeWrapper();

        new ContextThemeWrapper(mContext, R.style.TextAppearance);

        new ContextThemeWrapper(mContext, mContext.getTheme());
    }
Example 23
static boolean isWindowBackgroundDark(Context context) {
        TypedValue color = new TypedValue();
        try {
            context.getTheme().resolveAttribute(android.R.attr.colorBackground, color, true);
            return Color.red(color.data) < 128 && Color.green(color.data) < 128 && Color.blue(color.data) < 128;
        } catch (RuntimeException e) {
            return false;
        }
    }
Example 24
public static void addActionBarPaddingBottom(Context c, View v) {
        int mActionBarHeight = 0;
        TypedValue tv = new TypedValue();
        if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
            mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics());
        else
            mActionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme)

        v.setPadding(0, 0, 0, mActionBarHeight);
    }
Example 25
public ChartDataUsagePreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        setSelectable(false);
        // TODO: Resource.
        mLimitColor = 0xfff4511e;
        TypedArray a = context.getTheme().obtainStyledAttributes(
                new int[]{android.R.attr.textColorSecondary});
        mWarningColor = a.getColor(0, 0);
        setLayoutResource(R.layout.data_usage_graph);
    }