Skip to content

Commit e8caa24

Browse files
committed
优化低版本设置方法
1 parent 37910d4 commit e8caa24

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

shapebuilder/src/main/java/com/study/xuan/shapebuilder/shape/ShapeBuilder.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
public class ShapeBuilder{
1414
private GradientDrawable drawable;
1515
private AttrContainer container;
16+
private boolean isOperate;
1617
public ShapeBuilder() {
1718
drawable = new GradientDrawable();
1819
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
@@ -189,6 +190,7 @@ private ShapeBuilder GradientInit(GradientDrawable.Orientation orientation, int
189190
drawable.setOrientation(orientation);
190191
drawable.setColors(new int[]{startColor, centerColor, endColor});
191192
} else {
193+
isOperate = true;
192194
drawable = new GradientDrawable(orientation, new int[]{startColor, centerColor,
193195
endColor});
194196
}
@@ -273,7 +275,9 @@ public GradientDrawable build() {
273275
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
274276
return drawable;
275277
} else {
276-
operateMethod();
278+
if (isOperate) {
279+
operateMethod();
280+
}
277281
}
278282
return drawable;
279283
}

0 commit comments

Comments
 (0)