Skip to content

Commit 95a3d73

Browse files
committed
update to 1.6.5
1 parent 9849d83 commit 95a3d73

6 files changed

Lines changed: 67 additions & 35 deletions

File tree

.idea/gradle.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737
testImplementation 'junit:junit:4.12'
3838
androidTestImplementation 'com.android.support.test:runner:1.0.2'
3939
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
40-
implementation 'com.noober.background:core:1.6.4'
40+
implementation 'com.noober.background:core:1.6.5'
4141
// implementation project(':library')
4242
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4343
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ext {
3636
userOrg = 'noober'
3737
groupId = 'com.noober.background'
3838
uploadName = 'LibraryForBackground'
39-
publishVersion = '1.6.4'
39+
publishVersion = '1.6.5'
4040
desc = "A framework for directly generating shape through Tags, no need to write shape.xml again(通过标签直接生成shape,无需再写shape.xml)"
4141
website = 'https://github.com/JavaNoober/BackgroundLibrary'
4242
// gradlew clean build bintrayUpload -PbintrayUser=xiaoqiandroid -PbintrayKey=xxxxxxxxxxxxxxxx -PdryRun=false

library/src/main/java/com/noober/background/drawable/DrawableCreator.java

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -916,24 +916,39 @@ StateListDrawable getStateListDrawable(StateListDrawable stateListDrawable) {
916916
public static void setDrawable(Drawable drawable, View view, DrawablePosition drawablePosition) {
917917

918918
if (view instanceof TextView) {
919-
if (drawablePosition == DrawablePosition.Left) {
920-
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
921-
((TextView) view).setCompoundDrawables(drawable, null, null, null);
922-
} else if (drawablePosition == DrawablePosition.Top) {
923-
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
924-
((TextView) view).setCompoundDrawables(null, drawable, null, null);
925-
} else if (drawablePosition == DrawablePosition.Right) {
926-
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
927-
((TextView) view).setCompoundDrawables(null, null, drawable, null);
928-
} else if (drawablePosition == DrawablePosition.Bottom) {
929-
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
930-
((TextView) view).setCompoundDrawables(null, null, null, drawable);
931-
} else {
932-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
933-
view.setBackground(drawable);
919+
if(drawable != null){
920+
if (drawablePosition == DrawablePosition.Left) {
921+
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
922+
((TextView) view).setCompoundDrawables(drawable, null, null, null);
923+
} else if (drawablePosition == DrawablePosition.Top) {
924+
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
925+
((TextView) view).setCompoundDrawables(null, drawable, null, null);
926+
} else if (drawablePosition == DrawablePosition.Right) {
927+
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
928+
((TextView) view).setCompoundDrawables(null, null, drawable, null);
929+
} else if (drawablePosition == DrawablePosition.Bottom) {
930+
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
931+
((TextView) view).setCompoundDrawables(null, null, null, drawable);
934932
} else {
935-
view.setBackgroundDrawable(drawable);
933+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
934+
view.setBackground(drawable);
935+
} else {
936+
view.setBackgroundDrawable(drawable);
937+
}
938+
}
939+
}else {
940+
Drawable[] drawables = ((TextView) view).getCompoundDrawables();
941+
if (drawablePosition == DrawablePosition.Left) {
942+
drawables[0] = null;
943+
} else if (drawablePosition == DrawablePosition.Top) {
944+
drawables[1] = null;
945+
} else if (drawablePosition == DrawablePosition.Right) {
946+
drawables[2] = null;
947+
} else if (drawablePosition == DrawablePosition.Bottom) {
948+
drawables[3] = null;
949+
936950
}
951+
((TextView) view).setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3]);
937952
}
938953
} else {
939954
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {

libraryx/src/main/java/com/noober/background/drawable/DrawableCreator.java

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -916,24 +916,39 @@ StateListDrawable getStateListDrawable(StateListDrawable stateListDrawable) {
916916
public static void setDrawable(Drawable drawable, View view, DrawablePosition drawablePosition) {
917917

918918
if (view instanceof TextView) {
919-
if (drawablePosition == DrawablePosition.Left) {
920-
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
921-
((TextView) view).setCompoundDrawables(drawable, null, null, null);
922-
} else if (drawablePosition == DrawablePosition.Top) {
923-
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
924-
((TextView) view).setCompoundDrawables(null, drawable, null, null);
925-
} else if (drawablePosition == DrawablePosition.Right) {
926-
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
927-
((TextView) view).setCompoundDrawables(null, null, drawable, null);
928-
} else if (drawablePosition == DrawablePosition.Bottom) {
929-
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
930-
((TextView) view).setCompoundDrawables(null, null, null, drawable);
931-
} else {
932-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
933-
view.setBackground(drawable);
919+
if(drawable != null){
920+
if (drawablePosition == DrawablePosition.Left) {
921+
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
922+
((TextView) view).setCompoundDrawables(drawable, null, null, null);
923+
} else if (drawablePosition == DrawablePosition.Top) {
924+
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
925+
((TextView) view).setCompoundDrawables(null, drawable, null, null);
926+
} else if (drawablePosition == DrawablePosition.Right) {
927+
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
928+
((TextView) view).setCompoundDrawables(null, null, drawable, null);
929+
} else if (drawablePosition == DrawablePosition.Bottom) {
930+
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
931+
((TextView) view).setCompoundDrawables(null, null, null, drawable);
934932
} else {
935-
view.setBackgroundDrawable(drawable);
933+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
934+
view.setBackground(drawable);
935+
} else {
936+
view.setBackgroundDrawable(drawable);
937+
}
938+
}
939+
}else {
940+
Drawable[] drawables = ((TextView) view).getCompoundDrawables();
941+
if (drawablePosition == DrawablePosition.Left) {
942+
drawables[0] = null;
943+
} else if (drawablePosition == DrawablePosition.Top) {
944+
drawables[1] = null;
945+
} else if (drawablePosition == DrawablePosition.Right) {
946+
drawables[2] = null;
947+
} else if (drawablePosition == DrawablePosition.Bottom) {
948+
drawables[3] = null;
949+
936950
}
951+
((TextView) view).setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3]);
937952
}
938953
} else {
939954
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {

0 commit comments

Comments
 (0)