List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:com.ipa.Tools.TypefaceTextView.java
public TypefaceTextView(Context context, AttributeSet attrs) { super(context, attrs); // Get our custom attributes TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0); try {// w ww. j av a 2 s .co m String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface); if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) { Typeface typeface = sTypefaceCache.get(typefaceName); if (typeface == null) { typeface = Typeface.createFromAsset(context.getAssets(), String.format("fonts/%s-Family.otf", typefaceName)); // Cache the Typeface object sTypefaceCache.put(typefaceName, typeface); } setTypeface(typeface); // Note: This flag is required for proper typeface rendering setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } finally { a.recycle(); } }
From source file:com.todev.rabbitmqmanagement.ui.overview.widget.QueuedMessagesIndicator.java
@Override protected void initializeAttributes(Context context, AttributeSet attrs) { super.initializeAttributes(context, attrs); TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.QueuedMessagesIndicator, 0, 0);// w ww . j av a 2 s . co m try { readyColor = array.getColor(R.styleable.QueuedMessagesIndicator_ready_color, ContextCompat.getColor(context, R.color.queuedMessagesReady)); unackedColor = array.getColor(R.styleable.QueuedMessagesIndicator_unacked_color, ContextCompat.getColor(context, R.color.queuedMessagesUnacked)); totalColor = array.getColor(R.styleable.QueuedMessagesIndicator_total_color, ContextCompat.getColor(context, R.color.queuedMessagesTotal)); } finally { array.recycle(); } }
From source file:se.frikod.payday.TypefaceTextView.java
public TypefaceTextView(Context context, AttributeSet attrs) { super(context, attrs); // Get our custom attributes TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0); try {/*from ww w. java2 s . com*/ String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface); if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) { Typeface typeface = sTypefaceCache.get(typefaceName); if (typeface == null) { typeface = Typeface.createFromAsset(context.getAssets(), String.format("%s", typefaceName)); // Cache the Typeface object sTypefaceCache.put(typefaceName, typeface); } setTypeface(typeface); // Note: This flag is required for proper typeface rendering setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } finally { a.recycle(); } }
From source file:com.netpace.expressit.android.ui.TypefaceTextView.java
public TypefaceTextView(Context context, AttributeSet attrs) { super(context, attrs); // Get our custom attributes TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0); try {/* www. j a v a 2 s. co m*/ String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface); if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) { Typeface typeface = sTypefaceCache.get(typefaceName); if (typeface == null) { typeface = Typeface.createFromAsset(context.getAssets(), String.format("fonts/%s_0.otf", typefaceName)); // Cache the Typeface object sTypefaceCache.put(typefaceName, typeface); } setTypeface(typeface); // Note: This flag is required for proper typeface rendering setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } finally { a.recycle(); } }
From source file:com.mjaworski.myQuotes.Utils.TypefaceTextView.java
public TypefaceTextView(Context context, AttributeSet attrs) { super(context, attrs); // Get our custom attributes TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0); try {/*from www . j av a2 s. com*/ String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface); if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) { Typeface typeface = sTypefaceCache.get(typefaceName); if (typeface == null) { typeface = Typeface.createFromAsset(context.getAssets(), String.format("fonts/%s", typefaceName)); // Cache the Typeface object sTypefaceCache.put(typefaceName, typeface); } setTypeface(typeface); } } finally { a.recycle(); } }
From source file:org.bubenheimer.android.preference.EditIntPreference.java
@SuppressWarnings("WeakerAccess") protected EditIntPreference(final Context context, final AttributeSet attrs, final Pair<Integer, Integer> defaults) { super(context, attrs); final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.EditIntPreference, 0, 0); try {//from ww w .ja va 2s . c o m this.min = a.getInteger(R.styleable.EditIntPreference_min, defaults.first); this.max = a.getInteger(R.styleable.EditIntPreference_max, defaults.second); } finally { a.recycle(); } }
From source file:com.liken.customviews.TypefaceTextView.java
public TypefaceTextView(Context context, AttributeSet attrs) { super(context, attrs); // Get our custom attributes TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0); Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Aaargh.ttf"); // Cache the Typeface object // sTypefaceCache.put(typefaceName, typeface); setTypeface(typeface);// w w w . j a v a 2 s . c o m /* try { String typefaceName = a.getString( R.styleable.TypefaceTextView_Aaargh); if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) { Typeface typeface = sTypefaceCache.get(typefaceName); if (typeface == null) { typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Aaargh.ttf"); // Cache the Typeface object sTypefaceCache.put(typefaceName, typeface); } setTypeface(typeface); // Note: This flag is required for proper typeface rendering setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } finally { a.recycle(); }*/ }
From source file:com.uphyca.recyclerviewcommons.sample.DragAndDropWithHandleAdapter.java
public DragAndDropWithHandleAdapter(@NonNull Context context, @NonNull List<T> data) { super(data);/* www.j ava2 s . c om*/ this.inflater = LayoutInflater.from(context); TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, true); backgroundResId = outValue.resourceId; }
From source file:io.github.hidroh.materialistic.widget.TintableTextView.java
public TintableTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mTextColor = getTextColor(context, attrs); TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TintableTextView, 0, 0); setCompoundDrawablesWithIntrinsicBounds(ta.getDrawable(R.styleable.TintableTextView_iconStart), ta.getDrawable(R.styleable.TintableTextView_iconTop), ta.getDrawable(R.styleable.TintableTextView_iconEnd), ta.getDrawable(R.styleable.TintableTextView_iconBottom)); ta.recycle();/*w w w . j a v a2 s . c o m*/ }
From source file:de.grobox.transportr.ui.BasePopupMenu.java
protected BasePopupMenu(Context context, View anchor) { super(context, anchor); this.context = context; setOnMenuItemClickListener(this); TypedValue typedValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorControlNormal, typedValue, true); iconColor = typedValue.data;/* w w w. ja va 2 s.c om*/ }