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;
}
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));
}
});
}
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;
}
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;
}
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();
}
Aggregations