|
@@ -0,0 +1,307 @@
|
|
|
|
|
+package cn.muchinfo.rma.view.base.hnstmain.contractorders.unwind
|
|
|
|
|
+
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
|
|
+import android.os.Bundle
|
|
|
|
|
+import android.view.Gravity
|
|
|
|
|
+import androidx.recyclerview.widget.RecyclerView
|
|
|
|
|
+import cn.muchinfo.rma.R
|
|
|
|
|
+import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
|
|
+import cn.muchinfo.rma.global.data.ContractTradePositionData
|
|
|
|
|
+import cn.muchinfo.rma.global.data.TradeHolderDetailData
|
|
|
|
|
+import cn.muchinfo.rma.global.database.DataBase
|
|
|
|
|
+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.autoWidget.view.MangeNumberEditText2
|
|
|
|
|
+import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
|
|
+import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
|
|
+import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
|
|
|
|
|
+import com.blankj.utilcode.util.LogUtils
|
|
|
|
|
+import com.blankj.utilcode.util.ToastUtils
|
|
|
|
|
+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.*
|
|
|
|
|
+
|
|
|
|
|
+class ContractUnWindActivity : BaseActivity<ContractUnWindViewModel>(){
|
|
|
|
|
+
|
|
|
|
|
+ // 下拉刷新
|
|
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
|
|
+ private lateinit var agreement_recyclerView: RecyclerView
|
|
|
|
|
+
|
|
|
|
|
+ //合约汇总实体
|
|
|
|
|
+ val data by lazy { intent.getParcelableExtra<ContractTradePositionData>("data") as ContractTradePositionData }
|
|
|
|
|
+
|
|
|
|
|
+ //
|
|
|
|
|
+ private val agreementUnwindAdapter: BaseAdapter<TradeHolderDetailData, ContractUnwindViewHolder> =
|
|
|
|
|
+ BaseAdapter { _, _ ->
|
|
|
|
|
+ ContractUnwindViewHolder(
|
|
|
|
|
+ this,
|
|
|
|
|
+ viewModel
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ val thisTag by lazy {
|
|
|
|
|
+ "ContractUnWindActivity"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 输入的协议价
|
|
|
|
|
+ */
|
|
|
|
|
+ lateinit var agrement_price_edittext: MangeNumberEditText2
|
|
|
|
|
+
|
|
|
|
|
+ override fun onDestroy() {
|
|
|
|
|
+ super.onDestroy()
|
|
|
|
|
+ EventBus.getDefault().unregister(this)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
|
|
+ fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
|
|
|
|
|
+ /** 行情推送过来的goodsid **/
|
|
|
|
|
+ quoteMessageEvent.goodsid.forEach { goodid ->
|
|
|
|
|
+ LogUtils.eTag("dadafafsjhdkjahkjdhak", goodid)
|
|
|
|
|
+ //找到相应商品信息
|
|
|
|
|
+ val goodsInfo =
|
|
|
|
|
+ viewModel.agreementDataList.value?.find { it.refgoodsid?.toInt() == goodid }
|
|
|
|
|
+ viewModel.agreementDataList.value?.indexOf(goodsInfo)?.let {
|
|
|
|
|
+ if (it != -1) {//刷新相应item
|
|
|
|
|
+ agreement_recyclerView.adapter?.notifyItemChanged(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //选择了相应的单据
|
|
|
|
|
+ if (viewModel.agreementData.value?.refgoodsid.isNullOrEmpty().not()){
|
|
|
|
|
+ if (goodid == viewModel.agreementData.value?.refgoodsid?.toInt()){
|
|
|
|
|
+ val selectQuoteDayData = GlobalDataCollection.instance?.goodsInfoAndQuotesList?.find {
|
|
|
|
|
+ it?.outgoodscode == viewModel.agreementData.value?.refgoodscode
|
|
|
|
|
+ }
|
|
|
|
|
+ viewModel.quoteDayData.postValue(selectQuoteDayData?.quoteDayData)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
|
|
+
|
|
|
|
|
+ EventBus.getDefault().register(this)
|
|
|
|
|
+ verticalLayout {
|
|
|
|
|
+ viewModel.queryTradeHolderDetail(data = data,tag = thisTag)
|
|
|
|
|
+ createLoadingDialog(hintStr = "").bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
|
|
+ topBar {
|
|
|
|
|
+ commonLeftButton()
|
|
|
|
|
+ commonTitle {
|
|
|
|
|
+ text = "协议平仓"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ background = resources.getDrawable(R.color.yrdz_delivery_title_bg_color)
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "合约:" + data.goodscode + "/" + data.goodsname
|
|
|
|
|
+ textSizeAuto = 32
|
|
|
|
|
+ textColorInt = R.color.qhj_blue_text_color
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(matchParent, autoSize(70))
|
|
|
|
|
+
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "选择持仓单"
|
|
|
|
|
+ textSizeAuto = 34
|
|
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ itemView()
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "持仓单号/方向"
|
|
|
|
|
+ textSizeAuto = 29
|
|
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(0, autoSize(70), 1f)
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "数量/价格/金额"
|
|
|
|
|
+ textSizeAuto = 29
|
|
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
|
|
+ }.lparams(0, autoSize(70), 1f)
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL or Gravity.RIGHT
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "到期日/盈亏"
|
|
|
|
|
+ textSizeAuto = 29
|
|
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
|
|
+ marginEnd = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(0, autoSize(70), 1f)
|
|
|
|
|
+ }.lparams(matchParent, autoSize(70))
|
|
|
|
|
+
|
|
|
|
|
+ frameLayout {
|
|
|
|
|
+ verticalLayout {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ statusLayout(contentBlock = {
|
|
|
|
|
+ statusLayout = this
|
|
|
|
|
+ swipeToLoadLayout {
|
|
|
|
|
+ swipeToLayout = this
|
|
|
|
|
+ setEnableRefresh(false)
|
|
|
|
|
+ setEnableLoadMore(false)
|
|
|
|
|
+ setOnRefreshListener {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
|
|
+
|
|
|
|
|
+ // 未提交列表
|
|
|
|
|
+ recyclerView {
|
|
|
|
|
+ agreement_recyclerView = this
|
|
|
|
|
+ background = resources.getDrawable(R.color.segtabment_bg_color)
|
|
|
|
|
+ adapter = agreementUnwindAdapter
|
|
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
|
|
+ }
|
|
|
|
|
+ }, emptyBlock = {
|
|
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
|
|
+
|
|
|
|
|
+ viewModel.agreementDataList.bindOptional(context) {
|
|
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
|
|
+ statusLayout.showEmpty()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
|
|
+ }
|
|
|
|
|
+ statusLayout.showSuccess()
|
|
|
|
|
+ agreementUnwindAdapter.setNewData(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }.lparams(matchParent, matchParent) {
|
|
|
|
|
+ bottomMargin = autoSize(340)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ verticalLayout {
|
|
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "估算价:"
|
|
|
|
|
+ textSizeAuto = 31
|
|
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(autoSize(250), autoSize(100))
|
|
|
|
|
+
|
|
|
|
|
+ textView {
|
|
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
|
|
+ if (it?.getPrice() == 0.0){
|
|
|
|
|
+ text = "--"
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if (viewModel.agreementData.value?.refgoodsid.isNullOrEmpty()){
|
|
|
|
|
+ text = "--"
|
|
|
|
|
+ }else{
|
|
|
|
|
+ text = NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.getPrice().toString()),2)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ textSizeAuto = 31
|
|
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
|
|
+ marginStart = autoSize(32)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(matchParent, autoSize(140))
|
|
|
|
|
+
|
|
|
|
|
+ itemView()
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ verticalLayout {
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "估算金额"
|
|
|
|
|
+ textSizeAuto = 29
|
|
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
|
|
+ topMargin = autoSize(30)
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ textView {
|
|
|
|
|
+ viewModel.quoteDayData.bindOptional(context){
|
|
|
|
|
+ if (it?.getPrice() == 0.0){
|
|
|
|
|
+ text = "--"
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if (viewModel.agreementData.value?.refgoodsid.isNullOrEmpty()){
|
|
|
|
|
+ text = "--"
|
|
|
|
|
+ }else{
|
|
|
|
|
+ text = NumberUtils.roundNum(NumberUtils.doubleDistortion(it?.getPrice()?.times(viewModel.agreementData.value?.holderqty?.toInt() ?: 0).toString()),2)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ text = "--"
|
|
|
|
|
+ textSizeAuto = 34
|
|
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ topMargin = autoSize(10)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(0, autoSize(144),1f)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ textView {
|
|
|
|
|
+ onThrottleFirstClick {
|
|
|
|
|
+ if (viewModel.agreementData.value?.accountid.isNullOrEmpty()) {
|
|
|
|
|
+ ToastUtils.showLong("请选择需要进行协议平仓的单据")
|
|
|
|
|
+ return@onThrottleFirstClick
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ val applyData = viewModel.agreementData.value
|
|
|
|
|
+ viewModel.HolderCloseReq(
|
|
|
|
|
+ GoodsID = applyData?.goodsid?.toInt() ?: 0,
|
|
|
|
|
+ MarketID = applyData?.marketid?.toInt() ?: 0,
|
|
|
|
|
+ TradeID = applyData?.tradeid?.toLong() ?: 0,
|
|
|
|
|
+ BuyOrSell = applyData?.buyorsell?.toInt() ?: 0
|
|
|
|
|
+ ) {
|
|
|
|
|
+ finish()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ text = "平仓"
|
|
|
|
|
+ gravity = Gravity.CENTER
|
|
|
|
|
+ textSizeAuto = 36
|
|
|
|
|
+ textColorInt = R.color.white
|
|
|
|
|
+ backgroundResource = R.drawable.rydz_main_red_bg
|
|
|
|
|
+ }.lparams(autoSize(268), autoSize(96)){
|
|
|
|
|
+ marginEnd = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }.lparams(matchParent, autoSize(144))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }.lparams(matchParent, wrapContent) {
|
|
|
|
|
+ gravity = Gravity.BOTTOM
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|