Sfoglia il codice sorgente

yu.jie 解决ma不显示问题

yu jie 4 anni fa
parent
commit
46b90cffcc

+ 0 - 1
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/ChartActivity.kt

@@ -77,7 +77,6 @@ class ChartActivity : BaseActivity<ChartViewModel>() , View.OnClickListener {
         progressBar = findViewById(R.id.progress_view)
         chart_title = findViewById(R.id.chart_title)
         kChartView.setUpText(chart_title)
-
         timeChartView.setTextView(chart_title)
 
         findViewById<RelativeLayout>(R.id.trade_rly).setOnClickListener(this)

+ 22 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/KChartView.java

@@ -313,6 +313,28 @@ public class KChartView extends FrameLayout  implements ITouchEventResponse {
                             if (index <= currentLength) {
                                 OHLCEntity data = new ChartDataAdapter().historyDataToOHLDate(history).get(index);
                                 StickChartTools.setOHLC(context, this.upText, data.getOpen(), data.getHigh(), data.getLow(), data.getClose());
+                                showSum(minusStickChart, index);
+
+                                try {
+                                    LineEntity MA5 = candle_chart.getLineData().get(0);
+                                    LineEntity MA10 = candle_chart.getLineData().get(1);
+                                    LineEntity MA15 = candle_chart.getLineData().get(2);
+                                    if(MA5.getLineData() != null && MA5.getLineData().size() > 0 && MA10.getLineData() != null && MA10.getLineData().size() > 0 && MA15.getLineData() != null && MA15.getLineData().size() > 0
+                                    ){
+                                        double ma5Val = MA5.getLineData().get(index);
+                                        double ma10Val = MA10.getLineData().get(index);
+                                        double ma15Val = MA15.getLineData().get(index);
+
+                                        if(upText != null){
+                                            String value = upText.getText().toString() + "\n" + StickChartTools.setCandleStickText(context, ma5Val, ma10Val, ma15Val);
+                                            upText.setText(value);
+                                        }
+                                    }
+                                } catch (Exception e) {
+                                    // TODO Auto-generated catch block
+                                    e.printStackTrace();
+                                }
+
                             }
                         } catch (Exception e) {
                             // TODO Auto-generated catch block

+ 19 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/StickChartTools.java

@@ -3,6 +3,7 @@ package cn.muchinfo.rma.view.base.chart.old.timeCharts;
 import android.content.Context;
 import android.graphics.Color;
 import android.text.Html;
+import android.text.Spanned;
 import android.view.View;
 import android.widget.TextView;
 
@@ -735,6 +736,24 @@ public class StickChartTools {
         candleStickTV.setText(Html.fromHtml(strHtml));
     }
 
+    public static Spanned setCandleStickText(Context context, double ma5Val, double ma10Val, double ma15Val) {
+        String source = "";
+        source += "<font color='" + context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_ma5) + "'>MA5:%s </font>";
+        source += "<font color='" + context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_ma10) + "'>MA10:%s </font>";
+        source += "<font color='" + context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_ma15) + "'>MA15:%s</font>";
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setGroupingUsed(false);
+        nf.setMaximumFractionDigits(2);
+        nf.setMinimumFractionDigits(2);
+        String ma5 = nf.format(ma5Val);
+        String ma10 = nf.format(ma10Val);
+        String ma15 = nf.format(ma15Val);
+        String strHtml = String.format(source, ma5, ma10, ma15);
+        return Html.fromHtml(strHtml);
+    }
+
+
+
     public static void setOHLC(Context context, TextView textView, double opened, double highest, double lowest, double closed) {
         int decimalPlace = 2;
         textView.setText("开:"

+ 1 - 1
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/TimeChartView.java

@@ -149,7 +149,7 @@ public class TimeChartView extends FrameLayout implements ITouchEventResponse {
     /**
      * 这个方法只负责最新价的标题显示以及绘制颜色值
      *
-     * @param lastPrice  最新价
+     * @param lastPrice  最新价q
      * @param priceColor 最新价颜色
      */
     public void setLastPrice(String lastPrice, int priceColor) {

+ 6 - 7
RMA/app/src/main/res/layout/activity_chart.xml

@@ -152,13 +152,12 @@
         android:layout_below="@+id/chart_title"
         />
 
-    <cn.muchinfo.rma.view.base.chart.old.timeCharts.KChartView
-        android:id="@+id/k_chart_view"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_below="@+id/chart_title"
-        android:visibility="invisible"
-        />
+        <cn.muchinfo.rma.view.base.chart.old.timeCharts.KChartView
+            android:id="@+id/k_chart_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_below="@+id/chart_title"
+            android:visibility="invisible" />
 
     <ProgressBar
         android:id="@+id/progress_view"