Sfoglia il codice sorgente

yu.jie 图表相关 分时图

yu jie 4 anni fa
parent
commit
90cd27b84a

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

@@ -8,6 +8,7 @@ import android.widget.TextView
 import androidx.lifecycle.Observer
 import cn.muchinfo.rma.R
 import cn.muchinfo.rma.view.base.BaseActivity
+import cn.muchinfo.rma.view.base.chart.old.timeCharts.TimeChartView
 import org.jetbrains.anko.verticalLayout
 
 /**
@@ -15,6 +16,8 @@ import org.jetbrains.anko.verticalLayout
  */
 class ChartActivity : BaseActivity<ChartViewModel>() {
 
+    lateinit var timeChartView: TimeChartView
+
     companion object {
         // 启动页面
         fun start(goodsCode: String?, outGoodsCode: String?, context: Context) {
@@ -30,8 +33,6 @@ class ChartActivity : BaseActivity<ChartViewModel>() {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_chart)
         initView()
-
-
         viewModel.initData(intent)
         viewModel.initRequest()
     }
@@ -41,10 +42,17 @@ class ChartActivity : BaseActivity<ChartViewModel>() {
             finish()
         }
 
+        timeChartView =  findViewById(R.id.time_chart_view)
+        timeChartView = TimeChartView(this)
+
         viewModel.goodsInfo.observe(this, Observer {
             findViewById<TextView>(R.id.goods_name_tv).text = it?.goodsname
             findViewById<TextView>(R.id.goods_code_tv).text = it?.goodscode
         })
+
+        viewModel.tsData.observe(this, Observer {
+            timeChartView.setData(it)
+        })
     }
 
 

+ 4 - 2
RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/ChartViewModel.kt

@@ -4,6 +4,7 @@ import android.content.Intent
 import androidx.lifecycle.MutableLiveData
 import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
+import cn.muchinfo.rma.global.data.chart.ChartTSData
 import cn.muchinfo.rma.view.MyApplication
 import cn.muchinfo.rma.view.base.BaseViewModel
 
@@ -11,7 +12,8 @@ class ChartViewModel : BaseViewModel(){
 
     var outGoodsCode = ""
     var goodsCode = ""
-    var goodsInfo : MutableLiveData<GoodsInfo> = MutableLiveData<GoodsInfo>()  // 当前选中的商品信息
+    var goodsInfo : MutableLiveData<GoodsInfo> = MutableLiveData()  // 当前选中的商品信息
+    var tsData : MutableLiveData<ChartTSData> = MutableLiveData()
 
     fun initData(intent: Intent){
         outGoodsCode = intent.getStringExtra("outGoodsCode").toString()
@@ -30,7 +32,7 @@ class ChartViewModel : BaseViewModel(){
         }
         MyApplication.getInstance()?.chartManager?.queryTsData(params = params) { isSuccess, respData, _ ->
             if (isSuccess) {
-
+                tsData.postValue(respData)
             }
         }
     }

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

@@ -75,7 +75,7 @@ public class TimeChartView extends FrameLayout {
     /**
      * 设置分时图数据
      */
-    private void setData(ChartTSData timeChartData){
+    public void setData(ChartTSData timeChartData){
         this.timeChartData = timeChartData;
         if(timeChartData == null || timeChartData.getHistoryDatas() == null) return; // 没有数据
         // 这是需要画的线

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

@@ -345,8 +345,8 @@
         android:paddingTop="2dip"
         android:layout_below="@+id/mtp_chart_head"/>
 
-    <FrameLayout
-        android:id="@+id/mtp_chart_container"
+    <cn.muchinfo.rma.view.base.chart.old.timeCharts.TimeChartView
+        android:id="@+id/time_chart_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_below="@+id/chart_title"/>