Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
SkinLibrary
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gaodapeng
SkinLibrary
Commits
7c739eaf
Commit
7c739eaf
authored
Jul 01, 2021
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交标准版
parent
1698d4bc
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
256 additions
and
61 deletions
+256
-61
MainActivity.kt
demo/src/main/java/com/study/skindemo/MainActivity.kt
+1
-1
OneApplication.java
demo/src/main/java/com/study/skindemo/OneApplication.java
+1
-1
build.gradle
skin-lib/build.gradle
+36
-8
ExampleInstrumentedTest.kt
...ndroidTest/java/com/study/libs/ExampleInstrumentedTest.kt
+0
-24
AndroidManifest.xml
skin-lib/src/main/AndroidManifest.xml
+1
-2
ActivityLifeCycleCallback.java
...ain/java/com/miya/skin_lib/ActivityLifeCycleCallback.java
+2
-2
SkinAttribute.java
skin-lib/src/main/java/com/miya/skin_lib/SkinAttribute.java
+9
-10
SkinLayoutInflaterFactory.java
...ain/java/com/miya/skin_lib/SkinLayoutInflaterFactory.java
+2
-2
SkinManager.java
skin-lib/src/main/java/com/miya/skin_lib/SkinManager.java
+6
-6
SkinPreference.java
skin-lib/src/main/java/com/miya/skin_lib/SkinPreference.java
+1
-1
SkinViewSupport.java
...-lib/src/main/java/com/miya/skin_lib/SkinViewSupport.java
+1
-1
SkinResources.java
.../src/main/java/com/miya/skin_lib/utils/SkinResources.java
+1
-2
SkinThemeUtils.java
...src/main/java/com/miya/skin_lib/utils/SkinThemeUtils.java
+194
-0
ExampleUnitTest.kt
skin-lib/src/test/java/com/study/libs/ExampleUnitTest.kt
+1
-1
No files found.
demo/src/main/java/com/study/skindemo/MainActivity.kt
View file @
7c739eaf
...
@@ -2,7 +2,7 @@ package com.study.skindemo
...
@@ -2,7 +2,7 @@ package com.study.skindemo
import
android.os.Bundle
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
com.
study.libs
.SkinManager
import
com.
miya.skin_lib
.SkinManager
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.activity_main.*
import
java.io.File
import
java.io.File
...
...
demo/src/main/java/com/study/skindemo/OneApplication.java
View file @
7c739eaf
...
@@ -2,7 +2,7 @@ package com.study.skindemo;
...
@@ -2,7 +2,7 @@ package com.study.skindemo;
import
android.app.Application
;
import
android.app.Application
;
import
com.
study.libs
.SkinManager
;
import
com.
miya.skin_lib
.SkinManager
;
public
class
OneApplication
extends
Application
{
public
class
OneApplication
extends
Application
{
...
...
skin-lib/build.gradle
View file @
7c739eaf
apply
plugin:
'com.android.library'
apply
plugin:
'com.android.library'
apply
plugin:
'kotlin-android'
apply
plugin:
"maven-publish"
apply
plugin:
'
kotlin-android-extensions'
apply
plugin:
'
maven'
//发布到maven 库中的插件
android
{
android
{
compileSdkVersion
28
compileSdkVersion
28
...
@@ -12,7 +12,6 @@ android {
...
@@ -12,7 +12,6 @@ android {
versionCode
1
versionCode
1
versionName
"1.0"
versionName
"1.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles
"consumer-rules.pro"
consumerProguardFiles
"consumer-rules.pro"
}
}
...
@@ -22,15 +21,44 @@ android {
...
@@ -22,15 +21,44 @@ android {
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
}
}
}
android
.
libraryVariants
.
all
{
variant
->
variant
.
outputs
.
all
{
outputFileName
=
'skin-lib'
+
"-${defaultConfig.versionName}"
+
'.aar'
}
}
}
}
dependencies
{
dependencies
{
implementation
fileTree
(
dir:
"libs"
,
include:
[
"*.jar"
])
implementation
fileTree
(
dir:
"libs"
,
include:
[
"*.jar"
])
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation
'androidx.core:core-ktx:1.3.2'
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
'androidx.appcompat:appcompat:1.2.0'
testImplementation
'junit:junit:4.12'
}
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
//设置动态属性
ext
{
//发布到仓库用户名
publishUserName
=
"face-dev"
//发布到仓库地址
publishUserPassword
=
"Face-dev@2019"
//仓库地址
publishURL
=
"https://nexus.infra.miyatech.com/repository/shualianzhifu/"
publishVersion
=
1.0
publishArtifactId
=
"skin-lib"
publishGroupId
=
'com.miya.iot'
}
uploadArchives
{
repositories
.
mavenDeployer
{
repository
(
url:
publishURL
)
{
//RELEASE
authentication
(
userName:
publishUserName
,
password:
publishUserPassword
)
}
pom
.
project
{
version
publishVersion
artifactId
publishArtifactId
groupId
publishGroupId
packaging
'aar'
description
'skin_lib'
}
}
}
}
\ No newline at end of file
skin-lib/src/androidTest/java/com/study/libs/ExampleInstrumentedTest.kt
deleted
100644 → 0
View file @
1698d4bc
package
com.study.libs
import
androidx.test.platform.app.InstrumentationRegistry
import
androidx.test.ext.junit.runners.AndroidJUnit4
import
org.junit.Test
import
org.junit.runner.RunWith
import
org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith
(
AndroidJUnit4
::
class
)
class
ExampleInstrumentedTest
{
@Test
fun
useAppContext
()
{
// Context of the app under test.
val
appContext
=
InstrumentationRegistry
.
getInstrumentation
().
targetContext
assertEquals
(
"com.study.libs.test"
,
appContext
.
packageName
)
}
}
\ No newline at end of file
skin-lib/src/main/AndroidManifest.xml
View file @
7c739eaf
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.
study.libs
"
>
package=
"com.
miya.skin_lib
"
>
/
</manifest>
</manifest>
\ No newline at end of file
skin-lib/src/main/java/com/
study/libs
/ActivityLifeCycleCallback.java
→
skin-lib/src/main/java/com/
miya/skin_lib
/ActivityLifeCycleCallback.java
View file @
7c739eaf
package
com
.
study
.
libs
;
package
com
.
miya
.
skin_lib
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.app.Application
;
...
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
...
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
androidx.core.view.LayoutInflaterCompat
;
import
androidx.core.view.LayoutInflaterCompat
;
import
com.
study.libs
.utils.SkinThemeUtils
;
import
com.
miya.skin_lib
.utils.SkinThemeUtils
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
...
skin-lib/src/main/java/com/
study/libs
/SkinAttribute.java
→
skin-lib/src/main/java/com/
miya/skin_lib
/SkinAttribute.java
View file @
7c739eaf
package
com
.
study
.
libs
;
package
com
.
miya
.
skin_lib
;
import
android.graphics.drawable.ColorDrawable
;
import
android.graphics.drawable.ColorDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
...
@@ -9,8 +9,7 @@ import android.widget.TextView;
...
@@ -9,8 +9,7 @@ import android.widget.TextView;
import
androidx.core.view.ViewCompat
;
import
androidx.core.view.ViewCompat
;
import
com.study.libs.utils.SkinResources
;
import
com.miya.skin_lib.utils.SkinThemeUtils
;
import
com.study.libs.utils.SkinThemeUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -111,7 +110,7 @@ public class SkinAttribute {
...
@@ -111,7 +110,7 @@ public class SkinAttribute {
Drawable
left
=
null
,
top
=
null
,
right
=
null
,
bottom
=
null
;
Drawable
left
=
null
,
top
=
null
,
right
=
null
,
bottom
=
null
;
switch
(
skinPair
.
attributeName
)
{
switch
(
skinPair
.
attributeName
)
{
case
"background"
:
case
"background"
:
Object
background
=
SkinResources
.
getInstance
().
getBackground
(
skinPair
Object
background
=
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
getBackground
(
skinPair
.
resId
);
.
resId
);
//背景可能是 @color 也可能是 @drawable
//背景可能是 @color 也可能是 @drawable
if
(
background
instanceof
Integer
)
{
if
(
background
instanceof
Integer
)
{
...
@@ -121,7 +120,7 @@ public class SkinAttribute {
...
@@ -121,7 +120,7 @@ public class SkinAttribute {
}
}
break
;
break
;
case
"src"
:
case
"src"
:
background
=
SkinResources
.
getInstance
().
getBackground
(
skinPair
.
resId
);
background
=
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
getBackground
(
skinPair
.
resId
);
if
(
background
instanceof
Integer
)
{
if
(
background
instanceof
Integer
)
{
((
ImageView
)
view
).
setImageDrawable
(
new
ColorDrawable
((
Integer
)
((
ImageView
)
view
).
setImageDrawable
(
new
ColorDrawable
((
Integer
)
background
));
background
));
...
@@ -130,20 +129,20 @@ public class SkinAttribute {
...
@@ -130,20 +129,20 @@ public class SkinAttribute {
}
}
break
;
break
;
case
"textColor"
:
case
"textColor"
:
((
TextView
)
view
).
setTextColor
(
SkinResources
.
getInstance
().
getColorStateList
((
TextView
)
view
).
setTextColor
(
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
getColorStateList
(
skinPair
.
resId
));
(
skinPair
.
resId
));
break
;
break
;
case
"drawableLeft"
:
case
"drawableLeft"
:
left
=
SkinResources
.
getInstance
().
getDrawable
(
skinPair
.
resId
);
left
=
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
getDrawable
(
skinPair
.
resId
);
break
;
break
;
case
"drawableTop"
:
case
"drawableTop"
:
top
=
SkinResources
.
getInstance
().
getDrawable
(
skinPair
.
resId
);
top
=
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
getDrawable
(
skinPair
.
resId
);
break
;
break
;
case
"drawableRight"
:
case
"drawableRight"
:
right
=
SkinResources
.
getInstance
().
getDrawable
(
skinPair
.
resId
);
right
=
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
getDrawable
(
skinPair
.
resId
);
break
;
break
;
case
"drawableBottom"
:
case
"drawableBottom"
:
bottom
=
SkinResources
.
getInstance
().
getDrawable
(
skinPair
.
resId
);
bottom
=
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
getDrawable
(
skinPair
.
resId
);
break
;
break
;
default
:
default
:
break
;
break
;
...
...
skin-lib/src/main/java/com/
study/libs
/SkinLayoutInflaterFactory.java
→
skin-lib/src/main/java/com/
miya/skin_lib
/SkinLayoutInflaterFactory.java
View file @
7c739eaf
package
com
.
study
.
libs
;
package
com
.
miya
.
skin_lib
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -11,7 +11,7 @@ import androidx.annotation.NonNull;
...
@@ -11,7 +11,7 @@ import androidx.annotation.NonNull;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
com.
study.libs
.utils.SkinThemeUtils
;
import
com.
miya.skin_lib
.utils.SkinThemeUtils
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Constructor
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
...
skin-lib/src/main/java/com/
study/libs
/SkinManager.java
→
skin-lib/src/main/java/com/
miya/skin_lib
/SkinManager.java
View file @
7c739eaf
package
com
.
study
.
libs
;
package
com
.
miya
.
skin_lib
;
import
android.app.Application
;
import
android.app.Application
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageInfo
;
...
@@ -10,7 +10,7 @@ import android.text.TextUtils;
...
@@ -10,7 +10,7 @@ import android.text.TextUtils;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
com.
study.libs.utils.SkinResource
s
;
import
com.
miya.skin_lib.utils.SkinThemeUtil
s
;
import
java.io.File
;
import
java.io.File
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
...
@@ -30,7 +30,7 @@ public class SkinManager extends Observable {
...
@@ -30,7 +30,7 @@ public class SkinManager extends Observable {
private
SkinManager
(
Application
application
)
{
private
SkinManager
(
Application
application
)
{
this
.
application
=
application
;
this
.
application
=
application
;
SkinPreference
.
init
(
application
.
getApplicationContext
());
SkinPreference
.
init
(
application
.
getApplicationContext
());
SkinResources
.
init
(
application
);
Skin
ThemeUtils
.
Skin
Resources
.
init
(
application
);
application
.
registerActivityLifecycleCallbacks
(
new
ActivityLifeCycleCallback
(
this
));
application
.
registerActivityLifecycleCallbacks
(
new
ActivityLifeCycleCallback
(
this
));
loadSkin
(
SkinPreference
.
getInstance
().
getSkin
());
loadSkin
(
SkinPreference
.
getInstance
().
getSkin
());
}
}
...
@@ -61,7 +61,7 @@ public class SkinManager extends Observable {
...
@@ -61,7 +61,7 @@ public class SkinManager extends Observable {
public
void
loadSkin
(
String
skinPath
)
{
public
void
loadSkin
(
String
skinPath
)
{
if
(
TextUtils
.
isEmpty
(
skinPath
)
&&
!
new
File
(
skinPath
).
exists
())
{
//如果为空或者不存在该文件,则不用管
if
(
TextUtils
.
isEmpty
(
skinPath
)
&&
!
new
File
(
skinPath
).
exists
())
{
//如果为空或者不存在该文件,则不用管
SkinPreference
.
getInstance
().
reset
();
SkinPreference
.
getInstance
().
reset
();
SkinResources
.
getInstance
().
reset
();
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
reset
();
}
else
{
}
else
{
try
{
try
{
Resources
appResource
=
application
.
getResources
();
Resources
appResource
=
application
.
getResources
();
...
@@ -72,7 +72,7 @@ public class SkinManager extends Observable {
...
@@ -72,7 +72,7 @@ public class SkinManager extends Observable {
Resources
skinResources
=
new
Resources
(
assetManager
,
appResource
.
getDisplayMetrics
(),
appResource
.
getConfiguration
());
Resources
skinResources
=
new
Resources
(
assetManager
,
appResource
.
getDisplayMetrics
(),
appResource
.
getConfiguration
());
PackageManager
packageManager
=
application
.
getPackageManager
();
PackageManager
packageManager
=
application
.
getPackageManager
();
PackageInfo
info
=
packageManager
.
getPackageArchiveInfo
(
skinPath
,
PackageManager
.
GET_ACTIVITIES
);
PackageInfo
info
=
packageManager
.
getPackageArchiveInfo
(
skinPath
,
PackageManager
.
GET_ACTIVITIES
);
SkinResources
.
getInstance
().
applySkin
(
skinResources
,
info
.
packageName
);
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
applySkin
(
skinResources
,
info
.
packageName
);
SkinPreference
.
getInstance
().
setSkin
(
skinPath
);
SkinPreference
.
getInstance
().
setSkin
(
skinPath
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -88,7 +88,7 @@ public class SkinManager extends Observable {
...
@@ -88,7 +88,7 @@ public class SkinManager extends Observable {
*/
*/
public
void
reset
()
{
public
void
reset
()
{
SkinPreference
.
getInstance
().
reset
();
SkinPreference
.
getInstance
().
reset
();
SkinResources
.
getInstance
().
reset
();
Skin
ThemeUtils
.
Skin
Resources
.
getInstance
().
reset
();
setChanged
();
setChanged
();
notifyObservers
();
notifyObservers
();
}
}
...
...
skin-lib/src/main/java/com/
study/libs
/SkinPreference.java
→
skin-lib/src/main/java/com/
miya/skin_lib
/SkinPreference.java
View file @
7c739eaf
package
com
.
study
.
libs
;
package
com
.
miya
.
skin_lib
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
...
...
skin-lib/src/main/java/com/
study/libs
/SkinViewSupport.java
→
skin-lib/src/main/java/com/
miya/skin_lib
/SkinViewSupport.java
View file @
7c739eaf
package
com
.
study
.
libs
;
package
com
.
miya
.
skin_lib
;
public
interface
SkinViewSupport
{
public
interface
SkinViewSupport
{
...
...
skin-lib/src/main/java/com/
study/libs
/utils/SkinResources.java
→
skin-lib/src/main/java/com/
miya/skin_lib
/utils/SkinResources.java
View file @
7c739eaf
package
com
.
study
.
libs
.
utils
;
package
com
.
miya
.
skin_lib
.
utils
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.ColorStateList
;
import
android.content.res.ColorStateList
;
...
@@ -10,7 +10,6 @@ import androidx.core.content.res.ResourcesCompat;
...
@@ -10,7 +10,6 @@ import androidx.core.content.res.ResourcesCompat;
public
class
SkinResources
{
public
class
SkinResources
{
//皮肤包的包名
//皮肤包的包名
private
String
skinPkgName
;
private
String
skinPkgName
;
//是否使用默认的皮肤,用原始的内容
//是否使用默认的皮肤,用原始的内容
...
...
skin-lib/src/main/java/com/
study/libs
/utils/SkinThemeUtils.java
→
skin-lib/src/main/java/com/
miya/skin_lib
/utils/SkinThemeUtils.java
View file @
7c739eaf
package
com
.
study
.
libs
.
utils
;
package
com
.
miya
.
skin_lib
.
utils
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.ColorStateList
;
import
android.content.res.Resources
;
import
android.content.res.TypedArray
;
import
android.content.res.TypedArray
;
import
android.graphics.drawable.Drawable
;
import
android.os.Build
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
androidx.core.content.res.ResourcesCompat
;
/**
/**
* 修改主题信息
* 修改主题信息
...
@@ -70,4 +76,119 @@ public class SkinThemeUtils {
...
@@ -70,4 +76,119 @@ public class SkinThemeUtils {
}
}
}
}
public
static
class
SkinResources
{
//皮肤包的包名
private
String
skinPkgName
;
//是否使用默认的皮肤,用原始的内容
private
boolean
isDefaultSkin
=
true
;
//app原始的resource
private
Resources
appResources
;
//皮肤包的resources
private
Resources
skinResources
;
private
static
volatile
SkinResources
instance
;
private
SkinResources
(
Context
context
)
{
appResources
=
context
.
getResources
();
}
public
static
void
init
(
Context
context
)
{
if
(
null
==
instance
)
{
synchronized
(
SkinResources
.
class
)
{
if
(
null
==
instance
)
{
instance
=
new
SkinResources
(
context
);
}
}
}
}
public
static
SkinResources
getInstance
()
{
return
instance
;
}
public
void
reset
()
{
skinResources
=
null
;
skinPkgName
=
null
;
isDefaultSkin
=
true
;
}
public
void
applySkin
(
Resources
resources
,
String
pkgName
)
{
skinResources
=
resources
;
skinPkgName
=
pkgName
;
//是否使用默认皮肤
isDefaultSkin
=
TextUtils
.
isEmpty
(
pkgName
)
||
resources
==
null
;
}
/**
* 1. 通过原始app中的resId获取到自己的名字(R.color.icon_up,获取到的就是icon_up)和类型
* 2. 根据名字和类型获取皮肤包中的ID
*/
public
int
getIdentifier
(
int
resId
)
{
if
(
isDefaultSkin
)
{
return
resId
;
}
//获取名称,如:icon_up
String
resName
=
appResources
.
getResourceEntryName
(
resId
);
//获取类型,如:drawable
String
resType
=
appResources
.
getResourceTypeName
(
resId
);
int
skinId
=
skinResources
.
getIdentifier
(
resName
,
resType
,
skinPkgName
);
return
skinId
;
}
/**
* 输入主app的id,获取皮肤包中的
*/
public
int
getColor
(
int
resId
)
{
if
(
isDefaultSkin
)
{
return
appResources
.
getColor
(
resId
);
}
int
skinId
=
getIdentifier
(
resId
);
if
(
skinId
==
0
)
{
return
appResources
.
getColor
(
resId
);
}
return
skinResources
.
getColor
(
skinId
);
}
public
Drawable
getDrawable
(
int
resId
)
{
if
(
isDefaultSkin
)
{
return
ResourcesCompat
.
getDrawable
(
appResources
,
resId
,
null
);
}
int
skinId
=
getIdentifier
(
resId
);
if
(
skinId
==
0
)
{
return
ResourcesCompat
.
getDrawable
(
appResources
,
resId
,
null
);
}
return
ResourcesCompat
.
getDrawable
(
skinResources
,
skinId
,
null
);
}
public
ColorStateList
getColorStateList
(
int
resId
)
{
if
(
isDefaultSkin
)
{
return
ResourcesCompat
.
getColorStateList
(
appResources
,
resId
,
null
);
}
int
skinId
=
getIdentifier
(
resId
);
if
(
skinId
==
0
)
{
return
ResourcesCompat
.
getColorStateList
(
appResources
,
resId
,
null
);
}
return
ResourcesCompat
.
getColorStateList
(
skinResources
,
skinId
,
null
);
}
/**
* 可能是Color 也可能是drawable
*
* @return
*/
public
Object
getBackground
(
int
resId
)
{
String
resourceTypeName
=
appResources
.
getResourceTypeName
(
resId
);
if
(
"color"
.
equals
(
resourceTypeName
))
{
return
getColor
(
resId
);
}
else
{
// drawable
return
getDrawable
(
resId
);
}
}
}
}
}
skin-lib/src/test/java/com/study/libs/ExampleUnitTest.kt
View file @
7c739eaf
package
com.
study.libs
package
com.
miya.skin_lib
import
org.junit.Test
import
org.junit.Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment