|
|
@@ -0,0 +1,1000 @@
|
|
|
+package cn.muchinfo.rma.view.base.yrdzpurchase.business
|
|
|
+
|
|
|
+import android.annotation.SuppressLint
|
|
|
+import android.content.Intent
|
|
|
+import android.os.Bundle
|
|
|
+import android.view.Gravity
|
|
|
+import android.view.View
|
|
|
+import android.view.ViewGroup
|
|
|
+import androidx.appcompat.app.AppCompatActivity
|
|
|
+import androidx.lifecycle.MutableLiveData
|
|
|
+import androidx.viewpager.widget.PagerAdapter
|
|
|
+import androidx.viewpager.widget.ViewPager
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
+import cn.muchinfo.rma.global.colorType
|
|
|
+import cn.muchinfo.rma.global.data.OrderQuoteData
|
|
|
+import cn.muchinfo.rma.global.data.OrderQuoteDetailData
|
|
|
+import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
|
|
|
+import cn.muchinfo.rma.global.database.DataBase
|
|
|
+import cn.muchinfo.rma.global.isBlankString
|
|
|
+import cn.muchinfo.rma.global.toPercentage
|
|
|
+import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
+import cn.muchinfo.rma.view.autoWidget.*
|
|
|
+import cn.muchinfo.rma.view.autoWidget.utils.NumberUtils
|
|
|
+import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.emptyView
|
|
|
+import cn.muchinfo.rma.view.base.warehousereceipt.*
|
|
|
+import cn.muchinfo.rma.view.eventbus.EventConstent
|
|
|
+import cn.muchinfo.rma.view.eventbus.MessageEvent
|
|
|
+import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
|
|
|
+import com.blankj.utilcode.util.ActivityUtils
|
|
|
+import com.blankj.utilcode.util.ConvertUtils
|
|
|
+import com.blankj.utilcode.util.LogUtils
|
|
|
+import com.qmuiteam.qmui.util.QMUIDisplayHelper
|
|
|
+import com.qmuiteam.qmui.widget.tab.QMUITabIndicator
|
|
|
+import com.qmuiteam.qmui.widget.tab.QMUITabSegment
|
|
|
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
|
|
|
+import mtp.polymer.com.autowidget.dialog.createLoadingDialog
|
|
|
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
+import org.greenrobot.eventbus.ThreadMode
|
|
|
+import org.jetbrains.anko.*
|
|
|
+import org.jetbrains.anko.support.v4.viewPager
|
|
|
+
|
|
|
+/**
|
|
|
+ * 合约市场买卖大厅
|
|
|
+ */
|
|
|
+class ContractBusinessHallActivity : BaseActivity<ContractBusinessHallViewModel>(){
|
|
|
+
|
|
|
+ lateinit var segment: QMUITabSegment
|
|
|
+ var selectedTabIndex: Int = 0
|
|
|
+ private lateinit var viewPager: ViewPager
|
|
|
+
|
|
|
+ val goodsId by lazy { intent.getStringExtra("goodsId")}
|
|
|
+
|
|
|
+ val goodsCode by lazy { intent.getStringExtra("goodsCode") }
|
|
|
+
|
|
|
+ //顶部数据是否展开
|
|
|
+ val priceUpDown : MutableLiveData<Boolean> = MutableLiveData<Boolean>().apply { value = false }
|
|
|
+
|
|
|
+ /** 用于订阅行情的唯一标识 */
|
|
|
+ val thisTag by lazy {
|
|
|
+ "ContractBusinessHallActivity"
|
|
|
+ }
|
|
|
+
|
|
|
+ //买大厅
|
|
|
+ val buyHallUI by lazy { BuyHallUI(this,viewModel) }
|
|
|
+
|
|
|
+ //卖大厅
|
|
|
+ val sellHallUI by lazy { SellHallUI(this,viewModel) }
|
|
|
+
|
|
|
+ //viewpager的适配器
|
|
|
+ private var newPagerAdapter: PagerAdapter? = null
|
|
|
+
|
|
|
+ //tabSegment标题
|
|
|
+ private val newTabsArray: ArrayList<String> = arrayListOf()
|
|
|
+
|
|
|
+ //暂存的页面组
|
|
|
+ private val uiList: ArrayList<_FrameLayout> = arrayListOf()
|
|
|
+
|
|
|
+ val selectIndex: MutableLiveData<Int> = MutableLiveData()
|
|
|
+
|
|
|
+ fun initMenuData() {
|
|
|
+
|
|
|
+ newTabsArray.add("卖大厅")
|
|
|
+ uiList.add(sellHallUI.root)
|
|
|
+
|
|
|
+ newTabsArray.add("买大厅")
|
|
|
+ uiList.add(buyHallUI.root)
|
|
|
+
|
|
|
+ newPagerAdapter = object : PagerAdapter() {
|
|
|
+
|
|
|
+ override fun getPageTitle(position: Int): CharSequence? = newTabsArray[position]
|
|
|
+
|
|
|
+ override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
|
|
+ return uiList.get(position).apply {
|
|
|
+ container.addView(
|
|
|
+ this,
|
|
|
+ ViewGroup.LayoutParams(matchParent, matchParent)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
|
|
|
+ (`object` as? View)?.let { container.removeView(it) }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun isViewFromObject(view: View, `object`: Any): Boolean = view == `object`
|
|
|
+
|
|
|
+ override fun getCount(): Int = newTabsArray.size
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //通用的消息更新通知
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ fun onMessageEvent(messageEvent : MessageEvent) {
|
|
|
+ if (messageEvent.messageType == EventConstent.FID_MoneyChangedNtf){//资金账号变化通知
|
|
|
+ viewModel.getTaAccounts()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //行情推送通知
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
|
|
|
+ val goodsids = quoteMessageEvent.goodsid
|
|
|
+ //如果推送的goodsid包含当前页面的goodsid,则进行页面刷新
|
|
|
+ if (goodsids.contains(goodsId?.toInt())) {
|
|
|
+ LogUtils.eTag("BusinessHallActivity", "行情推送" + goodsId)
|
|
|
+ val quote =
|
|
|
+ GlobalDataCollection.instance?.goodsInfoAndQuotesList?.find { goodsCode == it.outgoodscode }?.quoteDayData
|
|
|
+ if (quote != null) {
|
|
|
+ //赋值盘面信息
|
|
|
+ viewModel.quoteDayData.postValue(quote)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onDestroy() {
|
|
|
+ super.onDestroy()
|
|
|
+ viewModel.removeSubscriptQuote(thisTag)
|
|
|
+ EventBus.getDefault().unregister(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ //初始化商品信息
|
|
|
+ fun initializeData(){
|
|
|
+ viewModel.goodsInfo.postValue(DataBase.getInstance().goodsInfoDao().getGoodsInfo(goodsId?.toInt() ?: 0))
|
|
|
+ viewModel.queryQuoteDay(tag = thisTag,goodsCodes = goodsCode ?: "",isShowLoading = false)
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ initMenuData()
|
|
|
+ initializeData()
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+
|
|
|
+ createLoadingDialog(hintStr = "").bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
+
|
|
|
+ //头部标题
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.main_title_bg_color)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ imageView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ imageResource = R.mipmap.back
|
|
|
+ }.lparams(autoSize(45), autoSize(45)) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ view {
|
|
|
+
|
|
|
+ }.lparams(autoSize(45), autoSize(45)) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ viewModel.goodsInfo.bindOptional(context){
|
|
|
+ text = it?.goodsname
|
|
|
+ }
|
|
|
+ textSizeAuto = 41
|
|
|
+ textColorInt = R.color.white
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ topMargin = autoSize(10)
|
|
|
+ }
|
|
|
+ }.lparams(wrapContent, autoSize(120))
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ // TODO 挂牌
|
|
|
+ }
|
|
|
+ imageResource = R.mipmap.hnst_add_icon
|
|
|
+ }.lparams(autoSize(45), autoSize(45)) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+// val intent = Intent()
|
|
|
+// intent.putExtra("data", orderQuoteData)
|
|
|
+// intent.putExtra("type",type)
|
|
|
+// intent.setClass(context, BusinessHallDetailsActivity::class.java)
|
|
|
+// ActivityUtils.startActivity(intent)
|
|
|
+ }
|
|
|
+ imageResource = R.mipmap.business_two
|
|
|
+ }.lparams(autoSize(45), autoSize(45)) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(120))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ verticalLayout {
|
|
|
+ verticalLayout {
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.getPrice()?.toString()),2)
|
|
|
+ textColorInt = it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 58
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.rydz_price_up_icon
|
|
|
+ }.lparams(autoSize(31), autoSize(31)){
|
|
|
+ marginStart = autoSize(12)
|
|
|
+ topMargin = autoSize(25)
|
|
|
+ }
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.rydz_chart_icon
|
|
|
+ }.lparams(autoSize(36), autoSize(36)){
|
|
|
+ marginStart = autoSize(10)
|
|
|
+ topMargin = autoSize(25)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, wrapContent){
|
|
|
+ topMargin = autoSize(10)
|
|
|
+ }
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ val gainsamount = it?.getPrice()?.minus(it.preclose)
|
|
|
+ if (gainsamount ?: 0.0 > 0.0){
|
|
|
+ text = "+" + NumberUtils.roundNum(gainsamount?.toString(),2)
|
|
|
+ }else if (gainsamount ?: 0.0 < 0.0){
|
|
|
+ text = "-" + NumberUtils.roundNum(gainsamount?.toString(),2)
|
|
|
+ }else{
|
|
|
+ text = "0"
|
|
|
+ }
|
|
|
+ textColorInt = it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ val gainsamount = it?.getPrice()?.minus(it.preclose)?.div(it.preclose)
|
|
|
+ if (gainsamount ?: 0.0 > 0.0){
|
|
|
+ text = "+" + gainsamount?.toString()?.toPercentage()
|
|
|
+ }else if (gainsamount ?: 0.0 < 0.0){
|
|
|
+ text = "-" + gainsamount?.toString()?.toPercentage()
|
|
|
+ }else{
|
|
|
+ text = "0%"
|
|
|
+ }
|
|
|
+ textColorInt = it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+ }.lparams(matchParent, wrapContent)
|
|
|
+ }.lparams(matchParent, autoSize(120))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "成交量"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.turnoverShort(it?.lastvolume?.toString())
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "持仓量"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.turnoverShort(it?.holdvolume?.toString())
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "昨结"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.presettle?.toString(),2)
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "昨收"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.preclose?.toString(),2)
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ }.lparams(0, autoSize(360),1f)
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "卖价"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.ask?.toString(),2)
|
|
|
+ textColorInt = it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "买价"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.bid?.toString(),2)
|
|
|
+ textColorInt = it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "最高"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.highest?.toString(),2)
|
|
|
+ textColorInt = it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "最低"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.lowest?.toString(),2)
|
|
|
+ textColorInt = it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "涨停"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.limitup?.toString(),2)
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "跌停"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.limitdown?.toString(),2)
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_green_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+ }.lparams(0, autoSize(360),1f)
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "卖量"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.turnoverShort(it?.askvolume?.toString())
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "买量"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.turnoverShort(it?.bidvolume?.toString())
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "开盘"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.opened?.toString(),2)
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "均价"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.averageprice?.toString(),2)
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "结算"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
+ text = NumberUtils.roundNum(it?.settle?.toString(),2)
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(60))
|
|
|
+ }.lparams(0, autoSize(360),1f)
|
|
|
+ }.lparams(matchParent, autoSize(360))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ priceUpDown.postValue(priceUpDown.value?.not())
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ imageView {
|
|
|
+ priceUpDown.bindOptional(context){
|
|
|
+ if (it == true){//收起
|
|
|
+ imageResource = R.mipmap.yrdz_down_icon
|
|
|
+ }else{
|
|
|
+ imageResource = R.mipmap.yrdz_up_icon
|
|
|
+ }
|
|
|
+ }
|
|
|
+ imageResource = R.mipmap.yrdz_up_icon
|
|
|
+ }.lparams(autoSize(40), autoSize(40))
|
|
|
+ }.lparams(matchParent, autoSize(40))
|
|
|
+
|
|
|
+ tabSegment {
|
|
|
+ segment = this
|
|
|
+ background = resources.getDrawable(R.color.segtabment_bg_color)
|
|
|
+ addOnTabSelectedListener(object :
|
|
|
+ QMUITabSegment.OnTabSelectedListener {
|
|
|
+ override fun onDoubleTap(index: Int) {}
|
|
|
+ override fun onTabReselected(index: Int) {}
|
|
|
+ override fun onTabUnselected(index: Int) {}
|
|
|
+ override fun onTabSelected(index: Int) {
|
|
|
+ selectedTabIndex = index
|
|
|
+ selectIndex.postValue(index)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ setIndicator(
|
|
|
+ QMUITabIndicator(
|
|
|
+ QMUIDisplayHelper.dp2px(context, 2),
|
|
|
+ false,
|
|
|
+ true
|
|
|
+ )
|
|
|
+ )
|
|
|
+ setDefaultTextSize(ConvertUtils.sp2px(16f), ConvertUtils.sp2px(16f))
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+
|
|
|
+ view {
|
|
|
+ background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
+ }.lparams(matchParent, autoSize(1)) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(32)
|
|
|
+ }
|
|
|
+ viewPager {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ viewPager = this
|
|
|
+ adapter = newPagerAdapter
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ segment.setupWithViewPager(viewPager)
|
|
|
+ segment.selectTab(selectedTabIndex)
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 卖大厅
|
|
|
+ * @property activity AppCompatActivity
|
|
|
+ * @property viewModel BusinessHallViewModel
|
|
|
+ * @constructor
|
|
|
+ */
|
|
|
+class SellHallUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: ContractBusinessHallViewModel
|
|
|
+) {
|
|
|
+
|
|
|
+ // 下拉刷新
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ private val businessSellHallAdapter: BaseAdapter<OrderQuoteDetailData, ContractBusinessSellHallViewHolder> =
|
|
|
+ BaseAdapter { _, _ ->
|
|
|
+ ContractBusinessSellHallViewHolder(
|
|
|
+ activity,
|
|
|
+ viewModel
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.querySellDataList()
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.hnst_sell_hall_top_bg_color)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL or Gravity.LEFT
|
|
|
+ textView {
|
|
|
+ text = "价格"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(74), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "数量"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(74), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL or Gravity.RIGHT
|
|
|
+ textView {
|
|
|
+ text = "挂牌方"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(74), 1f)
|
|
|
+ }.lparams(matchParent, autoSize(74))
|
|
|
+
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+// bindTaskStatus(viewModule.status)
|
|
|
+ setRetryAction {
|
|
|
+ viewModel.querySellDataList()
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(true)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.querySellDataList()
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ // 未提交列表
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = businessSellHallAdapter
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.businessSellHallDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ businessSellHallAdapter.setNewData(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 买大厅
|
|
|
+ * @property activity AppCompatActivity
|
|
|
+ * @property viewModel BusinessHallViewModel
|
|
|
+ * @constructor
|
|
|
+ */
|
|
|
+class BuyHallUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: ContractBusinessHallViewModel
|
|
|
+) {
|
|
|
+
|
|
|
+ // 下拉刷新
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ private val businessBuyHallAdapter: BaseAdapter<OrderQuoteDetailData, ContractBusinessBuyHallViewHolder> =
|
|
|
+ BaseAdapter { _, _ ->
|
|
|
+ ContractBusinessBuyHallViewHolder(
|
|
|
+ activity,
|
|
|
+ viewModel
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.queryBuyDataList()
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.hnst_buy_hall_top_bg_color)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL or Gravity.LEFT
|
|
|
+ textView {
|
|
|
+ text = "价格"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(74), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "数量"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(74), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL or Gravity.RIGHT
|
|
|
+ textView {
|
|
|
+ text = "挂牌方"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(74), 1f)
|
|
|
+ }.lparams(matchParent, autoSize(74))
|
|
|
+
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+// bindTaskStatus(viewModule.status)
|
|
|
+ setRetryAction {
|
|
|
+ viewModel.queryBuyDataList()
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(true)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.queryBuyDataList()
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ // 未提交列表
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = businessBuyHallAdapter
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.businessBuyHallDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ businessBuyHallAdapter.setNewData(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|