Skip to content

Commit

Permalink
可能的NPE;gzu-liyujiang#274 无法设置白色背景;gzu-liyujiang#268 加粗属性无效;
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Dec 5, 2021
1 parent db2375c commit 5b24f63
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public class WheelView extends View implements Runnable {
protected int defaultItemPosition;
protected int currentPosition;
protected String maxWidthText;
protected int textColor, selectedTextColor;
protected int textColor;
protected int selectedTextColor;
protected float textSize, selectedTextSize;
protected boolean selectedTextBold;
protected float indicatorSize;
Expand Down Expand Up @@ -315,6 +316,9 @@ public void setDefaultValue(Object value) {
boolean found = false;
int position = 0;
for (Object item : data) {
if (item == null) {
continue;
}
if (item.equals(value)) {
found = true;
break;
Expand Down Expand Up @@ -694,7 +698,7 @@ private void computeIndicatorRect() {
}

private void computeCurrentItemRect() {
if (!curtainEnabled && selectedTextColor == -1) {
if (!curtainEnabled && selectedTextColor == 0/* Color.TRANSPARENT */) {
return;
}
rectCurrentItem.set(rectDrawn.left, wheelCenterYCoordinate - halfItemHeight,
Expand Down Expand Up @@ -774,7 +778,7 @@ private void drawAllItem(Canvas canvas) {

private void drawItemRect(Canvas canvas, int dataPosition, boolean isCenterItem, float drawCenterYCoordinate) {
// Judges need to draw different color for current item or not
if (selectedTextColor == -1) {
if (selectedTextColor == 0/* Color.TRANSPARENT */) {
//没有设置选中项颜色,绘制所有项
canvas.save();
canvas.clipRect(rectDrawn);
Expand All @@ -786,8 +790,8 @@ private void drawItemRect(Canvas canvas, int dataPosition, boolean isCenterItem,
return;
}

if (textSize == selectedTextSize) {
//没有设置选中项的字号,绘制所有项
if (textSize == selectedTextSize && !selectedTextBold) {
//没有设置选中项的加大加粗,绘制所有项
canvas.save();
if (curvedEnabled) {
canvas.concat(matrixRotate);
Expand Down

0 comments on commit 5b24f63

Please sign in to comment.