Search in sources :

Example 36 with TypedValue

use of android.util.TypedValue in project Notes by lguipeng.

the class BaseActivity method getDarkColorPrimary.

public int getDarkColorPrimary() {
    TypedValue typedValue = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);
    return typedValue.data;
}
Also used : TypedValue(android.util.TypedValue)

Example 37 with TypedValue

use of android.util.TypedValue in project FirebaseUI-Android by firebase.

the class RegisterEmailFragment method setUpTermsOfService.

private void setUpTermsOfService() {
    if (TextUtils.isEmpty(mHelper.getFlowParams().termsOfServiceUrl)) {
        return;
    }
    ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.linkColor));
    String preamble = getString(R.string.create_account_preamble);
    String link = getString(R.string.terms_of_service);
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(preamble + link);
    int start = preamble.length();
    spannableStringBuilder.setSpan(foregroundColorSpan, start, start + link.length(), 0);
    mAgreementText.setText(spannableStringBuilder);
    mAgreementText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // Getting default color
            TypedValue typedValue = new TypedValue();
            getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
            @ColorInt int color = typedValue.data;
            new CustomTabsIntent.Builder().setToolbarColor(color).build().launchUrl(getActivity(), Uri.parse(mHelper.getFlowParams().termsOfServiceUrl));
        }
    });
}
Also used : ForegroundColorSpan(android.text.style.ForegroundColorSpan) SpannableStringBuilder(android.text.SpannableStringBuilder) View(android.view.View) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder) TypedValue(android.util.TypedValue)

Example 38 with TypedValue

use of android.util.TypedValue in project fresco by facebook.

the class WebpBitmapFactoryImpl method hookDecodeResource.

@DoNotStrip
public static Bitmap hookDecodeResource(Resources res, int id, BitmapFactory.Options opts) {
    Bitmap bm = null;
    TypedValue value = new TypedValue();
    try (InputStream is = res.openRawResource(id, value)) {
        bm = hookDecodeResourceStream(res, value, is, null, opts);
    } catch (Exception e) {
    // Keep resulting bitmap as null
    }
    if (IN_BITMAP_SUPPORTED && bm == null && opts != null && opts.inBitmap != null) {
        throw new IllegalArgumentException("Problem decoding into existing bitmap");
    }
    return bm;
}
Also used : Bitmap(android.graphics.Bitmap) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) TypedValue(android.util.TypedValue) DoNotStrip(com.facebook.common.internal.DoNotStrip)

Example 39 with TypedValue

use of android.util.TypedValue in project XobotOS by xamarin.

the class View method getVerticalScrollFactor.

/**
     * Gets a scale factor that determines the distance the view should scroll
     * vertically in response to {@link MotionEvent#ACTION_SCROLL}.
     * @return The vertical scroll scale factor.
     * @hide
     */
protected float getVerticalScrollFactor() {
    if (mVerticalScrollFactor == 0) {
        TypedValue outValue = new TypedValue();
        if (!mContext.getTheme().resolveAttribute(com.android.internal.R.attr.listPreferredItemHeight, outValue, true)) {
            throw new IllegalStateException("Expected theme to define listPreferredItemHeight.");
        }
        mVerticalScrollFactor = outValue.getDimension(mContext.getResources().getDisplayMetrics());
    }
    return mVerticalScrollFactor;
}
Also used : TypedValue(android.util.TypedValue)

Example 40 with TypedValue

use of android.util.TypedValue in project XobotOS by xamarin.

the class NinePatchDrawable method inflate.

@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException {
    super.inflate(r, parser, attrs);
    TypedArray a = r.obtainAttributes(attrs, com.android.internal.R.styleable.NinePatchDrawable);
    final int id = a.getResourceId(com.android.internal.R.styleable.NinePatchDrawable_src, 0);
    if (id == 0) {
        throw new XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid src attribute");
    }
    final boolean dither = a.getBoolean(com.android.internal.R.styleable.NinePatchDrawable_dither, DEFAULT_DITHER);
    final BitmapFactory.Options options = new BitmapFactory.Options();
    if (dither) {
        options.inDither = false;
    }
    options.inScreenDensity = DisplayMetrics.DENSITY_DEVICE;
    final Rect padding = new Rect();
    Bitmap bitmap = null;
    try {
        final TypedValue value = new TypedValue();
        final InputStream is = r.openRawResource(id, value);
        bitmap = BitmapFactory.decodeResourceStream(r, value, is, padding, options);
        is.close();
    } catch (IOException e) {
    // Ignore
    }
    if (bitmap == null) {
        throw new XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid src attribute");
    } else if (bitmap.getNinePatchChunk() == null) {
        throw new XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid 9-patch source image");
    }
    setNinePatchState(new NinePatchState(new NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch"), padding, dither), r);
    mNinePatchState.mTargetDensity = mTargetDensity;
    a.recycle();
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) TypedArray(android.content.res.TypedArray) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) TypedValue(android.util.TypedValue)

Aggregations

TypedValue (android.util.TypedValue)844 TypedArray (android.content.res.TypedArray)190 Resources (android.content.res.Resources)92 ContextThemeWrapper (android.view.ContextThemeWrapper)52 Context (android.content.Context)50 Drawable (android.graphics.drawable.Drawable)49 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)46 TextView (android.widget.TextView)44 Paint (android.graphics.Paint)41 IOException (java.io.IOException)39 AttributeSet (android.util.AttributeSet)34 View (android.view.View)30 XmlResourceParser (android.content.res.XmlResourceParser)29 Point (android.graphics.Point)26 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)26 ColorStateList (android.content.res.ColorStateList)23 DisplayMetrics (android.util.DisplayMetrics)23 LinearLayout (android.widget.LinearLayout)20 Bundle (android.os.Bundle)19 SpannableString (android.text.SpannableString)19