「Update」
1、修复 未兼容控件导致的崩溃异常 2、增加 getRawInputStream 获取资源包下的Raw文件流
This commit is contained in:
@@ -33,7 +33,7 @@ SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
|
||||
USERNAME=xintai
|
||||
PASSWORD=xintai2018
|
||||
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
|
||||
RELEASE=true
|
||||
RELEASE=false
|
||||
# AI CLOUD 云平台
|
||||
# 工具类
|
||||
MOGO_UTILS_VERSION=1.4.7.42
|
||||
@@ -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.45
|
||||
MOGO_SKIN_VERSION=1.4.7.47
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* donghongyu
|
||||
* donghongyu
|
||||
*/
|
||||
public class SkinAttribute {
|
||||
|
||||
@@ -76,8 +76,9 @@ public class SkinAttribute {
|
||||
} else {
|
||||
try {
|
||||
// @12343455332
|
||||
if (isNumeric(attributeValue.substring(1))) {
|
||||
resId = Integer.parseInt(attributeValue.substring(1));
|
||||
String resIdStr = attributeValue.substring(1);
|
||||
if (isNumeric(resIdStr)) {
|
||||
resId = Integer.parseInt(resIdStr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 由于有时候TextView会直接配置文字,而不是用 @string/XXX 所以会导致这里转换异常,车里简单的处理异常跳过即可
|
||||
@@ -130,7 +131,8 @@ public class SkinAttribute {
|
||||
* @param typeface 字体
|
||||
*/
|
||||
public void applySkin(Typeface typeface) {
|
||||
applySkinTypeface(typeface);
|
||||
Log.d(TAG, "applySkin() called with: typeface = [" + typeface + "] view = [" + view + "] Parent = " + view.getParent());
|
||||
//applySkinTypeface(typeface);
|
||||
applySkinViewSupport();
|
||||
try {
|
||||
for (SkinPair skinPair : skinPairs) {
|
||||
@@ -147,20 +149,32 @@ public class SkinAttribute {
|
||||
}
|
||||
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);
|
||||
try {
|
||||
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);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case "textColor":
|
||||
((TextView) view).setTextColor(SkinResources.getInstance().getColorStateList(skinPair.resId));
|
||||
try {
|
||||
((TextView) view).setTextColor(SkinResources.getInstance().getColorStateList(skinPair.resId));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case "textColorHint":
|
||||
((EditText) view).setHintTextColor(SkinResources.getInstance().getColorStateList(skinPair.resId));
|
||||
try {
|
||||
((EditText) view).setHintTextColor(SkinResources.getInstance().getColorStateList(skinPair.resId));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case "drawableLeft":
|
||||
left = SkinResources.getInstance().getDrawable(skinPair.resId);
|
||||
@@ -179,12 +193,16 @@ public class SkinAttribute {
|
||||
applySkinTypeface(typeface1);
|
||||
break;
|
||||
case "text":
|
||||
textStr = SkinResources.getInstance().getString(skinPair.resId);
|
||||
applyText(textStr);
|
||||
if (skinPair.resId > 0) {
|
||||
textStr = SkinResources.getInstance().getString(skinPair.resId);
|
||||
applyText(textStr);
|
||||
}
|
||||
break;
|
||||
case "hint":
|
||||
textStr = SkinResources.getInstance().getString(skinPair.resId);
|
||||
applyHintText(textStr);
|
||||
if (skinPair.resId > 0) {
|
||||
textStr = SkinResources.getInstance().getString(skinPair.resId);
|
||||
applyHintText(textStr);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -6,12 +6,17 @@ import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* donghongyu
|
||||
*/
|
||||
public class SkinResources {
|
||||
|
||||
private String TAG = "SkinResources";
|
||||
|
||||
private static SkinResources instance;
|
||||
|
||||
private Resources mSkinResources;
|
||||
@@ -65,6 +70,22 @@ public class SkinResources {
|
||||
return skinId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取皮肤中的Raw文件InputStream
|
||||
* @param resId
|
||||
* @return
|
||||
*/
|
||||
public InputStream getRawInputStream(int resId) {
|
||||
if (isDefaultSkin) {
|
||||
return mAppResources.openRawResource(resId);
|
||||
}
|
||||
int skinId = getIdentifier(resId);
|
||||
if (skinId == 0) {
|
||||
return mAppResources.openRawResource(resId);
|
||||
}
|
||||
return mSkinResources.openRawResource(resId);
|
||||
}
|
||||
|
||||
public int getColor(int resId) {
|
||||
if (isDefaultSkin) {
|
||||
return mAppResources.getColor(resId);
|
||||
@@ -130,7 +151,7 @@ public class SkinResources {
|
||||
}
|
||||
int skinId = getIdentifier(resId);
|
||||
if (skinId == 0) {
|
||||
return mAppResources.getString(skinId);
|
||||
return mAppResources.getString(resId);
|
||||
}
|
||||
return mSkinResources.getString(skinId);
|
||||
} else {
|
||||
@@ -151,6 +172,7 @@ public class SkinResources {
|
||||
public Typeface getTypeface(int resId) {
|
||||
String skinTypefacePath = getString(resId);
|
||||
if (TextUtils.isEmpty(skinTypefacePath)) {
|
||||
Log.d(TAG, "没有配置字体");
|
||||
return Typeface.DEFAULT;
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user