Skip to content

Commit

Permalink
[ *] 修复MiniFenShiView最大最小值相等是没有进行绘制的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yangsanning committed Jun 18, 2019
1 parent 7bc09ff commit d906543
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ allprojects {
//未经测试,不要随意升级支持库的版本
SUPPORT_LIBRARY_VERSION = '27.1.1'

VERSION_CODE = 10006
VERSION_NAME = "1.0.6"
VERSION_CODE = 10007
VERSION_NAME = "1.0.7"
}
}

Expand Down
21 changes: 16 additions & 5 deletions stock/src/main/java/ysn/com/stock/view/MiniFenShiView.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import ysn.com.stock.R;
import ysn.com.stock.bean.FenShi;
Expand Down Expand Up @@ -200,6 +201,13 @@ private float getY(float price) {
return getY(price, minStockPrice, maxStockPrice);
}

private void initData() {
stockPriceList.clear();
lastClose = 0.0f;
maxStockPrice = Float.MIN_VALUE;
minStockPrice = Float.MAX_VALUE;
}

private void initCurrentColor() {
if (stockPriceList.isEmpty()) {
return;
Expand All @@ -214,11 +222,11 @@ private void initCurrentColor() {
}
}

private void initData() {
stockPriceList.clear();
lastClose = 0.0f;
maxStockPrice = Float.MIN_VALUE;
minStockPrice = Float.MAX_VALUE;
private void initPeakPrice() {
if (Objects.equals(maxStockPrice, minStockPrice)) {
minStockPrice = maxStockPrice / 2f;
maxStockPrice = maxStockPrice * 3f / 2f;
}
}

public void setNewData(FenShi fenShi) {
Expand All @@ -232,6 +240,7 @@ public void setNewData(FenShi fenShi) {
}
lastClose = fenShi.getLastClose();
}
initPeakPrice();
initCurrentColor();
invalidate();
}
Expand All @@ -244,6 +253,7 @@ public void setNewData(ArrayList<Float> stockPriceList, Float lastClose) {
minStockPrice = Math.min(trade, minStockPrice);
}
this.lastClose = lastClose;
initPeakPrice();
initCurrentColor();
invalidate();
}
Expand All @@ -253,6 +263,7 @@ public void setNewData(ArrayList<Float> stockPriceList, Float lastClose, Float m
this.lastClose = lastClose;
this.maxStockPrice = maxStockPrice;
this.minStockPrice = minStockPrice;
initPeakPrice();
initCurrentColor();
invalidate();
}
Expand Down

0 comments on commit d906543

Please sign in to comment.