16
16
17
17
import java .util .ArrayList ;
18
18
import java .util .List ;
19
+ import java .util .Objects ;
19
20
20
21
import ysn .com .stock .R ;
21
22
import ysn .com .stock .bean .FenShi ;
@@ -200,6 +201,13 @@ private float getY(float price) {
200
201
return getY (price , minStockPrice , maxStockPrice );
201
202
}
202
203
204
+ private void initData () {
205
+ stockPriceList .clear ();
206
+ lastClose = 0.0f ;
207
+ maxStockPrice = Float .MIN_VALUE ;
208
+ minStockPrice = Float .MAX_VALUE ;
209
+ }
210
+
203
211
private void initCurrentColor () {
204
212
if (stockPriceList .isEmpty ()) {
205
213
return ;
@@ -214,11 +222,11 @@ private void initCurrentColor() {
214
222
}
215
223
}
216
224
217
- private void initData () {
218
- stockPriceList . clear ();
219
- lastClose = 0.0f ;
220
- maxStockPrice = Float . MIN_VALUE ;
221
- minStockPrice = Float . MAX_VALUE ;
225
+ private void initPeakPrice () {
226
+ if ( Objects . equals ( maxStockPrice , minStockPrice )) {
227
+ minStockPrice = maxStockPrice / 2f ;
228
+ maxStockPrice = maxStockPrice * 3f / 2f ;
229
+ }
222
230
}
223
231
224
232
public void setNewData (FenShi fenShi ) {
@@ -232,6 +240,7 @@ public void setNewData(FenShi fenShi) {
232
240
}
233
241
lastClose = fenShi .getLastClose ();
234
242
}
243
+ initPeakPrice ();
235
244
initCurrentColor ();
236
245
invalidate ();
237
246
}
@@ -244,6 +253,7 @@ public void setNewData(ArrayList<Float> stockPriceList, Float lastClose) {
244
253
minStockPrice = Math .min (trade , minStockPrice );
245
254
}
246
255
this .lastClose = lastClose ;
256
+ initPeakPrice ();
247
257
initCurrentColor ();
248
258
invalidate ();
249
259
}
@@ -253,6 +263,7 @@ public void setNewData(ArrayList<Float> stockPriceList, Float lastClose, Float m
253
263
this .lastClose = lastClose ;
254
264
this .maxStockPrice = maxStockPrice ;
255
265
this .minStockPrice = minStockPrice ;
266
+ initPeakPrice ();
256
267
initCurrentColor ();
257
268
invalidate ();
258
269
}
0 commit comments