|
|
@@ -0,0 +1,272 @@
|
|
|
+package cn.muchinfo.rma.view.base.future.holds
|
|
|
+
|
|
|
+import android.os.Bundle
|
|
|
+import android.view.Gravity
|
|
|
+import android.view.View
|
|
|
+import androidx.lifecycle.MutableLiveData
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.data.futureOrders.DealOrderData
|
|
|
+import cn.muchinfo.rma.global.data.futureOrders.FutureHoldData
|
|
|
+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.future.trade.itemView
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.emptyView
|
|
|
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
|
|
|
+import mtp.polymer.com.autowidget.dialog.createLoadingDialog
|
|
|
+import mtp.polymer.com.autowidget.dialog.createWarningDialog
|
|
|
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
+import org.jetbrains.anko.*
|
|
|
+
|
|
|
+class HoldDetailsActivity : BaseActivity<HoldDetailsViewModel>() {
|
|
|
+
|
|
|
+ /** 用于订阅行情的唯一标识 */
|
|
|
+ val thisTag by lazy {
|
|
|
+ "goodtradeorderHoldDetails"
|
|
|
+ }
|
|
|
+
|
|
|
+ private val dialog by lazy { createLoadingDialog(hintStr = "请求中...") }
|
|
|
+
|
|
|
+ val data: FutureHoldData by lazy {
|
|
|
+ intent.getParcelableExtra<FutureHoldData>("data") as FutureHoldData
|
|
|
+ }
|
|
|
+
|
|
|
+ val lifeData : MutableLiveData<FutureHoldData> = MutableLiveData()
|
|
|
+
|
|
|
+ private val holdDetailsAdapter: BaseAdapter<DealOrderData, HoldDetailsViewHolder> =
|
|
|
+ BaseAdapter { _, _ -> HoldDetailsViewHolder(this) }
|
|
|
+
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.queryHedgeTradeDetails(data.goodsid, data.buyorsell)
|
|
|
+ dialog.bindTaskStatus(context,viewModel.loadingDialogStatus)
|
|
|
+ viewModel.queryQuoteDay(tag = thisTag,goodsCodes = data.outgoodscode ?: ""){
|
|
|
+ data.calculate()
|
|
|
+ lifeData.postValue(data)
|
|
|
+ }
|
|
|
+
|
|
|
+ topBar {
|
|
|
+ commonLeftButton()
|
|
|
+ commonTitle {
|
|
|
+ text = "订单详情(持仓)"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ frameLayout {
|
|
|
+ nestedScrollView {
|
|
|
+ verticalLayout {
|
|
|
+ HoldDetailsItemView(
|
|
|
+ itemTitle = "合约名称",
|
|
|
+ itemContent = data.goodsname ?: "--"
|
|
|
+ )
|
|
|
+ itemView()
|
|
|
+ HoldDetailsItemView(
|
|
|
+ itemTitle = "今仓/总仓数量",
|
|
|
+ itemContent = data.curtdposition.toString() + "/" + data.curpositionqty
|
|
|
+ )
|
|
|
+ itemView()
|
|
|
+ HoldDetailsItemView(
|
|
|
+ itemTitle = "今仓/总仓可用",
|
|
|
+ itemContent = data.curtdposition.toString() + "/" + data.enableqty
|
|
|
+ )
|
|
|
+ itemView()
|
|
|
+ HoldDetailsItemView(
|
|
|
+ itemTitle = "开仓均价(CNY)",
|
|
|
+ itemContent = data.openaverageprice.toString()
|
|
|
+ )
|
|
|
+ itemView()
|
|
|
+ HoldDetailsItemView(
|
|
|
+ itemTitle = "持仓均价(CNY)",
|
|
|
+ itemContent = data.positionaverageprice.toString()
|
|
|
+ )
|
|
|
+ itemView()
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "逐笔浮盈(CNY)"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_title_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ lifeData.bindOptional(context){
|
|
|
+ if (it?.openpl ?: 0.0 < 0) {
|
|
|
+ textColorInt = R.color.rma_green_color
|
|
|
+ } else if (it?.openpl ?: 0.0 > 0) {
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ } else {
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }
|
|
|
+ text = NumberUtils.roundNum(it?.openpl?.toString(),2)
|
|
|
+ }
|
|
|
+ if (data.openpl < 0) {
|
|
|
+ textColorInt = R.color.rma_green_color
|
|
|
+ } else if (data.openpl > 0) {
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ } else {
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }
|
|
|
+ text = NumberUtils.roundNum(data.openpl.toString(),2)
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+ itemView()
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "盯市浮盈(CNY)"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_title_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ lifeData.bindOptional(context){
|
|
|
+ if (it?.positionpl ?: 0.0 < 0) {
|
|
|
+ textColorInt = R.color.rma_green_color
|
|
|
+ } else if (it?.positionpl ?: 0.0 > 0) {
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ } else {
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }
|
|
|
+ text = NumberUtils.roundNum(it?.positionpl?.toString(),2)
|
|
|
+ }
|
|
|
+ if (data.positionpl < 0) {
|
|
|
+ textColorInt = R.color.rma_green_color
|
|
|
+ } else if (data.positionpl > 0) {
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ } else {
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }
|
|
|
+ text = NumberUtils.roundNum(data.positionpl.toString(),2)
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+ itemView()
|
|
|
+ HoldDetailsItemView(
|
|
|
+ itemTitle = "交易所",
|
|
|
+ itemContent = data.exexchangename ?: "--"
|
|
|
+ )
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ text = "成交时间"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 30
|
|
|
+ }.lparams(0, wrapContent, 1f)
|
|
|
+
|
|
|
+ textView {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ text = "成交数量"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 30
|
|
|
+ }.lparams(0, wrapContent, 1f)
|
|
|
+
|
|
|
+ textView {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ text = "成交价格(CNY)"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 30
|
|
|
+ }.lparams(0, wrapContent, 1f)
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = holdDetailsAdapter
|
|
|
+ isNestedScrollingEnabled = false
|
|
|
+ }.lparams(matchParent, wrapContent)
|
|
|
+
|
|
|
+ viewModel.dealOrderList.bindOptional(context) {
|
|
|
+ holdDetailsAdapter.setNewData(it)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ if (data.enableqty > 0) {
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ } else {
|
|
|
+ visibility = View.GONE
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ createWarningDialog {
|
|
|
+ setTitle("平仓")
|
|
|
+ setMessage("确认对此持仓单进行平仓操作吗?")
|
|
|
+ addAction("取消") { dialog, _ -> dialog.dismiss() }
|
|
|
+ addAction("确定") { dialog, _ ->
|
|
|
+ viewModel.commitDealData(data, true){
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ }.show()
|
|
|
+
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ backgroundResource = R.mipmap.rma_submit_bg
|
|
|
+ text = "平仓"
|
|
|
+ textColorInt = R.color.white
|
|
|
+ textSizeAuto = 38
|
|
|
+ }.lparams(matchParent, autoSize(119)) {
|
|
|
+ marginStart = autoSize(59)
|
|
|
+ marginEnd = autoSize(59)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(144)) {
|
|
|
+ gravity = Gravity.BOTTOM
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+fun _LinearLayout.HoldDetailsItemView(itemTitle: String, itemContent: String) {
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = itemTitle
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_hint_title_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = itemContent
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(90))
|
|
|
+
|
|
|
+}
|