From 3df5db5dbefe6168c36d43a1b45de280fa92f249 Mon Sep 17 00:00:00 2001 From: donghongyu Date: Sat, 12 Oct 2024 20:13:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=8CUpdate=E3=80=8D=201=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20=E6=9C=AA=E5=85=BC=E5=AE=B9=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=B4=A9=E6=BA=83=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../java/com/mogo/skin/SkinAttribute.java | 118 +++++++++--------- 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/gradle.properties b/gradle.properties index 28ec353..e1cc6a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -58,4 +58,4 @@ MOGO_TELEMATIC_VERSION=1.4.7.42 # v2x MOGO_V2X_VERSION=1.4.7.42 # SKIN -MOGO_SKIN_VERSION=1.4.7.44 +MOGO_SKIN_VERSION=1.4.7.45 diff --git a/libraries/mogo-skin/src/main/java/com/mogo/skin/SkinAttribute.java b/libraries/mogo-skin/src/main/java/com/mogo/skin/SkinAttribute.java index 24d6cd8..e1ed9c2 100644 --- a/libraries/mogo-skin/src/main/java/com/mogo/skin/SkinAttribute.java +++ b/libraries/mogo-skin/src/main/java/com/mogo/skin/SkinAttribute.java @@ -132,63 +132,69 @@ public class SkinAttribute { public void applySkin(Typeface typeface) { applySkinTypeface(typeface); applySkinViewSupport(); - for (SkinPair skinPair : skinPairs) { - Drawable left = null, top = null, right = null, bottom = null; - String textStr; - switch (skinPair.attributeName) { - case "background": - Object background = SkinResources.getInstance().getBackground(skinPair.resId); - //Color - if (background instanceof Integer) { - view.setBackgroundColor((Integer) background); - } else { - ViewCompat.setBackground(view, (Drawable) background); - } - break; - case "src": - background = SkinResources.getInstance().getBackground(skinPair.resId); - if (background instanceof Integer) { - ((ImageView) view).setImageDrawable(new ColorDrawable((Integer) background)); - } else { - ((ImageView) view).setImageDrawable((Drawable) background); - } - break; - case "textColor": - ((TextView) view).setTextColor(SkinResources.getInstance().getColorStateList(skinPair.resId)); - break; - case "textColorHint": - ((EditText) view).setHintTextColor(SkinResources.getInstance().getColorStateList(skinPair.resId)); - break; - case "drawableLeft": - left = SkinResources.getInstance().getDrawable(skinPair.resId); - break; - case "drawableTop": - top = SkinResources.getInstance().getDrawable(skinPair.resId); - break; - case "drawableRight": - right = SkinResources.getInstance().getDrawable(skinPair.resId); - break; - case "drawableBottom": - bottom = SkinResources.getInstance().getDrawable(skinPair.resId); - break; - case "skinTypeface": - Typeface typeface1 = SkinResources.getInstance().getTypeface(skinPair.resId); - applySkinTypeface(typeface1); - break; - case "text": - textStr = SkinResources.getInstance().getString(skinPair.resId); - applyText(textStr); - break; - case "hint": - textStr = SkinResources.getInstance().getString(skinPair.resId); - applyHintText(textStr); - break; - default: - break; - } - if (null != left || null != right || null != top || null != bottom) { - ((TextView) view).setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); + try { + for (SkinPair skinPair : skinPairs) { + Drawable left = null, top = null, right = null, bottom = null; + String textStr; + switch (skinPair.attributeName) { + case "background": + Object background = SkinResources.getInstance().getBackground(skinPair.resId); + //Color + if (background instanceof Integer) { + view.setBackgroundColor((Integer) background); + } else { + ViewCompat.setBackground(view, (Drawable) background); + } + break; + case "src": + if (view instanceof ImageView){ + background = SkinResources.getInstance().getBackground(skinPair.resId); + if (background instanceof Integer) { + ((ImageView) view).setImageDrawable(new ColorDrawable((Integer) background)); + } else { + ((ImageView) view).setImageDrawable((Drawable) background); + } + } + break; + case "textColor": + ((TextView) view).setTextColor(SkinResources.getInstance().getColorStateList(skinPair.resId)); + break; + case "textColorHint": + ((EditText) view).setHintTextColor(SkinResources.getInstance().getColorStateList(skinPair.resId)); + break; + case "drawableLeft": + left = SkinResources.getInstance().getDrawable(skinPair.resId); + break; + case "drawableTop": + top = SkinResources.getInstance().getDrawable(skinPair.resId); + break; + case "drawableRight": + right = SkinResources.getInstance().getDrawable(skinPair.resId); + break; + case "drawableBottom": + bottom = SkinResources.getInstance().getDrawable(skinPair.resId); + break; + case "skinTypeface": + Typeface typeface1 = SkinResources.getInstance().getTypeface(skinPair.resId); + applySkinTypeface(typeface1); + break; + case "text": + textStr = SkinResources.getInstance().getString(skinPair.resId); + applyText(textStr); + break; + case "hint": + textStr = SkinResources.getInstance().getString(skinPair.resId); + applyHintText(textStr); + break; + default: + break; + } + if (null != left || null != right || null != top || null != bottom) { + ((TextView) view).setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); + } } + } catch (Exception e) { + e.printStackTrace(); } }