Skip to content

Commit 397bd47

Browse files
committed
update to 1.5.7
1 parent 99a8655 commit 397bd47

File tree

7 files changed

+53
-18
lines changed

7 files changed

+53
-18
lines changed

README-EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ A framework for directly generating shape through Tags, no need to write shape.x
77
Add this to your app's build.gradle:
88

99
implementation "com.android.support:appcompat-v7:$supportVersion"
10-
implementation 'com.noober.background:core:1.5.6'
10+
implementation 'com.noober.background:core:1.5.7'
1111

1212
if use androidx:
1313

1414
implementation "androidx.appcompat:appcompat:$supportVersion"
15-
implementation 'com.noober.background:core:1.5.6'
15+
implementation 'com.noober.background:core:1.5.7'
1616

1717

1818
## Example effect

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ A framework for directly generating shape through Tags, no need to write shape.x
1010
依赖方式:
1111

1212
implementation "com.android.support:appcompat-v7:$supportVersion"
13-
implementation 'com.noober.background:core:1.5.6'
13+
implementation 'com.noober.background:core:1.5.7'
1414

1515
如果项目使用了androidx:
1616

1717
implementation "androidx.appcompat:appcompat:$supportVersion"
18-
implementation 'com.noober.background:core:1.5.6'
18+
implementation 'com.noober.background:core:1.5.7'
1919

2020

2121
## 使用文档

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.5.6'
40+
implementation 'com.noober.background:core:1.5.7'
4141
// implementation project(':library')
4242
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4343
}

app/src/main/res/layout/activity_main.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
tools:context=".MainActivity"
1414
tools:ignore="MissingPrefix">
1515

16-
1716
<com.noober.background.view.BLTextView
1817
android:layout_width="wrap_content"
1918
android:layout_height="36dp"
@@ -32,6 +31,10 @@
3231
android:layout_width="wrap_content"
3332
android:layout_height="36dp"
3433
android:layout_marginTop="5dp"
34+
app:bl_padding_left= "15dp"
35+
app:bl_padding_top= "15dp"
36+
app:bl_padding_bottom= "5dp"
37+
app:bl_padding_right= "5dp"
3538
android:gravity="center"
3639
android:text="虚线圆角边框以及填充"
3740
android:textColor="#8c6822"
@@ -494,10 +497,10 @@
494497

495498
</FrameLayout>
496499

497-
<!--<fragment-->
498-
<!--android:id="@+id/fragmentTest"-->
499-
<!--android:name="com.noober.backgroudlibrary.BlankFragment"-->
500-
<!--android:layout_width="match_parent"-->
501-
<!--android:layout_height="match_parent" />-->
500+
<!-- <fragment-->
501+
<!-- android:id="@+id/fragmentTest"-->
502+
<!-- android:name="com.noober.backgroudlibrary.BlankFragment"-->
503+
<!-- android:layout_width="match_parent"-->
504+
<!-- android:layout_height="match_parent" />-->
502505
</LinearLayout>
503506
</android.support.v4.widget.NestedScrollView>

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.5.6'
39+
publishVersion = '1.5.7'
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: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ public static class Builder {
131131

132132
private boolean hasSelectDrawable = false;
133133

134+
private GradientDrawable baseGradientDrawable = null;
135+
private StateListDrawable baseStateListDrawable = null;
136+
134137
public Builder setShape(Shape shape) {
135138
this.shape = shape;
136139
return this;
@@ -481,6 +484,17 @@ public Builder setUnFocusedTextColor(int unFocusedTextColor) {
481484
return this;
482485
}
483486

487+
public Builder setBaseGradientDrawable(GradientDrawable baseGradientDrawable) {
488+
this.baseGradientDrawable = baseGradientDrawable;
489+
return this;
490+
}
491+
492+
public Builder setBaseStateListDrawable(StateListDrawable baseStateListDrawable) {
493+
this.baseStateListDrawable = baseStateListDrawable;
494+
return this;
495+
}
496+
497+
484498
public Drawable build() {
485499
GradientDrawable drawable = null;
486500
StateListDrawable stateListDrawable = null;
@@ -581,7 +595,7 @@ private ColorStateList getColorStateList() {
581595
}
582596

583597
private StateListDrawable getStateListDrawable() {
584-
StateListDrawable stateListDrawable = null;
598+
StateListDrawable stateListDrawable = baseStateListDrawable;
585599
if (checkableDrawable != null) {
586600
stateListDrawable = getStateListDrawable(stateListDrawable);
587601
stateListDrawable.addState(new int[]{android.R.attr.state_checkable}, checkableDrawable);
@@ -651,7 +665,10 @@ private StateListDrawable getStateListDrawable() {
651665

652666
@NonNull
653667
private GradientDrawable getGradientDrawable() {
654-
GradientDrawable drawable = new GradientDrawable();
668+
GradientDrawable drawable = baseGradientDrawable;
669+
if (drawable == null) {
670+
drawable = new GradientDrawable();
671+
}
655672
drawable.setShape(shape.value);
656673

657674
if (cornersRadius != null) {

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public static class Builder {
132132

133133
private boolean hasSelectDrawable = false;
134134

135+
private GradientDrawable baseGradientDrawable = null;
136+
private StateListDrawable baseStateListDrawable = null;
137+
135138
public Builder setShape(Shape shape) {
136139
this.shape = shape;
137140
return this;
@@ -482,6 +485,17 @@ public Builder setUnFocusedTextColor(int unFocusedTextColor) {
482485
return this;
483486
}
484487

488+
public Builder setBaseGradientDrawable(GradientDrawable baseGradientDrawable) {
489+
this.baseGradientDrawable = baseGradientDrawable;
490+
return this;
491+
}
492+
493+
public Builder setBaseStateListDrawable(StateListDrawable baseStateListDrawable) {
494+
this.baseStateListDrawable = baseStateListDrawable;
495+
return this;
496+
}
497+
498+
485499
public Drawable build() {
486500
GradientDrawable drawable = null;
487501
StateListDrawable stateListDrawable = null;
@@ -582,7 +596,7 @@ private ColorStateList getColorStateList() {
582596
}
583597

584598
private StateListDrawable getStateListDrawable() {
585-
StateListDrawable stateListDrawable = null;
599+
StateListDrawable stateListDrawable = baseStateListDrawable;
586600
if (checkableDrawable != null) {
587601
stateListDrawable = getStateListDrawable(stateListDrawable);
588602
stateListDrawable.addState(new int[]{android.R.attr.state_checkable}, checkableDrawable);
@@ -652,7 +666,10 @@ private StateListDrawable getStateListDrawable() {
652666

653667
@NonNull
654668
private GradientDrawable getGradientDrawable() {
655-
GradientDrawable drawable = new GradientDrawable();
669+
GradientDrawable drawable = baseGradientDrawable;
670+
if (drawable == null) {
671+
drawable = new GradientDrawable();
672+
}
656673
drawable.setShape(shape.value);
657674

658675
if (cornersRadius != null) {
@@ -735,7 +752,6 @@ private GradientDrawable getGradientDrawable() {
735752
drawable.setGradientType(gradient.value);
736753
drawable.setUseLevel(useLevel);
737754
if (!padding.isEmpty()) {
738-
739755
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
740756
drawable.setPadding(padding.left, padding.top, padding.right, padding.bottom);
741757
} else {
@@ -749,7 +765,6 @@ private GradientDrawable getGradientDrawable() {
749765
e.printStackTrace();
750766
}
751767
}
752-
753768
}
754769
if (sizeWidth != null && sizeHeight != null) {
755770
drawable.setSize(sizeWidth.intValue(), sizeHeight.intValue());

0 commit comments

Comments
 (0)