소스 검색

yu.jie 图表相关提交

xkwg 4 년 전
부모
커밋
17141f9012
20개의 변경된 파일653개의 추가작업 그리고 292개의 파일을 삭제
  1. 1 1
      RMA/app/build.gradle
  2. 3 3
      RMA/app/src/main/java/cn/muchinfo/rma/business/chart/ChartManager.kt
  3. 5 0
      RMA/app/src/main/java/cn/muchinfo/rma/global/StringUtils.kt
  4. 2 0
      RMA/app/src/main/java/cn/muchinfo/rma/global/data/QuoteDayData.kt
  5. 1 0
      RMA/app/src/main/java/cn/muchinfo/rma/global/data/account/LoginQueryData.kt
  6. 48 0
      RMA/app/src/main/java/cn/muchinfo/rma/global/data/account/loginQeruy/Markets.kt
  7. 53 5
      RMA/app/src/main/java/cn/muchinfo/rma/global/data/chart/ChartTSData.kt
  8. 2 2
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/app/Constant.kt
  9. 102 5
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/ChartActivity.kt
  10. 52 0
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/ChartDataAdapter.kt
  11. 108 7
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/ChartViewModel.kt
  12. 17 2
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/KChartView.java
  13. 71 8
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/chart/old/timeCharts/TimeChartView.java
  14. 15 3
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/markets/MarketBaseModel.kt
  15. 113 230
      RMA/app/src/main/res/layout/activity_chart.xml
  16. 49 19
      RMA/app/src/main/res/layout/chart_info_layout.xml
  17. 2 3
      RMA/app/src/main/res/layout/time_chart_view.xml
  18. 1 1
      RMA/chart/build.gradle
  19. 3 3
      RMA/chart/src/main/java/com/desfate/chart/GridChart.java
  20. 5 0
      RMA/chart/src/main/res/values/colors.xml

+ 1 - 1
RMA/app/build.gradle

@@ -17,7 +17,7 @@ android {
 
     defaultConfig {
         applicationId "cn.muchinfo.rma"
-        minSdkVersion 23
+        minSdkVersion 24
         targetSdkVersion 30
         versionCode 50001
         versionName "5.0.01"

+ 3 - 3
RMA/app/src/main/java/cn/muchinfo/rma/business/chart/ChartManager.kt

@@ -73,15 +73,15 @@ class ChartManager {
      */
     fun queryHistoryDatas(
         params: Map<String, String>,
-        responseBack: (isSuccess: Boolean, respData: HistoryDatas?, error: Error?) -> Unit
+        responseBack: (isSuccess: Boolean, respData: List<HistoryDatas>?, error: Error?) -> Unit
         ) {
             MyOkHttpUtils().query(
                 URL = SPUtils.getInstance()
                     .getString(Constant.goCommonSearchUrl) + "/Quote/QueryHistoryDatas",
                 params = params,
                 type = "1",
-                callback = object : ResponseCallback<BaseResult<HistoryDatas>>() {
-                    override fun onResponse(response: BaseResult<HistoryDatas>?, id: Int) {
+                callback = object : ResponseCallback<BaseResult<List<HistoryDatas>>>() {
+                    override fun onResponse(response: BaseResult<List<HistoryDatas>>?, id: Int) {
                         responseBack(true, response?.data, null)
                     }
 

+ 5 - 0
RMA/app/src/main/java/cn/muchinfo/rma/global/StringUtils.kt

@@ -75,6 +75,11 @@ fun String.toShowTime(format : String = "yyyy-MM-dd HH:mm:ss") : String{
     return timeString
 }
 
+fun String.toTimeData(format: String = "yyyy-MM-dd HH:mm:ss"): Date{
+    val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss+08:00", Locale.CHINA)
+    return sdf.parse(this)!!
+}
+
 /**
  * 历史委托单的状态
  */

+ 2 - 0
RMA/app/src/main/java/cn/muchinfo/rma/global/data/QuoteDayData.kt

@@ -1,5 +1,7 @@
 package cn.muchinfo.rma.global.data
 
+import cn.muchinfo.rma.global.data.chart.HistoryDatas
+
 /**
  * 盘面信息
  */

+ 1 - 0
RMA/app/src/main/java/cn/muchinfo/rma/global/data/account/LoginQueryData.kt

@@ -10,6 +10,7 @@ data class LoginQueryData(
     val loginAccount: LoginAccount? = null, // 登录账号
     val userAccount : UserAccount? = null, // 用户账号
     val userInfo: UserInfo? = null, // 用户信息
+    val market: List<Markets>? = arrayListOf(), // 市场信息
     val goodsgroups: List<GoodsGroups>? = arrayListOf(), // 商品组
     val externalExchanges: List<ExternalExchanges>? = arrayListOf(), // 外部交易所
     val systemParams: List<SystemParams>? = arrayListOf() // 系统参数

+ 48 - 0
RMA/app/src/main/java/cn/muchinfo/rma/global/data/account/loginQeruy/Markets.kt

@@ -0,0 +1,48 @@
+package cn.muchinfo.rma.global.data.account.loginQeruy
+
+data class Markets(
+    var auctionwrtype: Int = 0,  //竞拍仓单类型 - 1:无仓单 2:有仓单 3;有无仓单均可
+    var canacceptquote: Int = 0, // 确认行权是否接收行情 - 0:不接受 1:接受 [可确认权的挂牌期权市场可配置]
+    var cangoodsexercise: Int = 0, // [期权]是否可现货行权- 0:否 1:是
+    var cangoodsexercisetype: Int = 0, // 可现货行权期权类型 - 1:认购 2认沽 3:认购认沽 [CanGoodsExercise = 1时可设置]
+    var canmanualquotestrike: Int = 0,//是否可手动报行权价- 0:否 1:是 [期权]
+    var canmutistage: Int = 0, //是否可多段运行 – 0:不可 1:可 [挂牌期权]
+    var canpreexercise: Int = 0,//[期权]是否可预申报- 0:否 1:是
+    var clearinterval: Int = 0,//待开市间隔(交易市场开盘前多久发市场待开市信号(单位分钟))
+    var contracttmp: String = "",//合同模板[荷兰式][竞价式][仓单贸易]
+    var exchareaid: Int = 0,//所属交易所,可以没有
+    var goodstype: Int = 0,//商品类型 - 1:交易商品 2:仓单商品
+    var hasrebate: Int = 0,//是否返利[竞价式] 0:不返,1:返利 – 根据系统参数088显示或隐藏
+    var hastradecredit: Int = 0,//是否交易授信[做市收益权] - 0:不授信 1:授信
+    var haswr: Int = 0,//[竞拍]是否需要仓单 - 0:不需要 1:需要-作废
+    var isdeductmargin: Int = 0,//竞拍违约是否扣除保证金[竞拍-降价式] - 0:不扣 1:扣除
+    var isrecordsource: Int = 0,//是否记录成交源 - 0:不记录 1:记录 [所有权]
+    var isreleasemargin: Int = 0,//成交参与保证金是否释放[竞价式] - 0:不释放 1释放
+    var marginformula: Int = 0,//持仓保证金公式 - 1:双边收 2:净头寸收 3:大小边差异收 4:大边收 5:卖持仓收(仅期权)
+    var marginformula2: Int = 0,//持仓保证金公式(仅受托竞价) - 1:双边收 2:净头寸收 3:大小边差异收 4:大边收 5:卖持仓收(仅期权)
+    var marketid: Int = 0,//市场ID正常5位,前三位固定:两位表示交易模式, 一位表示交易属性(1:收益权,2:所有权) 其它特殊市场:0-系统 1-交割服务 2-账户服务3-履约服务 4-仓单服务 5-积分服务 6-银行服务
+    var marketname: String = "",//市场名称
+    var marketserviceid: Int = 0,//市场服务ID
+    var marketstatus: Int = 0,//生效状态(ValidStatus枚举): 1:待生效 2:正常 3:注销
+    var markettype: Int = 0,//市场类型- 1:非交易服务 2:交易服务
+    var matchermode: Int = 0,//指定对手模式[仓单贸易模式专用] - 1:任意对手
+    var openmethod: Int = 0,//开盘模式 - 0 自动 1手动
+    var otcuserid: Int = 0,//场外期权做市商[场外期权]
+    var outersynctime: String = "",//外部同步时间点(h24:mi:ss)[场外期权]
+    var pendingflag: Int = 0,//待开市时间标识[通道交易-对冲] - 0:当日 1:上日
+    var pendingtime: String = "",//待开市时间通道交易-对冲
+    var performancetempid: Int = 0,//履约计划模板ID - 作废
+    var premiumquotemode: Int = 0,//权利金报价方式 - 1:自动 2:手动
+    var rebateratio: Int = 0,//返利比率[竞价式]
+    var reckonorder: Int = 0,//结算顺序
+    var reckonpricealgorithm: Int = 0,//结算价算法: 1:最后多少笔成交价加权平均 2:最后多少秒成交价加权平均 3:全天加权平均 4:最后一口价 5.买一价 6.卖一价 7.买一卖一均价 8.外部结算价
+    var reckonpriceparam: Int = 0,//结算价参数
+    var reckontime: String = "",//结算时间通道交易-对冲
+    var roleprioritytype: Int = 0,//角色优先类型 - 1:无 2:报价商优先 3:非报价商优先 [16:挂牌点选]
+    var selllistingauditflag: Int = 0,//卖挂牌是否需要审核(仓单贸易) - 0:不需要 1:需要
+    var trademarkettype: Int = 0,//交易市场类型 - 1:合约市场 2:外部市场 3:仓单市场
+    var trademode: Int = 0,//交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价
+    var tradeproperty: Int = 0,//交易属性 - 1:收益权(可做空) 2:所有权(不可做空) 3:期权 4:现货 5:参考行情 6:通道交易 7:币交易 8:场外期权
+    var tradetype: Int = 0//下单方式[通道交易] - 1:直接转单 2:净头寸下单
+)
+

+ 53 - 5
RMA/app/src/main/java/cn/muchinfo/rma/global/data/chart/ChartTSData.kt

@@ -1,5 +1,9 @@
 package cn.muchinfo.rma.global.data.chart
 
+import cn.muchinfo.rma.global.toShowTime
+import kotlinx.coroutines.selects.select
+import java.util.*
+
 data class ChartTSData(
     val decimalPlace: String? = "",  //                         小数位
     val endTime: String? = "", //                               结束时间
@@ -40,20 +44,64 @@ data class ChartTSData(
      * 如果均线数据是补得数据  则计算数值时直接沿用上一口价格
      * 计算分时图 AVG10
      */
-    fun getTimeChartAVG10() : List<Double>{
+    fun getTimeChartAVG(avg: Int) : List<Double>{
         var avg10 = arrayListOf<Double>()
+        var save10 = arrayListOf<Double>()  // 这里保存的是10个有效的价格(补得数据则被跳过)
         if(historyDatas != null && historyDatas.isNotEmpty()){
             for(index in historyDatas.indices){
-                if(index == 0){
-                    avg10.add(historyDatas[index].c!!.toDouble())
+                if(historyDatas[index].getIsSupplementaryData()){
+                    if(avg10.size > 0) {
+                        avg10.add(avg10.last())
+                    }
+                    continue
                 }else{
-                    if(historyDatas[index - 1].c.equals(historyDatas[index].c)){
+                    save10.add(historyDatas[index].getClosePrice().toDouble())
+                    if(save10.size == avg){ // 第一次满足10个数据  计算代数平均
+                        avg10.add(save10.sum().div(save10.size))
+                    }else if(save10.size > avg){ // 之后每次满足都要移除最前面的数据
+                        save10.removeAt(0)
+                        avg10.add(save10.sum().div(save10.size))
+                    }else{
+                        avg10.add(save10.sum().div(save10.size))
                         continue
                     }
-                    avg10.add(((historyDatas[index - 1].c!!.toDouble() * historyDatas.size) + historyDatas[index].c!!.toDouble()) / (historyDatas.size + 1))
                 }
+//                if(index == 0){
+//                    avg10.add(historyDatas[index].c!!.toDouble())
+//                }else{
+//                    if(historyDatas[index - 1].c.equals(historyDatas[index].c)){
+//                        avg10.add(historyDatas[index].c!!.toDouble())
+//                    }else {
+//                        avg10.add(((historyDatas[index - 1].c!!.toDouble() * historyDatas.size) + historyDatas[index].c!!.toDouble()) / (historyDatas.size + 1))
+//                    }6
+//                }
             }
         }
         return avg10;
     }
+
+    fun getMaxValue() : Double{
+        var max = 0.0
+        if(historyDatas != null && historyDatas.isNotEmpty()){
+            historyDatas.forEach {
+                if(it.getHighestPrice().toDouble() > max) {
+                    max = it.getHighestPrice().toDouble()
+                }
+            }
+        }
+        return max
+    }
+
+    fun getMinValue() : Double{
+        if(historyDatas != null && historyDatas.isNotEmpty()){
+            var min = historyDatas[0].getLowestPrice().toDouble()
+                historyDatas.forEach {
+                if(it.getLowestPrice().toDouble() < min) {
+                    min = it.getLowestPrice().toDouble()
+                }
+            }
+            return min
+        }
+        return 0.0;
+    }
 }

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

@@ -8,10 +8,10 @@ object Constant {
      */
 //    const val baseurl = "http://103.40.249.127:28280/cfg?key=mtp_20"
 //    const val baseurl = "http://192.168.30.125:8080/cfg?key=test_125"
-//    const val baseurl = "http://192.168.31.114:8080/cfg?key=test_114" // shenzhen01  123123
+    const val baseurl = "http://192.168.31.114:8080/cfg?key=test_114" // shenzhen01  123123
 //    const val baseurl = "http://192.168.31.220:8080/cfg?key=test_220"//李倩
 //      const val baseurl = "http://192.168.30.211:8080/cfg?key=test_211"// 瑶姐
-    const val baseurl = "http://192.168.31.175:8080/cfg?key=test_175" // 8888  123123
+//    const val baseurl = "http://192.168.31.175:8080/cfg?key=test_175" // 8888  123123
 //    const val baseurl = "http://192.168.31.223:8080/cfg?key=test_223"
 
     /**

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

@@ -3,26 +3,41 @@ package cn.muchinfo.rma.view.base.chart;
 import android.content.Context
 import android.content.Intent
 import android.os.Bundle
+import android.view.View
 import android.widget.ImageView
+import android.widget.ProgressBar
+import android.widget.RelativeLayout
+import com.google.android.material.tabs.TabLayout
+
 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.KChartView
 import cn.muchinfo.rma.view.base.chart.old.timeCharts.TimeChartView
-import org.jetbrains.anko.verticalLayout
+import cn.muchinfo.rma.view.base.future.trade.GoodsTradeActivity
+import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
+import com.blankj.utilcode.util.ActivityUtils
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
+import org.greenrobot.eventbus.ThreadMode
 
 /**
  * 图表相关
  */
-class ChartActivity : BaseActivity<ChartViewModel>() {
+class ChartActivity : BaseActivity<ChartViewModel>() , View.OnClickListener{
 
     lateinit var timeChartView: TimeChartView
+    lateinit var tabLayout: TabLayout
+    lateinit var kChartView: KChartView
+    lateinit var progressBar: ProgressBar
 
     companion object {
         // 启动页面
-        fun start(goodsCode: String?, outGoodsCode: String?, context: Context) {
+        fun start(goodsId: String?, goodsCode: String?, outGoodsCode: String?, context: Context) {
             val intent = Intent()
             intent.setClass(context, ChartActivity::class.java)
+            intent.putExtra("goodsId", goodsId)
             intent.putExtra("goodsCode", goodsCode)
             intent.putExtra("outGoodsCode", outGoodsCode)
             context.startActivity(intent)
@@ -31,31 +46,113 @@ class ChartActivity : BaseActivity<ChartViewModel>() {
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
+        EventBus.getDefault().register(this)
         setContentView(R.layout.activity_chart)
         initView()
         viewModel.initData(intent)
         viewModel.initRequest()
+
     }
 
     fun initView(){
         findViewById<ImageView>(R.id.back_img).setOnClickListener {
             finish()
         }
+        tabLayout = findViewById(R.id.mtp_chart_head)
+        timeChartView =  findViewById(R.id.time_chart_view)  // 分时图
+        kChartView = findViewById(R.id.k_chart_view)  //        k线图
+        progressBar = findViewById(R.id.progress_view)
 
-        timeChartView =  findViewById(R.id.time_chart_view)
-        timeChartView = TimeChartView(this)
+        findViewById<RelativeLayout>(R.id.trade_rly).setOnClickListener(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
+            findViewById<TextView>(R.id.tag_market_tag).text = viewModel.marketName
         })
 
         viewModel.tsData.observe(this, Observer {
+            progressBar.visibility = View.INVISIBLE
             timeChartView.setData(it)
         })
+
+        viewModel.kData.observe(this, Observer {
+            progressBar.visibility = View.INVISIBLE
+            kChartView.setDates(viewModel.outGoodsCode, it)
+        })
+
+        tabLayout.addTab(tabLayout.newTab().setText("分时图").setTag(10086))
+        tabLayout.addTab(tabLayout.newTab().setText("日 K").setTag(11))
+        tabLayout.addTab(tabLayout.newTab().setText("周 K").setTag(12))
+        tabLayout.addTab(tabLayout.newTab().setText("月 K").setTag(13))
+        tabLayout.addTab(tabLayout.newTab().setText("年 K").setTag(14))
+        tabLayout.addTab(tabLayout.newTab().setText("1 分").setTag(1))
+        tabLayout.addTab(tabLayout.newTab().setText("5 分").setTag(2))
+        tabLayout.addTab(tabLayout.newTab().setText("30 分").setTag(3))
+
+        tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener{
+            override fun onTabReselected(tab: TabLayout.Tab?) {
+
+            }
+
+            override fun onTabUnselected(tab: TabLayout.Tab?) {
+
+            }
+
+            override fun onTabSelected(tab: TabLayout.Tab?) {
+                when(tab?.tag){
+                    10086 -> {
+                        kChartView.visibility = View.INVISIBLE
+                        timeChartView.visibility = View.VISIBLE
+                        viewModel.queryTimeChart()
+                        progressBar.visibility = View.VISIBLE
+                    }
+                    1,2,3,11,12,13,14 -> {
+                        kChartView.visibility = View.VISIBLE
+                        timeChartView.visibility = View.INVISIBLE
+                        viewModel.queryKChart( tab.tag.toString())
+                        progressBar.visibility = View.VISIBLE
+                    }
+                }
+            }
+        })
+
+        timeChartView.setTimeChartListener {
+            // 重新刷新
+            viewModel.queryTimeChart()
+        }
+    }
+
+    override fun onClick(v: View?) {
+        when(v?.id){
+            R.id.trade_rly -> {
+                val intent = Intent()
+                intent.putExtra("goodsId", viewModel.goodsId)
+                intent.putExtra("outGoodsCode", viewModel.outGoodsCode)
+                intent.setClass(this, GoodsTradeActivity::class.java)
+                ActivityUtils.startActivity(intent)
+            }
+        }
     }
 
 
+    //行情推送通知
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
+        val goodsids = quoteMessageEvent.goodsid
+        //如果推送的goodsid包含当前页面的goodsid,则进行页面刷新
+        if (goodsids.contains(viewModel.goodsId)){
+            // 这里把当前最新价转化为历史
+            timeChartView.refreshDate(ChartDataAdapter().getHisTikData(viewModel.outGoodsCode))
+            // 这里更新最新价
+            viewModel.refreshTimePrice(timeChartView)
+        }
+    }
+
+    override fun onDestroy() {
+        super.onDestroy()
+        EventBus.getDefault().unregister(this)
+    }
 
 
 }

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

@@ -2,6 +2,13 @@ package cn.muchinfo.rma.view.base.chart;
 
 import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.data.GoodsInfoAndQuotes
+import cn.muchinfo.rma.global.data.chart.HistoryDatas
+import cn.muchinfo.rma.global.toShowTime
+import cn.muchinfo.rma.global.toTimeData
+import com.blankj.utilcode.util.TimeUtils
+import com.desfate.chart.entity.OHLCEntity
+import java.text.SimpleDateFormat
+import java.util.*
 
 /**
  * 数据在这里适配
@@ -22,4 +29,49 @@ class ChartDataAdapter {
         }
     }
 
+    /**
+     * 转换当前行情的数据为历史
+     */
+    fun getHisTikData(goodsCode : String) : HistoryDatas{
+        var lastQuote = GlobalDataCollection.instance?.goodsInfoAndQuotesList?.find {
+            it.outgoodscode == goodsCode
+        }?.quoteDayData
+        return HistoryDatas( lastQuote?.last.toString(),
+            "",
+            lastQuote?.last.toString(),
+            lastQuote?.last.toString(),
+            lastQuote?.last.toString(),
+            lastQuote?.last.toString(),
+            lastQuote?.last.toString(),
+            lastQuote?.lasttime.toString(),
+            lastQuote?.last.toString(),
+            lastQuote?.last.toString())
+    }
+
+    fun checkSameMin(time1: String, time2: String): Boolean{
+        val cal1 = Calendar.getInstance()
+        cal1.time = time1.toTimeData()
+        val cal2 = Calendar.getInstance()
+        cal2.time = time2.toTimeData()
+        return cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR) &&
+        cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR) &&
+        cal1.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE)
+    }
+
+    fun historyDataToOHLDate(history: List<HistoryDatas>): List<OHLCEntity>{
+        if(history.isNotEmpty()){
+            return history.map {
+                val ohlcEntity = OHLCEntity()
+                ohlcEntity.close = it.getClosePrice().toDouble()
+                ohlcEntity.high = it.getHighestPrice().toDouble()
+                ohlcEntity.low = it.getLowestPrice().toDouble()
+                ohlcEntity.open = it.getOpeningPrice().toDouble()
+                ohlcEntity.time = it.getTime().toShowTime()
+                ohlcEntity
+            }
+        }
+        return arrayListOf()
+    }
+
+
 }

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

@@ -1,31 +1,89 @@
 package cn.muchinfo.rma.view.base.chart
 
 import android.content.Intent
+import androidx.core.content.ContextCompat.getColor
 import androidx.lifecycle.MutableLiveData
+import cn.muchinfo.rma.R
 import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
+import cn.muchinfo.rma.global.data.account.loginQeruy.Markets
 import cn.muchinfo.rma.global.data.chart.ChartTSData
+import cn.muchinfo.rma.global.data.chart.HistoryDatas
+import cn.muchinfo.rma.global.database.AppDatabase
+import cn.muchinfo.rma.global.room.Builder
 import cn.muchinfo.rma.view.MyApplication
 import cn.muchinfo.rma.view.base.BaseViewModel
+import cn.muchinfo.rma.view.base.chart.old.timeCharts.TimeChartView
 
-class ChartViewModel : BaseViewModel(){
+/**
+ * 分时图使用goodscode请求接口  用outgoodscode请求盘面
+ */
+class ChartViewModel : BaseViewModel() {
 
+    var goodsInfo: MutableLiveData<GoodsInfo> = MutableLiveData()  // 当前选中的商品信息
+    var tsData: MutableLiveData<ChartTSData> = MutableLiveData()
+    var kData: MutableLiveData<List<HistoryDatas>> = MutableLiveData()
+
+    var goodsId = 0
     var outGoodsCode = ""
     var goodsCode = ""
-    var goodsInfo : MutableLiveData<GoodsInfo> = MutableLiveData()  // 当前选中的商品信息
-    var tsData : MutableLiveData<ChartTSData> = MutableLiveData()
+    var goodsGroupId = 0
+    var marketName = ""
+    var marketId = 0
 
-    fun initData(intent: Intent){
+    fun initData(intent: Intent) {
+        goodsId = intent.getIntExtra("goodsId", 0)
         outGoodsCode = intent.getStringExtra("outGoodsCode").toString()
         goodsCode = intent.getStringExtra("goodsCode").toString()
-        goodsInfo.postValue(GlobalDataCollection.instance?.goodsInfoList?.find { it.goodscode.equals(goodsCode) })
+        goodsGroupId = intent.getIntExtra("goodsGroupId", 0)
+        marketId = intent.getIntExtra("marketId", 0)
+        goodsInfo.postValue(Builder.getDatabase<AppDatabase>().goodsInfoDao.getGoodsInfo(goodsId))
+        // FIXME: 2021/4/25  这里以后要根据市场id去判断交易模式 现在只有一种交易模式
+        // autoId 关联 exchangeId
+        if(GlobalDataCollection.instance?.loginQueryData?.market?.size != 0){
+            val markets: Markets =
+                GlobalDataCollection.instance?.loginQueryData?.market?.find { it.marketid == marketId }!!
+            marketName = if (markets.trademode == 15) {
+                GlobalDataCollection.instance?.loginQueryData?.externalExchanges?.find { externalExchanges ->
+                    externalExchanges.autoid ==
+                            GlobalDataCollection.instance?.loginQueryData?.goodsgroups?.find { it.goodsgroupid == goodsGroupId }?.exexchangeid
+                }?.exexchangename.toString()
+            } else {
+                markets.marketname
+            }
+        }
+        // 订阅当前商品行情
+        MyApplication.getInstance()?.quoteManager?.addSubscriptQuote(
+            "11112",
+            setOf(outGoodsCode)
+        ) { isCompleted, err ->
+            System.out.println(isCompleted)
+        }
     }
 
-    fun initRequest(){
-        queryTsData(goodsCode);
+    fun initRequest() {
+        queryTsData(goodsCode)
+        queryQuoteDay(outGoodsCode)
     }
 
 
+    /**
+     * 分时图请求
+     */
+    fun queryTimeChart(){
+        queryTsData(goodsCode)
+    }
+
+    /**
+     * 请求当前商品k线
+     */
+    fun queryKChart(type: String){
+        queryKChartData(outGoodsCode, type)
+    }
+
+    /**
+     * 请求当前商品历史数据
+     */
     fun queryTsData(goodsCode: String) {
         val params = mutableMapOf<String, String>().apply {
             put("goodsCode", goodsCode)
@@ -36,4 +94,47 @@ class ChartViewModel : BaseViewModel(){
             }
         }
     }
+
+    /**
+     * 请求当前商品盘面
+     */
+    fun queryQuoteDay(goodsCode: String) {
+        val params = mutableMapOf<String, String>().apply {
+            put("goodsCodes", goodsCode)
+        }
+        MyApplication.getInstance()?.futureManager?.queryQuoteDay(params = params) { isSuccess, respData, _ ->
+            if (isSuccess) {
+                // 盘面请求成功
+                tsData.postValue(tsData.value)  // 刷新图表
+            }
+        }
+      }
+
+    /**
+     * 请求k线数据
+     */
+    fun queryKChartData(goodsCode: String, type: String){
+        val params = mutableMapOf<String, String>().apply {
+            put("goodsCode", goodsCode)
+            put("cycleType", type)
+            put("count", "600")
+            put("isAsc", "true")
+        }
+        MyApplication.getInstance()?.chartManager?.queryHistoryDatas(params = params) { isSuccess, respData, _ ->
+            if (isSuccess) {
+                kData.postValue(respData)
+            }
+        }
+    }
+
+    /**
+     * 更新分时图最新价
+     */
+    fun refreshTimePrice(timeChartView: TimeChartView){
+        timeChartView.setLastPrice(
+            ChartDataAdapter().getGoodsInfoMarket(outGoodsCode)!!.quoteDayData.last.toString(), getColor(getApplication(),
+                R.color.p_down_color))
+    }
+
+
 }

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

@@ -11,6 +11,7 @@ import android.widget.TextView;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import com.desfate.chart.ChartConstant;
+import com.desfate.chart.GridChart;
 import com.desfate.chart.MACandleStickChart;
 import com.desfate.chart.MinusStickChart;
 import com.desfate.chart.entity.LineEntity;
@@ -45,7 +46,7 @@ public class KChartView extends FrameLayout {
     }
 
     private void initView(){
-        view = LayoutInflater.from(context).inflate(R.layout.k_chart_view, null);
+        view = LayoutInflater.from(getContext()).inflate(R.layout.k_chart_view, this);
         candle_chart = view.findViewById(R.id.candle_chart);
         minusStickChart = view.findViewById(R.id.minus_chart);
         info_text = view.findViewById(R.id.info_text);
@@ -144,11 +145,25 @@ public class KChartView extends FrameLayout {
         M15Line.setLineColor(getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_ma5));
         M15Line.setLineData(new KChartTools().getMDatesAdapter(15, history));
         lines.add(M15Line);
+        candle_chart.setMaxSticksNum(candle_chart.getMaxSticksNum());
+
+        candle_chart.setNotifyAxisMarginLeft(GridChart.DEFAULT_AXIS_MARGIN_LEFT);
+        candle_chart.setStartIndex(-1);
         candle_chart.setTasLastPrice(String.valueOf(new ChartDataAdapter().getGoodsInfoMarket(goodsCode).getQuoteDayData().getLast()));
         candle_chart.setNewPriceColor(getResources().getColor(R.color.p_up_color));
+
         candle_chart.setLineData(lines);
+        candle_chart.setOHLCData(new ChartDataAdapter().historyDataToOHLDate(history));
+
+        LineEntity MA5 = candle_chart.getLineData().get(0);
+        LineEntity MA10 = candle_chart.getLineData().get(1);
+        LineEntity MA15 = candle_chart.getLineData().get(2);
+        double ma5Val = MA5.getLineData().get(MA5.getLineData().size() - 1);
+        double ma10Val = MA10.getLineData().get(MA10.getLineData().size() - 1);
+        double ma15Val = MA15.getLineData().get(MA15.getLineData().size() - 1);
+
         candle_chart.setDecimalNum(new ChartDataAdapter().getGoodsInfoMarket(goodsCode).getGoodsInfo().getDecimalplace());
-        candle_chart.postInvalidate();
+        candle_chart.invalidate();
     }
 
 

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

@@ -5,14 +5,19 @@ import android.graphics.Color;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.FrameLayout;
+
+import com.desfate.chart.GridChart;
 import com.desfate.chart.LineChart;
 import com.desfate.chart.entity.LineEntity;
 import java.util.ArrayList;
 import java.util.List;
 import cn.muchinfo.rma.R;
 import cn.muchinfo.rma.global.data.chart.ChartTSData;
+import cn.muchinfo.rma.global.data.chart.HistoryDatas;
 import cn.muchinfo.rma.view.base.chart.ChartDataAdapter;
+import cn.muchinfo.rma.view.base.chart.old.controls.OTCChartControl;
 
 /**
  * 我负责抽离混乱的分时图逻辑
@@ -24,6 +29,7 @@ public class TimeChartView extends FrameLayout {
     ChartTSData timeChartData;
     LineChart lineChart;
 
+
     public TimeChartView(Context context) {
         super(context);
         this.context = context;
@@ -36,8 +42,8 @@ public class TimeChartView extends FrameLayout {
         initView();
     }
 
-    private void initView(){
-        view = LayoutInflater.from(context).inflate(R.layout.time_chart_view, null);
+    public void initView(){
+        view =  LayoutInflater.from(getContext()).inflate(R.layout.time_chart_view, this);
         lineChart = view.findViewById(R.id.line_chart_view);
         setLineConfig();
     }
@@ -58,7 +64,7 @@ public class TimeChartView extends FrameLayout {
         lineChart.setStartIndex(1);
         lineChart.setLatitudeColor(Color.GRAY);
         lineChart.setLatitudeFontColor(Color.GRAY);
-        lineChart.setBackgroundColor(getResources().getColor(R.color.manager_body_bg));
+        lineChart.setBackgroundColor(getResources().getColor(R.color.chart_background_color));
         // 设置屏幕最多显示多少条数据,如果多余这个数字将要滑动才能看见
         lineChart.setMaxPointNum(1440);
         lineChart.setDisplayAxisXTitle(true);
@@ -84,21 +90,78 @@ public class TimeChartView extends FrameLayout {
         LineEntity minutesLine = new LineEntity();
         minutesLine.setTitle("M");
         minutesLine.setLineData(timeChartData.getTimeChartPriceData());
-        minutesLine.setLineColor(getResources().getColor(R.color.mtp_chart_t_m5_m1));
+        minutesLine.setLineColor(getResources().getColor(R.color.chart_time_min_line_color));
         minutesLine.setLineTime(timeChartData.getTimeChartPriceTime());
         // 十日均线
         LineEntity avg10Line = new LineEntity();
         avg10Line.setTitle("AVG10");
-        avg10Line.setLineData(timeChartData.getTimeChartAVG10());
+        avg10Line.setLineData(timeChartData.getTimeChartAVG(1440));
         avg10Line.setLineTime(timeChartData.getTimeChartPriceTime());
-        avg10Line.setLineColor(getResources().getColor(R.color.mtp_chart_t_avg));
+        avg10Line.setLineColor(getResources().getColor(R.color.chart_avg_line_color));
+
+        lines.add(avg10Line);
+        lines.add(minutesLine);
+
+        if(timeChartData.getMaxValue() == timeChartData.getMinValue()){
+            lineChart.setMaxValue(timeChartData.getMaxValue() * 1.05);
+            lineChart.setMinValue(0);
+        }else {
+            lineChart.setMaxValue(timeChartData.getMaxValue());
+            lineChart.setMinValue(timeChartData.getMinValue());
+        }
+
         // 这里是通过起始点和结束点 确认当前显示的宽高
         lineChart.initAxisY(timeChartData.getPreSettle(),
-                String.valueOf(new ChartDataAdapter().getGoodsInfoMarket(timeChartData.getGoodsCode()).getQuoteDayData().getLast()),
+                String.valueOf(new ChartDataAdapter().getGoodsInfoMarket(timeChartData.getOutGoodsCode()).getQuoteDayData().getLast()),
                 timeChartData.getDecimalPlace());
         lineChart.setDecimalNum(Integer.parseInt(timeChartData.getDecimalPlace()));
         lineChart.setLineData(lines);
-        lineChart.postInvalidate();
+        lineChart.setDatasNum(timeChartData.getHistoryDatas().size());
+
+        lineChart.setNotifyAxisMarginLeft(GridChart.DEFAULT_AXIS_MARGIN_LEFT);
+        lineChart.setStartIndex(-1);
+        lineChart.invalidate();
+    }
+
+    /**
+     * 这个方法只负责最新价的标题显示以及绘制颜色值
+     * @param lastPrice 最新价
+     * @param priceColor 最新价颜色
+     */
+    public void setLastPrice(String lastPrice, int priceColor){
+        // 最新的数据
+        lineChart.setTasLastPrice(lastPrice);
+        lineChart.setNewPriceColor(priceColor);
+        lineChart.invalidate();
+    }
+
+    /**
+     * 更新主数据
+     * @param lastDate 最新数据
+     */
+    public void refreshDate(HistoryDatas lastDate){
+        if(timeChartData == null || timeChartData.getHistoryDatas() == null) return; // 没有数据
+        HistoryDatas lastData = timeChartData.getHistoryDatas().get(timeChartData.getHistoryDatas().size() - 1);
+        HistoryDatas nowData = lastData;
+//        if(new ChartDataAdapter().checkSameMin(nowData.getTime(), lastData.getTime())){ // 不是同一分钟 则重新请求
+            timeChartData.getHistoryDatas().add(lastDate);
+//        }else{
+//            if(timeChartListener != null) timeChartListener.onTimeRepairFail();
+//        }
+        setData(timeChartData);
+//        if(timeChartData.getHistoryDatas().get(timeChartData.getHistoryDatas().size() - 1).getTime())
     }
 
+    TimeChartListener timeChartListener;
+
+    public void setTimeChartListener(TimeChartListener timeChartListener){
+        this.timeChartListener = timeChartListener;
+    }
+
+    public interface TimeChartListener{
+        void onTimeRepairFail();
+    }
+
+
+
 }

+ 15 - 3
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/markets/MarketBaseModel.kt

@@ -256,12 +256,24 @@ class MarketBaseModel : BaseViewModel() {
             // 点击item
             holder.itemView.tag = list?.get(position)
             holder.itemView.setOnClickListener {
+//                val intent = Intent()
+//                intent.putExtra("goodsId", list?.get(position)?.goodsid.toString())
+//                intent.putExtra("outGoodsCode", list?.get(position)?.outgoodscode)
+//                intent.setClass(context!!, GoodsTradeActivity::class.java)
+//                ActivityUtils.startActivity(intent)
+
+                val goodsInfo: GoodsInfo = it.tag as GoodsInfo
+
+
                 val intent = Intent()
-                intent.putExtra("goodsId", list?.get(position)?.goodsid.toString())
                 intent.putExtra("outGoodsCode", list?.get(position)?.outgoodscode)
-                intent.setClass(context!!, GoodsTradeActivity::class.java)
+                intent.putExtra("goodsCode", list?.get(position)?.goodscode)
+                intent.putExtra("goodsId", list?.get(position)?.goodsid)
+                intent.putExtra("goodsGroupId", list?.get(position)?.goodsgroupid)
+                intent.putExtra("marketId", list?.get(position)?.marketid)
+                intent.setClass(context!!, ChartActivity::class.java)
                 ActivityUtils.startActivity(intent)
-//                val goodsInfo: GoodsInfo = it.tag as GoodsInfo
+
 //                ChartActivity.start(goodsInfo.goodscode, goodsInfo.outgoodscode, context!!)
             }
         }

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

@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
+<androidx.constraintlayout.widget.ConstraintLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/roots_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
@@ -11,6 +12,9 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:background="@color/main_title_bg_color"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
         >
 
         <ImageView
@@ -96,259 +100,138 @@
         layout="@layout/chart_info_layout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_below="@+id/title_lay" />
+        android:layout_below="@+id/title_lay"
+        app:layout_constraintTop_toBottomOf="@+id/title_lay"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        />
 
-    <HorizontalScrollView
+    <com.google.android.material.tabs.TabLayout
         android:layout_below="@+id/chart_info_lay"
         android:id="@+id/mtp_chart_head"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:scrollbars="none">
-
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal">
-
-            <RelativeLayout
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:orientation="vertical">
-
-                <TextView
-                    android:id="@+id/mtp_time_chart"
-                    android:layout_width="40dip"
-                    android:layout_height="wrap_content"
-                    android:layout_marginLeft="1dip"
-                    android:background="@color/p_global_bg_color"
-                    android:gravity="center"
-                    android:paddingBottom="5dip"
-                    android:paddingTop="5dip"
-                    android:text="分时图"
-                    android:textColor="@color/p_normal_txt_color"
-                    android:textSize="12sp" />
+        android:layout_height="30dp"
+        app:tabMode="scrollable"
+        app:tabGravity="center"
+        app:tabIndicatorColor="@color/rma_item_yellow_color"
+        app:tabSelectedTextColor="@color/rma_item_yellow_color"
+        app:tabTextColor="@color/__picker_black_40"
+        app:tabBackground="@android:color/transparent"
+        app:tabRippleColor="@android:color/transparent"
+        app:layout_constraintTop_toBottomOf="@+id/chart_info_lay"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        />
 
-                <TextView
-                    android:id="@+id/mtp_time_chart_b"
-                    android:layout_width="34dip"
-                    android:layout_height="3dip"
-                    android:layout_alignBottom="@+id/mtp_time_chart"
-                    android:layout_centerHorizontal="true"
-                    android:background="@color/line_hint_color" />
-            </RelativeLayout>
-
-            <RelativeLayout
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:orientation="vertical">
-
-                <TextView
-                    android:id="@+id/mtp_one_chart"
-                    android:layout_width="40dip"
-                    android:layout_height="wrap_content"
-                    android:background="@color/p_global_bg_color"
-                    android:gravity="center"
-                    android:paddingBottom="5dip"
-                    android:paddingTop="5dip"
-                    android:text="1分"
-                    android:textColor="@color/p_normal_txt_color"
-                    android:textSize="12sp" />
-
-                <TextView
-                    android:id="@+id/mtp_one_chart_b"
-                    android:layout_width="34dp"
-                    android:layout_height="3dip"
-                    android:layout_alignBottom="@+id/mtp_one_chart"
-                    android:layout_centerHorizontal="true"
-                    android:background="@color/line_hint_color"
-                    android:visibility="gone" />
-            </RelativeLayout>
-
-            <RelativeLayout
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:orientation="vertical">
-
-                <TextView
-                    android:id="@+id/mtp_five_chart"
-                    android:layout_width="40dip"
-                    android:layout_height="wrap_content"
-                    android:background="@color/p_global_bg_color"
-                    android:gravity="center"
-                    android:paddingBottom="5dip"
-                    android:paddingTop="5dip"
-                    android:text="5分"
-                    android:textColor="@color/p_normal_txt_color"
-                    android:textSize="12sp" />
+    <RelativeLayout
+        android:layout_below="@+id/mtp_chart_head"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:id="@+id/chart_lay"
+        app:layout_constraintTop_toBottomOf="@+id/mtp_chart_head"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/bottom_lay"
+        >
 
-                <TextView
-                    android:id="@+id/mtp_five_chart_b"
-                    android:layout_width="34dp"
-                    android:layout_height="3dip"
-                    android:layout_alignBottom="@+id/mtp_five_chart"
-                    android:layout_centerHorizontal="true"
-                    android:background="@color/line_hint_color"
-                    android:visibility="gone" />
-            </RelativeLayout>
+    <TextView
+        android:id="@+id/chart_title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:paddingBottom="2dip"
+        android:paddingLeft="10dip"
+        android:paddingRight="15dip"
+        android:paddingTop="2dip" />
 
-            <RelativeLayout
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:orientation="vertical">
+    <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"
+        />
 
-                <TextView
-                    android:id="@+id/mtp_thirty_chart"
-                    android:layout_width="40dip"
-                    android:layout_height="wrap_content"
-                    android:background="@color/p_global_bg_color"
-                    android:gravity="center"
-                    android:paddingBottom="5dip"
-                    android:paddingTop="5dip"
-                    android:text="30分"
-                    android:textColor="@color/p_normal_txt_color"
-                    android:textSize="12sp" />
+    <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"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_centerInParent="true"
+        />
+    </RelativeLayout>
 
-                <TextView
-                    android:id="@+id/mtp_thirty_chart_b"
-                    android:layout_width="34dp"
-                    android:layout_height="3dip"
-                    android:layout_alignBottom="@+id/mtp_thirty_chart"
-                    android:layout_centerHorizontal="true"
-                    android:background="@color/line_hint_color"
-                    android:visibility="gone" />
-            </RelativeLayout>
+    <LinearLayout
+        android:id="@+id/bottom_lay"
+        android:layout_width="match_parent"
+        android:layout_height="60dp"
+        android:orientation="horizontal"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/chart_lay"
+        >
 
-            <RelativeLayout
+        <RelativeLayout
+            android:layout_weight="1"
+            android:layout_height="match_parent"
+            android:layout_width="wrap_content"
+            android:gravity="center_horizontal"
+            android:padding="5dp"
+            >
+            <ImageView
+                android:id="@+id/self_choice_img"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:visibility="gone"
-                android:orientation="vertical">
-
-                <TextView
-                    android:id="@+id/mtp_one_hour_chart"
-                    android:layout_width="40dip"
-                    android:layout_height="wrap_content"
-                    android:background="@color/p_global_bg_color"
-                    android:gravity="center"
-                    android:paddingBottom="5dip"
-                    android:paddingTop="5dip"
-                    android:text="1时"
-                    android:textColor="@color/p_normal_txt_color"
-                    android:textSize="12sp" />
-
-                <TextView
-                    android:id="@+id/mtp_one_hour_chart_b"
-                    android:layout_width="34dp"
-                    android:layout_height="3dip"
-                    android:layout_alignBottom="@+id/mtp_one_hour_chart"
-                    android:layout_centerHorizontal="true"
-                    android:background="@color/line_hint_color"
-                    android:visibility="gone" />
-            </RelativeLayout>
+                android:src="@mipmap/chart_buy_icon"
+                android:layout_centerHorizontal="true"
+                />
 
-            <RelativeLayout
+            <TextView
+                android:layout_below="@+id/self_choice_img"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:visibility="gone"
-                android:orientation="vertical">
+                android:layout_centerHorizontal="true"
+                android:textSize="@dimen/textsize_18sp"
+                android:text="自选"
+                />
 
-                <TextView
-                    android:id="@+id/mtp_two_hour_chart"
-                    android:layout_width="40dip"
-                    android:layout_height="wrap_content"
-                    android:background="@color/p_global_bg_color"
-                    android:gravity="center"
-                    android:paddingBottom="5dip"
-                    android:paddingTop="5dip"
-                    android:text="2时"
-                    android:textColor="@color/p_normal_txt_color"
-                    android:textSize="12sp" />
+        </RelativeLayout>
 
-                <TextView
-                    android:id="@+id/mtp_two_hour_chart_b"
-                    android:layout_width="34dp"
-                    android:layout_height="3dip"
-                    android:layout_alignBottom="@+id/mtp_two_hour_chart"
-                    android:layout_centerHorizontal="true"
-                    android:background="@color/line_hint_color"
-                    android:visibility="gone" />
-            </RelativeLayout>
 
-            <RelativeLayout
+        <RelativeLayout
+            android:id="@+id/trade_rly"
+            android:layout_height="match_parent"
+            android:layout_width="wrap_content"
+            android:layout_weight="1"
+            android:padding="5dp"
+            >
+            <ImageView
+                android:id="@+id/trade_img"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:visibility="gone"
-                android:orientation="vertical">
-
-                <TextView
-                    android:id="@+id/mtp_four_hour_chart"
-                    android:layout_width="40dip"
-                    android:layout_height="wrap_content"
-                    android:layout_alignParentTop="true"
-                    android:background="@color/p_global_bg_color"
-                    android:gravity="center"
-                    android:paddingBottom="5dip"
-                    android:paddingTop="5dip"
-                    android:text="4时"
-                    android:textColor="@color/p_normal_txt_color"
-                    android:textSize="12sp" />
-
-                <TextView
-                    android:id="@+id/mtp_four_hour_chart_b"
-                    android:layout_width="34dp"
-                    android:layout_height="3dip"
-                    android:layout_alignBottom="@+id/mtp_four_hour_chart"
-                    android:layout_centerHorizontal="true"
-                    android:background="@color/line_hint_color"
-                    android:visibility="gone" />
-            </RelativeLayout>
+                android:src="@mipmap/chart_buy_icon"
+                android:layout_centerHorizontal="true"
+                />
 
-            <RelativeLayout
+            <TextView
+                android:layout_below="@+id/trade_img"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:orientation="vertical">
-
-                <TextView
-                    android:id="@+id/mtp_one_day_chart"
-                    android:layout_width="40dip"
-                    android:layout_height="wrap_content"
-                    android:background="@color/p_global_bg_color"
-                    android:gravity="center"
-                    android:paddingBottom="5dip"
-                    android:paddingTop="5dip"
-                    android:text="日线"
-                    android:textColor="@color/p_normal_txt_color"
-
-                    android:textSize="12sp" />
-
-                <TextView
-                    android:id="@+id/mtp_one_day_chart_b"
-                    android:layout_width="34dp"
-                    android:layout_height="3dip"
-                    android:layout_alignBottom="@+id/mtp_one_day_chart"
-                    android:layout_centerHorizontal="true"
-                    android:background="@color/line_hint_color"
-                    android:visibility="gone" />
-            </RelativeLayout>
-        </LinearLayout>
-    </HorizontalScrollView>
+                android:text="交易"
+                android:textSize="@dimen/textsize_18sp"
+                android:layout_centerHorizontal="true"
+                />
 
+        </RelativeLayout>
 
-    <TextView
-        android:id="@+id/chart_title"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_vertical"
-        android:paddingBottom="2dip"
-        android:paddingLeft="10dip"
-        android:paddingRight="15dip"
-        android:paddingTop="2dip"
-        android:layout_below="@+id/mtp_chart_head"/>
 
-    <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"/>
+    </LinearLayout>
 
-</RelativeLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 49 - 19
RMA/app/src/main/res/layout/chart_info_layout.xml

@@ -25,7 +25,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
-                android:text="000000" />
+                android:text="--" />
 
             <TextView
                 android:id="@+id/now_price_value"
@@ -33,7 +33,7 @@
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
                 android:layout_centerVertical="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -48,14 +48,14 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
-                android:text="000000" />
+                android:text="--" />
 
             <TextView
                 android:id="@+id/up_down_present"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -70,6 +70,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textSize="12sp"
+                android:textColor="@color/rma_black_33"
                 android:text="成交量" />
 
             <TextView
@@ -77,7 +79,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -91,6 +93,8 @@
                 android:id="@+id/holder_amount_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:textSize="12sp"
+                android:textColor="@color/rma_black_33"
                 android:layout_alignParentStart="true"
                 android:text="持仓量" />
 
@@ -99,7 +103,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -113,6 +117,8 @@
                 android:id="@+id/daily_settlement_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:textSize="12sp"
+                android:textColor="@color/rma_black_33"
                 android:layout_alignParentStart="true"
                 android:text="作&#8195;结" />
 
@@ -121,7 +127,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -135,6 +141,8 @@
                 android:id="@+id/daily_close_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:textSize="12sp"
+                android:textColor="@color/rma_black_33"
                 android:layout_alignParentStart="true"
                 android:text="昨&#8195;收" />
 
@@ -143,7 +151,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -169,6 +177,8 @@
                 android:id="@+id/sell_price_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:textSize="12sp"
+                android:textColor="@color/rma_black_33"
                 android:layout_alignParentStart="true"
                 android:text="卖&#8195;价" />
 
@@ -178,7 +188,7 @@
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
                 android:layout_centerVertical="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -193,6 +203,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textSize="12sp"
+                android:textColor="@color/rma_black_33"
                 android:text="买&#8195;价" />
 
             <TextView
@@ -200,7 +212,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -215,6 +227,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
+                android:textSize="12sp"
                 android:text="最&#8195;高" />
 
             <TextView
@@ -222,7 +236,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -237,6 +251,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
+                android:textSize="12sp"
                 android:text="最&#8195;低" />
 
             <TextView
@@ -244,7 +260,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -259,6 +275,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
+                android:textSize="12sp"
                 android:text="涨&#8195;停" />
 
             <TextView
@@ -266,7 +284,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -280,7 +298,9 @@
                 android:id="@+id/drop_limit_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:textSize="12sp"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
                 android:text="跌&#8195;停" />
 
             <TextView
@@ -288,7 +308,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
     </LinearLayout>
@@ -312,7 +332,9 @@
                 android:id="@+id/sell_amount_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:textSize="12sp"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
                 android:text="卖&#8195;量" />
 
             <TextView
@@ -321,7 +343,7 @@
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
                 android:layout_centerVertical="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -336,6 +358,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
+                android:textSize="12sp"
                 android:text="买&#8195;量" />
 
             <TextView
@@ -343,7 +367,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -358,6 +382,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
+                android:textSize="12sp"
                 android:text="开&#8195;盘" />
 
             <TextView
@@ -365,7 +391,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -380,6 +406,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
+                android:textSize="12sp"
                 android:text="均&#8195;价" />
 
             <TextView
@@ -387,7 +415,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 
@@ -402,6 +430,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentStart="true"
+                android:textColor="@color/rma_black_33"
+                android:textSize="12sp"
                 android:text="结&#8195;算" />
 
             <TextView
@@ -409,7 +439,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentEnd="true"
-                android:text="000000" />
+                android:text="--" />
 
         </RelativeLayout>
 

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

@@ -6,13 +6,12 @@
 
     <com.desfate.chart.LineChart
         android:id="@+id/line_chart_view"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintLeft_toLeftOf="parent"
         />
 
-
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 1 - 1
RMA/chart/build.gradle

@@ -7,7 +7,7 @@ android {
     buildToolsVersion "30.0.3"
 
     defaultConfig {
-        minSdkVersion 23
+        minSdkVersion 24
         targetSdkVersion 30
         versionCode 1
         versionName "1.0"

+ 3 - 3
RMA/chart/src/main/java/com/desfate/chart/GridChart.java

@@ -1555,19 +1555,19 @@ public class GridChart extends BaseChart implements OnGestureListener, OnScaleGe
             mPaintFont.setColor(latitudeFontColor);
             mPaintFont.setAntiAlias(true);
             mPaintFont.setTextSize(latitudeFontSize);
-            if (!"".equals(getTasLastPrice())) {// 最新价格在界面上的显示
+            if (!"".equals(tasLastPrice)) {// 最新价格在界面上的显示
                 mPaintFont.setColor(getNewPriceColor());
                 String height = axisYTitles.get(axisYTitles.size() - 1);
                 String low = axisYTitles.get(0);
                 double sum = Double.parseDouble(height) - Double.parseDouble(low);// 最高价和最低价的差值
-                double sum_lastPrice = Double.parseDouble(getTasLastPrice()) - Double.parseDouble(low);// 最新价和最底价的差值
+                double sum_lastPrice = Double.parseDouble(tasLastPrice) - Double.parseDouble(low);// 最新价和最底价的差值
                 // 针对每个像素高度占用值
                 double cell = ((this.getHeight() - axisMarginBottom - axisMarginTop) / sum);
                 float _height = (float) (sum_lastPrice * cell);
                 /**
                  * 画出当前的最新价
                  */
-                canvas.drawText(getTasLastPrice(), super.getWidth() - axisMarginLeft,
+                canvas.drawText(tasLastPrice, super.getWidth() - axisMarginLeft,
                         this.getHeight() - _height - axisMarginBottom + latitudeFontSize / 2f, mPaintFont);
 
 

+ 5 - 0
RMA/chart/src/main/res/values/colors.xml

@@ -10,6 +10,11 @@
     <!--全局配置-全局的背景颜色,任何子布局、控件都不需要用颜色标配,-->
     <color name="p_global_bg_color">#f3f3f3</color>
     <!-- 图表 -->
+    <color name="chart_background_color">#F1F1F1</color>
+    <color name="chart_time_min_line_color">#2ba4fc</color>
+    <color name="chart_avg_line_color">#fddf81</color>
+
+
     <color name="mtp_chart_t_m5_m1">#333333</color>
     <color name="mtp_chart_white">#d7d7d7</color>
     <color name="mtp_chart_t_avg">#379A7B</color>