Skip to content

Commit 4ebfb1e

Browse files
committed
see 04/04 log
1 parent 197f80f commit 4ebfb1e

File tree

8 files changed

+115
-40
lines changed

8 files changed

+115
-40
lines changed

.github/workflows/android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
with:
1515
java-version: 1.8
1616
- name: Build with Gradle
17-
run: ./gradlew aR -x :lib:lib_utilcode:verifyReleaseResources
17+
run: ./gradlew aR

feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/CoreUtilActivity.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class CoreUtilActivity : CommonActivity() {
6767

6868
override fun bindItems(): MutableList<CommonItem<*>> {
6969
return CollectionUtils.newArrayList(
70+
CommonItemClick(R.string.demo_shadow, true) {
71+
ShadowActivity.start(this)
72+
},
7073
CommonItemClick(R.string.demo_activity, true) {
7174
ActivityActivity.start(this)
7275
},
@@ -160,9 +163,7 @@ class CoreUtilActivity : CommonActivity() {
160163
CommonItemClick(R.string.demo_sdcard, true) {
161164
SDCardActivity.start(this)
162165
},
163-
CommonItemClick(R.string.demo_shadow, true) {
164-
ShadowActivity.start(this)
165-
},
166+
166167
CommonItemClick(R.string.demo_snackbar, true) {
167168
SnackbarActivity.start(this)
168169
},

feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/shadow/ShadowActivity.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ class ShadowActivity : CommonActivity() {
3939

4040
override fun initView(savedInstanceState: Bundle?, contentView: View?) {
4141
super.initView(savedInstanceState, contentView)
42-
ShadowUtils.apply(shadowRectView, Config().setShadowColor(0x700000FF, 0x7000FF00))
43-
ShadowUtils.apply(shadowRoundRectView, Config().setShadowColor(0x700000FF, 0x7000FF00).setShadowRadius(
42+
ShadowUtils.apply(shadowRectView, Config().setShadowColor(0x44000000, 0x55000000))
43+
ShadowUtils.apply(shadowRoundRectView, Config().setShadowColor(0x44000000, 0x55000000).setShadowRadius(
4444
SizeUtils.dp2px(16f).toFloat()))
45-
ShadowUtils.apply(shadowCircleView, Config().setCircle().setShadowColor(0x700000FF, 0x7000FF00))
45+
ShadowUtils.apply(shadowCircleView, Config().setCircle().setShadowColor(0x44000000, 0x55000000))
46+
47+
ShadowUtils.apply(shadowRectView1, Config().setShadowColor(0x44000000, 0x55000000))
48+
ShadowUtils.apply(shadowRoundRectView1, Config().setShadowColor(0x44000000, 0x55000000).setShadowRadius(
49+
SizeUtils.dp2px(16f).toFloat()))
50+
ShadowUtils.apply(shadowCircleView1, Config().setCircle().setShadowColor(0x44000000, 0x55000000))
4651
}
4752
}

feature/utilcode/pkg/src/main/res/drawable/shadow_circle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<shape xmlns:android="http://schemas.android.com/apk/res/android"
33
android:shape="oval">
44

5-
<solid android:color="@color/colorAccent" />
5+
<solid android:color="#80FF73A3" />
66

77
</shape>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<shape xmlns:android="http://schemas.android.com/apk/res/android">
33

4-
<solid android:color="@color/colorPrimary" />
4+
<solid android:color="#8034A48E" />
55
<corners android:radius="@dimen/radius_16" />
66

77
</shape>

feature/utilcode/pkg/src/main/res/layout/shadow_activity.xml

Lines changed: 88 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,104 +6,172 @@
66
android:orientation="vertical"
77
android:padding="16dp">
88

9-
<View
10-
android:layout_width="match_parent"
11-
android:layout_height="32dp" />
12-
139
<View
1410
android:layout_width="match_parent"
1511
android:layout_height="1px"
12+
android:layout_marginTop="32dp"
1613
android:background="@drawable/common_item_divider" />
1714

1815
<LinearLayout
1916
android:layout_width="match_parent"
2017
android:layout_height="wrap_content"
21-
android:gravity="center_horizontal">
18+
android:gravity="center"
19+
android:orientation="horizontal">
2220

2321
<View
2422
android:layout_width="80dp"
2523
android:layout_height="80dp"
26-
android:background="@color/colorAccent"
24+
android:layout_gravity="center"
25+
android:background="#80FF73A3"
2726
android:clickable="true" />
2827

2928
<View
3029
android:id="@+id/shadowRectView"
3130
android:layout_width="80dp"
3231
android:layout_height="80dp"
33-
android:layout_marginLeft="32dp"
34-
android:background="@color/colorAccent"
32+
android:layout_gravity="center"
33+
android:layout_marginLeft="16dp"
34+
android:background="#80FF73A3"
3535
android:clickable="true" />
3636

37+
<FrameLayout
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content"
40+
android:layout_marginLeft="16dp">
41+
42+
43+
<View
44+
android:layout_width="80dp"
45+
android:layout_height="80dp"
46+
android:layout_gravity="center"
47+
android:background="#80FF73A3"
48+
android:clickable="true" />
49+
50+
<View
51+
android:id="@+id/shadowRectView1"
52+
android:layout_width="80dp"
53+
android:layout_height="80dp"
54+
android:layout_gravity="center"
55+
android:background="#80FF73A3"
56+
android:clickable="true" />
57+
58+
</FrameLayout>
59+
3760
</LinearLayout>
3861

3962
<View
4063
android:layout_width="match_parent"
4164
android:layout_height="1px"
4265
android:background="@drawable/common_item_divider" />
4366

44-
<View
45-
android:layout_width="match_parent"
46-
android:layout_height="32dp" />
47-
4867
<View
4968
android:layout_width="match_parent"
5069
android:layout_height="1px"
70+
android:layout_marginTop="32dp"
5171
android:background="@drawable/common_item_divider" />
5272

5373
<LinearLayout
5474
android:layout_width="match_parent"
5575
android:layout_height="wrap_content"
56-
android:gravity="center_horizontal">
76+
android:gravity="center"
77+
android:orientation="horizontal">
5778

5879
<View
5980
android:layout_width="80dp"
6081
android:layout_height="80dp"
82+
android:layout_gravity="center"
6183
android:background="@drawable/shadow_round_rect"
6284
android:clickable="true" />
6385

6486
<View
6587
android:id="@+id/shadowRoundRectView"
6688
android:layout_width="80dp"
6789
android:layout_height="80dp"
68-
android:layout_marginLeft="32dp"
90+
android:layout_gravity="center"
91+
android:layout_marginLeft="16dp"
6992
android:background="@drawable/shadow_round_rect"
7093
android:clickable="true" />
7194

95+
<FrameLayout
96+
android:layout_width="wrap_content"
97+
android:layout_height="wrap_content"
98+
android:layout_marginLeft="16dp">
99+
100+
<View
101+
android:layout_width="80dp"
102+
android:layout_height="80dp"
103+
android:layout_gravity="center"
104+
android:background="@drawable/shadow_round_rect"
105+
android:clickable="true" />
106+
107+
<View
108+
android:id="@+id/shadowRoundRectView1"
109+
android:layout_width="80dp"
110+
android:layout_height="80dp"
111+
android:layout_gravity="center"
112+
android:background="@drawable/shadow_round_rect"
113+
android:clickable="true" />
114+
115+
</FrameLayout>
116+
72117
</LinearLayout>
73118

119+
74120
<View
75121
android:layout_width="match_parent"
76122
android:layout_height="1px"
77123
android:background="@drawable/common_item_divider" />
78124

79-
<View
80-
android:layout_width="match_parent"
81-
android:layout_height="32dp" />
82-
83125
<View
84126
android:layout_width="match_parent"
85127
android:layout_height="1px"
128+
android:layout_marginTop="32dp"
86129
android:background="@drawable/common_item_divider" />
87130

88131
<LinearLayout
89132
android:layout_width="match_parent"
90133
android:layout_height="wrap_content"
91-
android:gravity="center_horizontal">
134+
android:gravity="center"
135+
android:orientation="horizontal">
92136

93137
<View
94138
android:layout_width="80dp"
95139
android:layout_height="80dp"
140+
android:layout_gravity="center"
96141
android:background="@drawable/shadow_circle"
97142
android:clickable="true" />
98143

99144
<View
100145
android:id="@+id/shadowCircleView"
101146
android:layout_width="80dp"
102147
android:layout_height="80dp"
103-
android:layout_marginLeft="32dp"
148+
android:layout_gravity="center"
149+
android:layout_marginLeft="16dp"
104150
android:background="@drawable/shadow_circle"
105151
android:clickable="true" />
106152

153+
<FrameLayout
154+
android:layout_width="wrap_content"
155+
android:layout_height="wrap_content"
156+
android:layout_marginLeft="16dp">
157+
158+
<View
159+
android:layout_width="80dp"
160+
android:layout_height="80dp"
161+
android:layout_gravity="center"
162+
android:background="@drawable/shadow_circle"
163+
android:clickable="true" />
164+
165+
<View
166+
android:id="@+id/shadowCircleView1"
167+
android:layout_width="80dp"
168+
android:layout_height="80dp"
169+
android:layout_gravity="center"
170+
android:background="@drawable/shadow_circle"
171+
android:clickable="true" />
172+
173+
</FrameLayout>
174+
107175
</LinearLayout>
108176

109177
<View

lib/utilcode/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ publish {
4848
version = Config.depConfig.lib_utilcode.version
4949
website = "https://github.com/Blankj/AndroidUtilCode"
5050
}
51+
52+
afterEvaluate {
53+
verifyReleaseResources.enabled(false)
54+
}

lib/utilcode/src/main/java/com/blankj/utilcode/util/ShadowUtils.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static void apply(View view, Config builder) {
5656

5757
public static class Config {
5858

59-
private static final int SHADOW_COLOR_DEFAULT = 0xb0_000000;
59+
private static final int SHADOW_COLOR_DEFAULT = 0x44000000;
6060
private static final int SHADOW_SIZE = UtilsBridge.dp2px(8);
6161

6262
private float mShadowRadius = -1;
@@ -215,7 +215,7 @@ public ShadowDrawable(Drawable content, float radius,
215215
float shadowSize, float maxShadowSize, int shadowColor, boolean isCircle) {
216216
super(content);
217217
mShadowStartColor = shadowColor;
218-
mShadowEndColor = 0;
218+
mShadowEndColor = mShadowStartColor & 0x00ffffff;
219219
this.isCircle = isCircle;
220220
if (isCircle) {
221221
mShadowMultiplier = 1;
@@ -438,18 +438,17 @@ private void buildShadowCorners() {
438438
mCornerShadowPath.rLineTo(-mShadowSize, 0);
439439
// outer arc
440440
mCornerShadowPath.arcTo(outerBounds, 180f, 180f, false);
441-
mCornerShadowPath.arcTo(outerBounds, 360f, 180f, false);
441+
mCornerShadowPath.arcTo(outerBounds, 0f, 180f, false);
442442
// inner arc
443-
mCornerShadowPath.arcTo(innerBounds, 540f, -180f, false);
444-
mCornerShadowPath.arcTo(innerBounds, 360f, -180f, false);
443+
mCornerShadowPath.arcTo(innerBounds, 180f, 180f, false);
444+
mCornerShadowPath.arcTo(innerBounds, 0f, 180f, false);
445445
mCornerShadowPath.close();
446446

447447
float shadowRadius = -outerBounds.top;
448448
if (shadowRadius > 0f) {
449449
float startRatio = size / shadowRadius;
450450
mCornerShadowPaint.setShader(new RadialGradient(0, 0, shadowRadius,
451-
new int[]{0, mShadowStartColor, mShadowEndColor},
452-
new float[]{0f, startRatio, 1f},
451+
new int[]{0, mShadowStartColor, mShadowEndColor}, new float[]{0.0F, startRatio, 1.0F},
453452
Shader.TileMode.CLAMP));
454453
}
455454
return;
@@ -477,17 +476,15 @@ private void buildShadowCorners() {
477476
if (shadowRadius > 0f) {
478477
float startRatio = mCornerRadius / shadowRadius;
479478
mCornerShadowPaint.setShader(new RadialGradient(0, 0, shadowRadius,
480-
new int[]{0, mShadowStartColor, mShadowEndColor},
481-
new float[]{0f, startRatio, 1f},
479+
new int[]{0, mShadowStartColor, mShadowEndColor}, new float[]{0F, startRatio, 1F},
482480
Shader.TileMode.CLAMP));
483481
}
484482

485483
// we offset the content shadowSize/2 pixels up to make it more realistic.
486484
// this is why edge shadow shader has some extra space
487485
// When drawing bottom edge shadow, we use that extra space.
488486
mEdgeShadowPaint.setShader(new LinearGradient(0, innerBounds.top, 0, outerBounds.top,
489-
new int[]{mShadowStartColor, mShadowEndColor},
490-
new float[]{0f, 1f}, Shader.TileMode.CLAMP));
487+
mShadowStartColor, mShadowEndColor, Shader.TileMode.CLAMP));
491488
mEdgeShadowPaint.setAntiAlias(false);
492489
}
493490

0 commit comments

Comments
 (0)