|
|
@@ -45,7 +45,9 @@ public class KChartView extends FrameLayout implements ITouchEventResponse {
|
|
|
String state = ChartConstant.BIAS;
|
|
|
TextView upText;
|
|
|
|
|
|
+ String goodsCode = "";
|
|
|
List<HistoryDatas> history = new ArrayList<>();
|
|
|
+ List<HistoryDatas> saveHistory = new ArrayList<>();
|
|
|
public KChartView(@NonNull Context context) {
|
|
|
super(context);
|
|
|
this.context = context;
|
|
|
@@ -159,8 +161,11 @@ public class KChartView extends FrameLayout implements ITouchEventResponse {
|
|
|
*/
|
|
|
public void setDates(String goodsCode, List<HistoryDatas> history){
|
|
|
if(history == null || history.isEmpty()) return; // 没有数据
|
|
|
+ this.goodsCode = goodsCode;
|
|
|
this.history.clear();
|
|
|
this.history.addAll(history);
|
|
|
+ this.saveHistory.clear();
|
|
|
+ this.saveHistory.addAll(this.history);
|
|
|
// 这是需要画的线
|
|
|
List<LineEntity> lines = new ArrayList<>();
|
|
|
LineEntity M5Line = new LineEntity();;
|
|
|
@@ -365,8 +370,49 @@ public class KChartView extends FrameLayout implements ITouchEventResponse {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新主数据
|
|
|
+ *
|
|
|
+ * @param lastDate 最新数据
|
|
|
+ */
|
|
|
+ public void refreshDate(HistoryDatas lastDate) {
|
|
|
+ if (this.saveHistory == null || this.saveHistory.size() == 0 || goodsCode.equals("")) return; // 没有数据
|
|
|
+ HistoryDatas lastData = this.saveHistory.get(this.saveHistory.size() - 1);
|
|
|
+ HistoryDatas nowData = lastDate;
|
|
|
+ if(new ChartDataAdapter().checkSameMin(nowData.getTime().replace("T"," ").replace("+08:00",""), lastData.getTime().replace("T"," ").replace("+08:00",""))){ // 不是同一分钟 则重新请求
|
|
|
+ this.saveHistory.add(lastDate);
|
|
|
+ }else{
|
|
|
+ if(kChartListener != null) kChartListener.onKRepairFail();
|
|
|
+ }
|
|
|
+ setDates(goodsCode, this.saveHistory);
|
|
|
+// if(timeChartData.getHistoryDatas().get(timeChartData.getHistoryDatas().size() - 1).getTime())
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 这个方法只负责最新价的标题显示以及绘制颜色值
|
|
|
+ *
|
|
|
+ * @param lastPrice 最新价q
|
|
|
+ * @param priceColor 最新价颜色
|
|
|
+ */
|
|
|
+ public void setLastPrice(String lastPrice, int priceColor) {
|
|
|
+ candle_chart.setTasLastPrice(lastPrice);
|
|
|
+ candle_chart.setNewPriceColor(priceColor);
|
|
|
+ candle_chart.invalidate();
|
|
|
+ }
|
|
|
+
|
|
|
private boolean isTimeCharts = false;
|
|
|
public void setIsTimeChart(boolean isTimeChart){
|
|
|
this.isTimeCharts = isTimeChart;
|
|
|
}
|
|
|
+
|
|
|
+ public interface KChartListener {
|
|
|
+ void onKRepairFail();
|
|
|
+ }
|
|
|
+
|
|
|
+ private KChartListener kChartListener;
|
|
|
+
|
|
|
+ public void setKChartListener(KChartListener timeChartListener) {
|
|
|
+ this.kChartListener = kChartListener;
|
|
|
+ }
|
|
|
+
|
|
|
}
|