List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:com.community.yuequ.bottombar.BottomBar.java
private void populateAttributes(Context context, AttributeSet attrs) { primaryColor = MiscUtils.getColor(getContext(), R.attr.colorPrimary); screenWidth = MiscUtils.getScreenWidth(getContext()); tenDp = MiscUtils.dpToPixel(getContext(), 10); maxFixedItemWidth = MiscUtils.dpToPixel(getContext(), 168); TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BottomBar, 0, 0); try {//ww w . j a va 2s .com tabXmlResource = ta.getResourceId(R.styleable.BottomBar_bb_tabXmlResource, 0); isTabletMode = ta.getBoolean(R.styleable.BottomBar_bb_tabletMode, false); behaviors = ta.getInteger(R.styleable.BottomBar_bb_behavior, BEHAVIOR_NONE); inActiveTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_inActiveTabAlpha, isShiftingMode() ? DEFAULT_INACTIVE_SHIFTING_TAB_ALPHA : 1); activeTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_activeTabAlpha, 1); @ColorInt int defaultInActiveColor = isShiftingMode() ? Color.WHITE : ContextCompat.getColor(context, R.color.bb_inActiveBottomBarItemColor); int defaultActiveColor = isShiftingMode() ? Color.WHITE : primaryColor; inActiveTabColor = ta.getColor(R.styleable.BottomBar_bb_inActiveTabColor, defaultInActiveColor); activeTabColor = ta.getColor(R.styleable.BottomBar_bb_activeTabColor, defaultActiveColor); badgeBackgroundColor = ta.getColor(R.styleable.BottomBar_bb_badgeBackgroundColor, Color.RED); titleTextAppearance = ta.getResourceId(R.styleable.BottomBar_bb_titleTextAppearance, 0); titleTypeFace = getTypeFaceFromAsset(ta.getString(R.styleable.BottomBar_bb_titleTypeFace)); showShadow = ta.getBoolean(R.styleable.BottomBar_bb_showShadow, true); } finally { ta.recycle(); } }
From source file:eu.faircode.netguard.LogAdapter.java
public LogAdapter(Context context, Cursor cursor, boolean resolve) { super(context, cursor, 0); this.resolve = resolve; colTime = cursor.getColumnIndex("time"); colVersion = cursor.getColumnIndex("version"); colProtocol = cursor.getColumnIndex("protocol"); colFlags = cursor.getColumnIndex("flags"); colSAddr = cursor.getColumnIndex("saddr"); colSPort = cursor.getColumnIndex("sport"); colDaddr = cursor.getColumnIndex("daddr"); colDPort = cursor.getColumnIndex("dport"); colDName = cursor.getColumnIndex("dname"); colUid = cursor.getColumnIndex("uid"); colData = cursor.getColumnIndex("data"); colAllowed = cursor.getColumnIndex("allowed"); colConnection = cursor.getColumnIndex("connection"); colInteractive = cursor.getColumnIndex("interactive"); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorOn, tv, true); colorOn = tv.data;/*ww w . j av a2 s . c om*/ context.getTheme().resolveAttribute(R.attr.colorOff, tv, true); colorOff = tv.data; try { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); dns = SinkholeService.getDns(context); vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1")); vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1")); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:com.ickphum.android.isoview.InteractiveLineGraphView.java
public InteractiveLineGraphView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.InteractiveLineGraphView, defStyle, defStyle);//from ww w. j a va2 s . c o m try { mLabelTextColor = a.getColor(R.styleable.InteractiveLineGraphView_labelTextColor, mLabelTextColor); mLabelTextSize = a.getDimension(R.styleable.InteractiveLineGraphView_labelTextSize, mLabelTextSize); mLabelSeparation = a.getDimensionPixelSize(R.styleable.InteractiveLineGraphView_labelSeparation, mLabelSeparation); mGridThickness = a.getDimension(R.styleable.InteractiveLineGraphView_gridThickness, mGridThickness); mGridColor = a.getColor(R.styleable.InteractiveLineGraphView_gridColor, mGridColor); mAxisThickness = a.getDimension(R.styleable.InteractiveLineGraphView_axisThickness, mAxisThickness); mAxisColor = a.getColor(R.styleable.InteractiveLineGraphView_axisColor, mAxisColor); mDataThickness = a.getDimension(R.styleable.InteractiveLineGraphView_dataThickness, mDataThickness); mDataColor = a.getColor(R.styleable.InteractiveLineGraphView_dataColor, mDataColor); } finally { a.recycle(); } initPaints(); // Sets up interactions if (!this.isInEditMode()) { mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); } mScroller = new OverScroller(context); mZoomer = new Zoomer(context); // Sets up edge effects mEdgeEffectLeft = new EdgeEffectCompat(context); mEdgeEffectTop = new EdgeEffectCompat(context); mEdgeEffectRight = new EdgeEffectCompat(context); mEdgeEffectBottom = new EdgeEffectCompat(context); }
From source file:cn.androidy.androiddevelopmentpatterns.interactivechart.InteractiveLineGraphView.java
public InteractiveLineGraphView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.InteractiveLineGraphView, defStyle, defStyle);//from w w w. j a va 2 s .c o m try { mLabelTextColor = a.getColor(R.styleable.InteractiveLineGraphView_labelTextColor, mLabelTextColor); mLabelTextSize = a.getDimension(R.styleable.InteractiveLineGraphView_labelTextSize, mLabelTextSize); mLabelSeparation = a.getDimensionPixelSize(R.styleable.InteractiveLineGraphView_labelSeparation, mLabelSeparation); mGridThickness = a.getDimension(R.styleable.InteractiveLineGraphView_gridThickness, mGridThickness); mGridColor = a.getColor(R.styleable.InteractiveLineGraphView_gridColor, mGridColor); mAxisThickness = a.getDimension(R.styleable.InteractiveLineGraphView_axisThickness, mAxisThickness); mAxisColor = a.getColor(R.styleable.InteractiveLineGraphView_axisColor, mAxisColor); mDataThickness = a.getDimension(R.styleable.InteractiveLineGraphView_dataThickness, mDataThickness); mDataColor = a.getColor(R.styleable.InteractiveLineGraphView_dataColor, mDataColor); } finally { a.recycle(); } initPaints(); // Sets up interactions mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); mScroller = new OverScroller(context); mZoomer = new Zoomer(context); // Sets up edge effects mEdgeEffectLeft = new EdgeEffectCompat(context); mEdgeEffectTop = new EdgeEffectCompat(context); mEdgeEffectRight = new EdgeEffectCompat(context); mEdgeEffectBottom = new EdgeEffectCompat(context); }
From source file:bottombar.BottomBar.java
private void populateAttributes(Context context, AttributeSet attrs) { primaryColor = MiscUtils.getColor(getContext(), R.attr.colorPrimary); screenWidth = MiscUtils.getScreenWidth(getContext()); tenDp = MiscUtils.dpToPixel(getContext(), 10); maxFixedItemWidth = MiscUtils.dpToPixel(getContext(), 168); TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BottomBar, 0, 0); try {/*from w ww . j av a 2s. c o m*/ tabXmlResource = ta.getResourceId(R.styleable.BottomBar_bb_tabXmlResource, 0); isTabletMode = ta.getBoolean(R.styleable.BottomBar_bb_tabletMode, false); behaviors = ta.getInteger(R.styleable.BottomBar_bb_behavior, BEHAVIOR_NONE); inActiveTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_inActiveTabAlpha, isShiftingMode() ? DEFAULT_INACTIVE_SHIFTING_TAB_ALPHA : 1); activeTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_activeTabAlpha, 1); @ColorInt int defaultInActiveColor = isShiftingMode() ? Color.WHITE : ContextCompat.getColor(context, R.color.bb_inActiveBottomBarItemColor); int defaultActiveColor = isShiftingMode() ? Color.WHITE : primaryColor; inActiveTabColor = ta.getColor(R.styleable.BottomBar_bb_inActiveTabColor, defaultInActiveColor); activeTabColor = ta.getColor(R.styleable.BottomBar_bb_activeTabColor, defaultActiveColor); badgeBackgroundColor = ta.getColor(R.styleable.BottomBar_bb_badgeBackgroundColor, Color.RED); hideBadgeWhenActive = ta.getBoolean(R.styleable.BottomBar_bb_badgesHideWhenActive, true); titleTextAppearance = ta.getResourceId(R.styleable.BottomBar_bb_titleTextAppearance, 0); titleTypeFace = getTypeFaceFromAsset(ta.getString(R.styleable.BottomBar_bb_titleTypeFace)); showShadow = ta.getBoolean(R.styleable.BottomBar_bb_showShadow, true); } finally { ta.recycle(); } }
From source file:com.layer.atlas.AtlasMessagesList.java
public void parseStyle(Context context, AttributeSet attrs, int defStyle) { TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AtlasMessageList, R.attr.AtlasMessageList, defStyle); this.myTextColor = ta.getColor(R.styleable.AtlasMessageList_myTextColor, context.getResources().getColor(R.color.atlas_text_black)); this.myTextStyle = ta.getInt(R.styleable.AtlasMessageList_myTextStyle, Typeface.NORMAL); String myTextTypefaceName = ta.getString(R.styleable.AtlasMessageList_myTextTypeface); this.myTextTypeface = myTextTypefaceName != null ? Typeface.create(myTextTypefaceName, myTextStyle) : null; //this.myTextSize = ta.getDimension(R.styleable.AtlasMessageList_myTextSize, context.getResources().getDimension(R.dimen.atlas_text_size_general)); this.otherTextColor = ta.getColor(R.styleable.AtlasMessageList_theirTextColor, context.getResources().getColor(R.color.atlas_text_black)); this.otherTextStyle = ta.getInt(R.styleable.AtlasMessageList_theirTextStyle, Typeface.NORMAL); String otherTextTypefaceName = ta.getString(R.styleable.AtlasMessageList_theirTextTypeface); this.otherTextTypeface = otherTextTypefaceName != null ? Typeface.create(otherTextTypefaceName, otherTextStyle) : null;//ww w . j av a 2 s .c o m //this.otherTextSize = ta.getDimension(R.styleable.AtlasMessageList_theirTextSize, context.getResources().getDimension(R.dimen.atlas_text_size_general)); this.myBubbleColor = ta.getColor(R.styleable.AtlasMessageList_myBubbleColor, context.getResources().getColor(R.color.atlas_bubble_blue)); this.otherBubbleColor = ta.getColor(R.styleable.AtlasMessageList_theirBubbleColor, context.getResources().getColor(R.color.atlas_background_gray)); this.dateTextColor = ta.getColor(R.styleable.AtlasMessageList_dateTextColor, context.getResources().getColor(R.color.atlas_text_gray)); this.avatarTextColor = ta.getColor(R.styleable.AtlasMessageList_avatarTextColor, context.getResources().getColor(R.color.atlas_text_black)); this.avatarBackgroundColor = ta.getColor(R.styleable.AtlasMessageList_avatarBackgroundColor, context.getResources().getColor(R.color.atlas_background_gray)); ta.recycle(); }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
private int getInteger(Context ctx, TypedValue typedValue, int attrId) { ctx.getTheme().resolveAttribute(attrId, typedValue, true); return ctx.getResources().getInteger(typedValue.resourceId); }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
private int getDimension(Context ctx, TypedValue typedValue, int attrId) { ctx.getTheme().resolveAttribute(attrId, typedValue, true); return ctx.getResources().getDimensionPixelSize(typedValue.resourceId); }
From source file:com.base.view.slidemenu.SlideMenu.java
protected Drawable getDefaultContentBackground(Context context) { TypedValue value = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.windowBackground, value, true); return context.getResources().getDrawable(value.resourceId); }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
private float getFloat(Context ctx, TypedValue typedValue, int attrId) { ctx.getTheme().resolveAttribute(attrId, typedValue, true); // Android resources don't have a native float type, so we have to use strings. return Float.valueOf(ctx.getResources().getString(typedValue.resourceId)); }