项目:q-mail
文件:FoldableLinearLayout.java
/**
* Load given attributes to inner variables,*
* @param context
* @param attrs
*/
private void processAttributes(Context context,AttributeSet attrs) {
Theme theme = context.getTheme();
TypedValue outValue = new TypedValue();
boolean found = theme.resolveAttribute(R.attr.iconActionCollapse,outValue,true);
if (found) {
mIconActionCollapseId = outValue.resourceId;
}
found = theme.resolveAttribute(R.attr.iconActionExpand,true);
if (found) {
mIconActionExpandId = outValue.resourceId;
}
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs,R.styleable.FoldableLinearLayout,0);
mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel);
mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel);
a.recycle();
}
// If any attribute isn't found then set a default one
mFoldedLabel = (mFoldedLabel == null) ? "No text!" : mFoldedLabel;
mUnFoldedLabel = (mUnFoldedLabel == null) ? "No text!" : mUnFoldedLabel;
}
项目:MakiLite
文件:ThemeUtils.java
@TargetApi(LOLLIPOP)
static int resolveAccentColor(Context context) {
Theme theme = context.getTheme();
// on Lollipop,grab system colorAccent attribute
// pre-Lollipop,grab AppCompat colorAccent attribute
// finally,check for custom mp_colorAccent attribute
int attr = isAtLeastL() ? android.R.attr.colorAccent : R.attr.colorAccent;
TypedArray typedArray = theme.obtainStyledAttributes(new int[] { attr,R.attr.mp_colorAccent });
int accentColor = typedArray.getColor(0,FALLBACK_COLOR);
accentColor = typedArray.getColor(1,accentColor);
typedArray.recycle();
return accentColor;
}
项目:GitHub
文件:DrawableDecoderCompat.java
/**
* Loads a Drawable using {@link AppCompatResources} if available and {@link ResourcesCompat}
* otherwise,depending on whether or not the v7 support library is included in the application.
*
* @param theme Used instead of the {@link Theme} returned from the given {@link Context} if
* non-null when loading the {@link Drawable}.
*/
public static Drawable getDrawable(Context context,@DrawableRes int id,@Nullable Theme theme) {
try {
// Race conditions may cause us to attempt to load using v7 more than once. That's ok since
// this check is a modest optimization and the output will be correct anyway.
if (shouldCallAppCompatResources) {
return loadDrawableV7(context,id);
}
} catch (NoClassDefFoundError error) {
shouldCallAppCompatResources = false;
} catch (Resources.NotFoundException e) {
// Ignored,this can be thrown when drawable compat attempts to decode a canary resource. If
// that decode attempt fails,we still want to try with the v4 ResourcesCompat below.
}
return loadDrawableV4(context,id,theme != null ? theme : context.getTheme());
}
项目:letv
文件:JarMainBFragmentActivity.java
public void setoverrideResources(JarResources myres) {
JLog.i("clf","setoverrideResources...myres=" + myres);
if (myres == null) {
this.myResources = null;
this.resources = null;
this.assetManager = null;
this.theme = null;
return;
}
this.myResources = myres;
JLog.i("clf","setoverrideResources...this.myResources=" + this.myResources);
this.resources = myres.getResources();
JLog.i("clf","setoverrideResources...this.resources=" + this.resources);
this.assetManager = myres.getAssets();
JLog.i("clf","setoverrideResources...this.assetManager=" + this.assetManager);
Theme t = myres.getResources().newTheme();
JLog.i("clf","setoverrideResources...t=" + t);
t.setTo(getTheme());
this.theme = t;
JLog.i("clf","setoverrideResources...this.theme=" + this.theme);
}
private void ensureListMenuPresenter(Menu menu) {
if (this.mListMenuPresenter == null && (menu instanceof MenuBuilder)) {
MenuBuilder mb = (MenuBuilder) menu;
Context context = this.mDecorToolbar.getContext();
TypedValue outValue = new TypedValue();
Theme widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(context.getTheme());
widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme,true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId,true);
}
widgetTheme.resolveAttribute(R.attr.panelMenuListTheme,true);
} else {
widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu,true);
}
Context context2 = new ContextThemeWrapper(context,0);
context2.getTheme().setTo(widgetTheme);
this.mListMenuPresenter = new ListMenuPresenter(context2,R.layout.abc_list_menu_item_layout);
this.mListMenuPresenter.setCallback(new PanelMenuPresenterCallback());
mb.addMenuPresenter(this.mListMenuPresenter);
}
}
void setStyle(Context context) {
TypedValue outValue = new TypedValue();
Theme widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(context.getTheme());
widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme,true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId,true);
}
widgetTheme.resolveAttribute(R.attr.panelMenuListTheme,true);
} else {
widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu,true);
}
Context context2 = new ContextThemeWrapper(context,0);
context2.getTheme().setTo(widgetTheme);
this.listPresenterContext = context2;
TypedArray a = context2.obtainStyledAttributes(R.styleable.AppCompatTheme);
this.background = a.getResourceId(R.styleable.AppCompatTheme_panelBackground,0);
this.windowAnimations = a.getResourceId(R.styleable.AppCompatTheme_android_windowAnimationStyle,0);
a.recycle();
}
private boolean initializePanelMenu(PanelFeatureState st) {
Context context = this.mContext;
if ((st.featureId == 0 || st.featureId == 108) && this.mDecorContentParent != null) {
TypedValue outValue = new TypedValue();
Theme baseTheme = context.getTheme();
baseTheme.resolveAttribute(R.attr.actionBarTheme,true);
Theme widgetTheme = null;
if (outValue.resourceId != 0) {
widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(baseTheme);
widgetTheme.applyStyle(outValue.resourceId,true);
widgetTheme.resolveAttribute(R.attr.actionBarWidgetTheme,true);
} else {
baseTheme.resolveAttribute(R.attr.actionBarWidgetTheme,true);
}
if (outValue.resourceId != 0) {
if (widgetTheme == null) {
widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(baseTheme);
}
widgetTheme.applyStyle(outValue.resourceId,true);
}
if (widgetTheme != null) {
Context context2 = new ContextThemeWrapper(context,0);
context2.getTheme().setTo(widgetTheme);
context = context2;
}
}
MenuBuilder menu = new MenuBuilder(context);
menu.setCallback(this);
st.setMenu(menu);
return true;
}
public DropDownAdapter(@Nullable SpinnerAdapter adapter,@Nullable Theme dropDownTheme) {
this.mAdapter = adapter;
if (adapter instanceof listadapter) {
this.mlistadapter = (listadapter) adapter;
}
if (dropDownTheme == null) {
return;
}
if (AppCompatSpinner.IS_AT_LEAST_M && (adapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedAdapter = (ThemedSpinnerAdapter) adapter;
if (themedAdapter.getDropDownViewTheme() != dropDownTheme) {
themedAdapter.setDropDownViewTheme(dropDownTheme);
}
} else if (adapter instanceof ThemedSpinnerAdapter) {
ThemedSpinnerAdapter themedAdapter2 = (ThemedSpinnerAdapter) adapter;
if (themedAdapter2.getDropDownViewTheme() == null) {
themedAdapter2.setDropDownViewTheme(dropDownTheme);
}
}
}
项目:MDPreference
文件:ThemeUtils.java
@TargetApi(LOLLIPOP)
static int resolveAccentColor(Context context) {
Theme theme = context.getTheme();
// on Lollipop,grab system colorAccent attribute
// pre-Lollipop,grab AppCompat colorAccent attribute
// finally,check for custom mp_colorAccent attribute
int attr = isAtLeastL() ? android.R.attr.colorAccent : R.attr.colorAccent;
TypedArray typedArray = theme.obtainStyledAttributes(new int[]{attr,R.attr.mp_colorAccent});
int accentColor = typedArray.getColor(0,FALLBACK_COLOR);
accentColor = typedArray.getColor(1,accentColor);
typedArray.recycle();
return accentColor;
}
项目:solved-hacking-problem
文件:bi.java
public bi(SpinnerAdapter spinnerAdapter,Theme theme) {
this.f1367a = spinnerAdapter;
if (spinnerAdapter instanceof listadapter) {
this.f1368b = (listadapter) spinnerAdapter;
}
if (theme == null) {
return;
}
if (bg.f1353a && (spinnerAdapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedSpinnerAdapter = (ThemedSpinnerAdapter) spinnerAdapter;
if (themedSpinnerAdapter.getDropDownViewTheme() != theme) {
themedSpinnerAdapter.setDropDownViewTheme(theme);
}
} else if (spinnerAdapter instanceof dd) {
dd ddVar = (dd) spinnerAdapter;
if (ddVar.m2705a() == null) {
ddVar.m2706a(theme);
}
}
}
项目:CanDialog
文件:VectorDrawable.java
@Override
public void applyTheme(Theme t) {
super.applyTheme(t);
final VectorDrawableState state = mVectorState;
if (state != null && state.mThemeAttrs != null) {
//Todo
final TypedArray a = null;//t.resolveAttributes(state.mThemeAttrs,R.styleable.VectorDrawable);
try {
state.mCacheDirty = true;
updateStateFromTypedArray(a);
} catch (XmlPullParserException e) {
throw new RuntimeException(e);
} finally {
a.recycle();
}
mTintFilter = updateTintFilter(mTintFilter,state.mTint,state.mTintMode);
}
final VPathRenderer path = state.mVPathRenderer;
if (path != null && path.canApplyTheme()) {
path.applyTheme(t);
}
}
项目:freeotp-android
文件:ProgressCircle.java
private void setup(Context context,AttributeSet attrs) {
displayMetrics dm = getResources().getdisplayMetrics();
mPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,2,dm);
mstrokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,4,dm);
mRectF = new RectF();
mRect = new Rect();
mPaint = new Paint();
mPaint.setARGB(0x99,0x33,0x33);
mPaint.setAntiAlias(true);
mPaint.setstrokeCap(Paint.Cap.BUTT);
if (attrs != null) {
Theme t = context.getTheme();
TypedArray a = t.obtainStyledAttributes(attrs,R.styleable.ProgressCircle,0);
try {
setMax(a.getInteger(R.styleable.ProgressCircle_max,100));
setHollow(a.getBoolean(R.styleable.ProgressCircle_hollow,false));
} finally {
a.recycle();
}
}
}
项目:K9-MailClient
文件:FoldableLinearLayout.java
/**
* Load given attributes to inner variables,0);
mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel);
mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel);
a.recycle();
}
// If any attribute isn't found then set a default one
mFoldedLabel = (mFoldedLabel == null) ? "No text!" : mFoldedLabel;
mUnFoldedLabel = (mUnFoldedLabel == null) ? "No text!" : mUnFoldedLabel;
}
项目:solved-hacking-problem
文件:aq.java
void m1771a(Context context) {
TypedValue typedValue = new TypedValue();
Theme newTheme = context.getResources().newTheme();
newTheme.setTo(context.getTheme());
newTheme.resolveAttribute(C0233b.actionBarPopupTheme,typedValue,true);
if (typedValue.resourceId != 0) {
newTheme.applyStyle(typedValue.resourceId,true);
}
newTheme.resolveAttribute(C0233b.panelMenuListTheme,true);
} else {
newTheme.applyStyle(C0242k.Theme_AppCompat_CompactMenu,true);
}
Context c0249e = new C0249e(context,0);
c0249e.getTheme().setTo(newTheme);
this.f646l = c0249e;
TypedArray obtainStyledAttributes = c0249e.obtainStyledAttributes(C0243l.AppCompatTheme);
this.f636b = obtainStyledAttributes.getResourceId(C0243l.AppCompatTheme_panelBackground,0);
this.f640f = obtainStyledAttributes.getResourceId(C0243l.AppCompatTheme_android_windowAnimationStyle,0);
obtainStyledAttributes.recycle();
}
项目:apker
文件:JarMainBaseActivity.java
@Override
public void setoverrideResources(ApkResources myres) {
if (myres == null) {
this.jarResources = null;
this.resources = null;
this.assetManager = null;
this.theme = null;
} else {
this.jarResources = myres;
this.resources = myres.getResources();
this.assetManager = myres.getAssets();
Theme t = myres.getResources().newTheme();
t.setTo(getTheme());
this.theme = t;
}
}
项目:CanDialog
文件:VectorDrawable.java
private void recursiveApplyTheme(VGroup currentGroup,Theme t) {
// We can do a tree traverse here,apply theme to all paths which
// can apply theme.
final ArrayList<Object> children = currentGroup.mChildren;
for (int i = 0; i < children.size(); i++) {
Object child = children.get(i);
if (child instanceof VGroup) {
VGroup childGroup = (VGroup) child;
if (childGroup.canApplyTheme()) {
childGroup.applyTheme(t);
}
recursiveApplyTheme(childGroup,t);
} else if (child instanceof VPath) {
VPath childpath = (VPath) child;
if (childpath.canApplyTheme()) {
childpath.applyTheme(t);
}
}
}
}
项目:SOS-The-Healthcare-Companion
文件:ContactBadge.java
private void initOverlay(Context context,Shape shape) {
// pressed state
TypedValue typedValue = new TypedValue();
Theme theme = context.getTheme();
mpressedOverlay = new ShapeDrawable(shape);
int overlayColor = Color.parseColor("#aa888888");
if (theme.resolveAttribute(R.attr.cp_badgeOverlayColor,true)) {
overlayColor = typedValue.data;
}
Paint paint = mpressedOverlay.getPaint();
paint.setColor(overlayColor);
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
}
项目:letv
文件:JarMainBaseActivity.java
public void setoverrideResources(JarResources myres) {
if (myres == null) {
this.jarResources = null;
this.resources = null;
this.assetManager = null;
this.theme = null;
return;
}
this.jarResources = myres;
this.resources = myres.getResources();
this.assetManager = myres.getAssets();
Theme t = myres.getResources().newTheme();
t.setTo(getTheme());
this.theme = t;
}
项目:letv
文件:ResourcesCompat.java
@Nullable
public static Drawable getDrawable(@NonNull Resources res,@Nullable Theme theme) throws NotFoundException {
if (VERSION.SDK_INT >= 21) {
return ResourcesCompatApi21.getDrawable(res,theme);
}
return res.getDrawable(id);
}
项目:letv
文件:ResourcesCompat.java
@Nullable
public static Drawable getDrawableForDensity(@NonNull Resources res,int density,@Nullable Theme theme) throws NotFoundException {
if (VERSION.SDK_INT >= 21) {
return ResourcesCompatApi21.getDrawableForDensity(res,density,theme);
}
if (VERSION.SDK_INT >= 15) {
return ResourcesCompatIcsMr1.getDrawableForDensity(res,density);
}
return res.getDrawable(id);
}
项目:letv
文件:ResourcesCompat.java
@ColorInt
public static int getColor(@NonNull Resources res,@ColorRes int id,@Nullable Theme theme) throws NotFoundException {
if (VERSION.SDK_INT >= 23) {
return ResourcesCompatApi23.getColor(res,theme);
}
return res.getColor(id);
}
项目:letv
文件:ResourcesCompat.java
@Nullable
public static ColorStateList getColorStateList(@NonNull Resources res,@Nullable Theme theme) throws NotFoundException {
if (VERSION.SDK_INT >= 23) {
return ResourcesCompatApi23.getColorStateList(res,theme);
}
return res.getColorStateList(id);
}
项目:respinner
文件:ReSpinner.java
public ReSpinner(Context context,AttributeSet attrs,int defStyleAttr,int mode,Theme popupTheme) {
super(context,attrs,defStyleAttr,mode,popupTheme);
}
public Theme getTheme() {
if (this.mTheme != null) {
return this.mTheme;
}
if (this.mThemeResource == 0) {
this.mThemeResource = R.style.Theme_AppCompat_Light;
}
initializeTheme();
return this.mTheme;
}
public Drawable createFromXmlInner(@NonNull Context context,@NonNull XmlPullParser parser,@NonNull AttributeSet attrs,@Nullable Theme theme) {
try {
return AnimatedVectorDrawableCompat.createFromXmlInner(context,context.getResources(),parser,theme);
} catch (Exception e) {
Log.e("AvdcInflateDelegate","Exception while inflating <animated-vector>",e);
return null;
}
}
public Drawable createFromXmlInner(@NonNull Context context,@Nullable Theme theme) {
try {
return VectorDrawableCompat.createFromXmlInner(context.getResources(),theme);
} catch (Exception e) {
Log.e("VdcInflateDelegate","Exception while inflating <vector>",e);
return null;
}
}
public void setDropDownViewTheme(@Nullable Theme theme) {
if (theme == null) {
this.mDropDownInflater = null;
} else if (theme == this.mContext.getTheme()) {
this.mDropDownInflater = this.mInflater;
} else {
this.mDropDownInflater = LayoutInflater.from(new ContextThemeWrapper(this.mContext,theme));
}
}
public void inflate(Resources r,Theme theme,XmlPullParser parser) {
if (TypedArrayUtils.hasAttribute(parser,"pathData")) {
TypedArray a = VectorDrawableCommon.obtainAttributes(r,theme,AndroidResources.styleable_VectorDrawableClipPath);
updateStateFromTypedArray(a);
a.recycle();
}
}
@Nullable
public static VectorDrawableCompat create(@NonNull Resources res,@DrawableRes int resId,@Nullable Theme theme) {
if (VERSION.SDK_INT >= 21) {
VectorDrawableCompat drawable = new VectorDrawableCompat();
drawable.mDelegateDrawable = ResourcesCompat.getDrawable(res,resId,theme);
drawable.mCachedConstantStateDelegate = new VectorDrawableDelegateState(drawable.mDelegateDrawable.getConstantState());
return drawable;
}
try {
int type;
XmlPullParser parser = res.getXml(resId);
AttributeSet attrs = Xml.asAttributeSet(parser);
do {
type = parser.next();
if (type == 2) {
break;
}
} while (type != 1);
if (type == 2) {
return createFromXmlInner(res,theme);
}
throw new XmlPullParserException("No start tag found");
} catch (XmlPullParserException e) {
Log.e(LOGTAG,"parser error",e);
return null;
} catch (IOException e2) {
Log.e(LOGTAG,e2);
return null;
}
}
public void inflate(Resources res,XmlPullParser parser,Theme theme) throws XmlPullParserException,IOException {
if (this.mDelegateDrawable != null) {
DrawableCompat.inflate(this.mDelegateDrawable,res,theme);
return;
}
VectorDrawableCompatState state = this.mVectorState;
state.mVPathRenderer = new VPathRenderer();
TypedArray a = VectorDrawableCommon.obtainAttributes(res,AndroidResources.styleable_VectorDrawableTypeArray);
updateStateFromTypedArray(a,parser);
a.recycle();
state.mChangingConfigurations = getChangingConfigurations();
state.mCacheDirty = true;
inflateInternal(res,theme);
this.mTintFilter = updateTintFilter(this.mTintFilter,state.mTintMode);
}
@Nullable
public static Drawable getDrawable(@NonNull Resources res,theme);
}
return res.getDrawable(id);
}
@Nullable
public static Drawable getDrawableForDensity(@NonNull Resources res,density);
}
return res.getDrawable(id);
}
@ColorInt
public static int getColor(@NonNull Resources res,theme);
}
return res.getColor(id);
}
@Nullable
public static ColorStateList getColorStateList(@NonNull Resources res,theme);
}
return res.getColorStateList(id);
}
项目:FlickLauncher
文件:PreloadIconDrawable.java
项目:FlickLauncher
文件:PreloadIconDrawable.java
public void applyPreloaderTheme(Theme t) {
TypedArray ta = t.obtainStyledAttributes(R.styleable.PreloadIconDrawable);
mBgDrawable = ta.getDrawable(R.styleable.PreloadIconDrawable_background);
mBgDrawable.setFilterBitmap(true);
mPaint.setstrokeWidth(ta.getDimension(R.styleable.PreloadIconDrawable_indicatorSize,0));
mRingOutset = ta.getDimensionPixelSize(R.styleable.PreloadIconDrawable_ringOutset,0);
ta.recycle();
onBoundsChange(getBounds());
invalidateSelf();
}
项目:FlickLauncher
文件:BubbleTextView.java
private Theme getPreloaderTheme() {
Object tag = getTag();
int style = ((tag != null) && (tag instanceof ShortcutInfo) &&
(((ShortcutInfo) tag).container >= 0)) ? R.style.PreloadIcon_Folder
: R.style.PreloadIcon;
Theme theme = sPreloaderThemes.get(style);
if (theme == null) {
theme = getResources().newTheme();
theme.applyStyle(style,true);
sPreloaderThemes.put(style,theme);
}
return theme;
}
项目:SimpleUILauncher
文件:PreloadIconDrawable.java
项目:SimpleUILauncher
文件:PreloadIconDrawable.java
public void applyPreloaderTheme(Theme t) {
TypedArray ta = t.obtainStyledAttributes(R.styleable.PreloadIconDrawable);
mBgDrawable = ta.getDrawable(R.styleable.PreloadIconDrawable_background);
mBgDrawable.setFilterBitmap(true);
mPaint.setstrokeWidth(ta.getDimension(R.styleable.PreloadIconDrawable_indicatorSize,0);
ta.recycle();
onBoundsChange(getBounds());
invalidateSelf();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。