소스 검색

行情数据刷新问题

yu.jie 3 년 전
부모
커밋
3f244a90c4
1개의 변경된 파일108개의 추가작업 그리고 66개의 파일을 삭제
  1. 108 66
      RMA/app/src/main/java/cn/muchinfo/rma/view/base/hnstmain/HnstMainFragment.kt

+ 108 - 66
RMA/app/src/main/java/cn/muchinfo/rma/view/base/hnstmain/HnstMainFragment.kt

@@ -92,7 +92,7 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
             viewModel.queryContractTradePosition("2")
             viewModel.getUserAccount()
             viewModel.resetAccountData()
-        } else if (messageEvent.messageType == EventConstent.FID_OrderDealedNtf){
+        } else if (messageEvent.messageType == EventConstent.FID_OrderDealedNtf) {
             viewModel.queryContractTradePosition("2")
         }
     }
@@ -110,7 +110,7 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
 
                 // resolve bug  #3429
                 // 减少频率
-                if(TimeUtils.getNowMills() - requestTime > 1500){
+                if (TimeUtils.getNowMills() - requestTime > 1500) {
                     viewModel.getUserAccount()
                     viewModel.resetAccountData()
                     requestTime = TimeUtils.getNowMills()
@@ -119,7 +119,9 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
             }
         }
     }
+
     private var requestTime = TimeUtils.getNowMills()
+
     @SuppressLint("MissingPermission", "RtlHardcoded", "SetTextI18n")
     override fun onCreateView(
         inflater: LayoutInflater,
@@ -295,7 +297,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
 
                         linearLayout {
                             visibility =
-                                if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                if (SPUtils.getInstance()
+                                        .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                        .getString(Constant.oem) == "xhcp"
+                                ) {
                                     View.GONE
                                 } else {
                                     View.VISIBLE
@@ -413,7 +418,8 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                                 gravity = Gravity.LEFT
                                 textView {
                                     text = if (SPUtils.getInstance()
-                                            .getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp"
+                                            .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                            .getString(Constant.oem) == "xhcp"
                                     ) {
                                         "净值"
                                     } else {
@@ -432,7 +438,8 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                                     viewModel.usedAccountData.bindOptional(context) {
                                         if (isOpenEye.value == true) {
                                             if (SPUtils.getInstance()
-                                                    .getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp"
+                                                    .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                                    .getString(Constant.oem) == "xhcp"
                                             ) {
                                                 val parmasvalue =
                                                     GlobalDataCollection.instance?.getSystemParamsValue(
@@ -484,7 +491,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                         //狗屎一样的设计,,,,,fuck
                         linearLayout {
                             visibility =
-                                if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                if (SPUtils.getInstance()
+                                        .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                        .getString(Constant.oem) == "xhcp"
+                                ) {
                                     View.VISIBLE
                                 } else {
                                     View.GONE
@@ -494,7 +504,8 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                                 gravity = Gravity.LEFT
                                 textView {
                                     text = if (SPUtils.getInstance()
-                                            .getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp"
+                                            .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                            .getString(Constant.oem) == "xhcp"
                                     ) {
                                         "净值"
                                     } else {
@@ -514,15 +525,16 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                                     viewModel.usedAccountData.bindOptional(context) {
                                         if (isOpenEye.value == true) {
                                             if (SPUtils.getInstance()
-                                                    .getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp"
+                                                    .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                                    .getString(Constant.oem) == "xhcp"
                                             ) {
                                                 val parmasvalue =
                                                     GlobalDataCollection.instance?.getSystemParamsValue(
                                                         "307"
                                                     )
-                                                if(it != null){
-                                                    it!!.postValueOfPosition.bindOptional(context){ its ->
-                                                        if(its != null) {
+                                                if (it != null) {
+                                                    it!!.postValueOfPosition.bindOptional(context) { its ->
+                                                        if (its != null) {
                                                             if (parmasvalue == "1") {//1.净值=期末余额+市值+浮动盈亏(收益权)-其他冻结-出金冻结
                                                                 text = NumberUtils.roundNum(
                                                                     NumberUtils.doubleDistortion(
@@ -685,7 +697,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
 
                         linearLayout {
                             visibility =
-                                if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                if (SPUtils.getInstance()
+                                        .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                        .getString(Constant.oem) == "xhcp"
+                                ) {
                                     View.VISIBLE
                                 } else {
                                     View.GONE
@@ -760,34 +775,38 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                                             if (text.toString().trim() == "****") {
                                                 text = NumberUtils.roundNum(
                                                     NumberUtils.doubleDistortion(it?.valueOfposition_keep_watch_profit_and_loss?.toString()),
-                                                        2
+                                                    2
                                                 )
                                             }
 
-                                                var lastprice: Double? = 0.0
-
-                                                it!!.postValueOfPosition.bindOptional(context){ its ->
-                                                    if(its != lastprice || (its == lastprice && lastprice == 0.0)){
-                                                        lastprice = its
-                                                        text = NumberUtils.roundNum(
-                                                            NumberUtils.doubleDistortion(its?.toString()),
-                                                            2
-                                                        )
+                                            var lastprice: Double? = 0.0
+                                            if (it != null) {
+                                                it!!.postValueOfPosition.bindOptional(context) { its ->
+                                                    if(its != null) {
+                                                        if (its != lastprice || (its == lastprice && lastprice == 0.0)) {
+                                                            lastprice = its
+                                                            text = NumberUtils.roundNum(
+                                                                NumberUtils.doubleDistortion(its?.toString()),
+                                                                2
+                                                            )
 
-                                                        textColorInt = when {
-                                                            its ?: 0.0 > 0.0 -> {
-                                                                R.color.rma_red_color
-                                                            }
-                                                            its ?: 0.0 < 0.0 -> {
-                                                                R.color.rma_green_color
-                                                            }
-                                                            else -> {
-                                                                R.color.rma_black_33
+                                                            textColorInt = when {
+                                                                its ?: 0.0 > 0.0 -> {
+                                                                    R.color.rma_red_color
+                                                                }
+                                                                its ?: 0.0 < 0.0 -> {
+                                                                    R.color.rma_green_color
+                                                                }
+                                                                else -> {
+                                                                    R.color.rma_black_33
+                                                                }
                                                             }
                                                         }
                                                     }
                                                 }
-//                                            }
+                                            }
+
+//
 
 
                                         } else {
@@ -817,40 +836,44 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                                      */
                                     viewModel.usedAccountData.bindOptional(context) {
                                         if (isOpenEye.value == true) {
-                                            if(it != null) {
+                                            if (it != null) {
                                                 it!!.postValueOfPosition.bindOptional(context) { its ->
 ///// 0 - 占用/净值  1 - 净值/占用
-                                                    val parmasvalue =
-                                                        GlobalDataCollection.instance?.getSystemParamsValue(
-                                                            "087"
-                                                        )
-                                                    val worth: Double
-                                                    worth =
-                                                        if (parmasvalue == "1") {//1.风险净值=期末余额+市值+浮动盈亏(收益权)-其他冻结-出金冻结
-                                                            it?.currentbalance?.plus(
-                                                                it.valueOfposition
+                                                    if (its != null) {
+                                                        val parmasvalue =
+                                                            GlobalDataCollection.instance?.getSystemParamsValue(
+                                                                "087"
                                                             )
-                                                                ?.plus(it.valueOfposition_keep_watch_profit_and_loss)
-                                                                ?.minus(it.otherfreezemargin)
-                                                                ?.minus(it.outamountfreeze) ?: 0.0
+                                                        val worth: Double
+                                                        worth =
+                                                            if (parmasvalue == "1") {//1.风险净值=期末余额+市值+浮动盈亏(收益权)-其他冻结-出金冻结
+                                                                it?.currentbalance?.plus(
+                                                                    it.valueOfposition
+                                                                )
+                                                                    ?.plus(its)
+                                                                    ?.minus(it.otherfreezemargin)
+                                                                    ?.minus(it.outamountfreeze)
+                                                                    ?: 0.0
 
 
-                                                        } else {//0.净值=期末余额+浮动盈亏(收益权)-其他冻结-出金冻结
-                                                            it?.currentbalance?.plus(it.valueOfposition_keep_watch_profit_and_loss)
-                                                                ?.minus(it.otherfreezemargin)
-                                                                ?.minus(it.outamountfreeze) ?: 1.0
-                                                        }
+                                                            } else {//0.净值=期末余额+浮动盈亏(收益权)-其他冻结-出金冻结
+                                                                it?.currentbalance?.plus(its)
+                                                                    ?.minus(it.otherfreezemargin)
+                                                                    ?.minus(it.outamountfreeze)
+                                                                    ?: 1.0
+                                                            }
 
-                                                    var risk = 0.0
+                                                        var risk = 0.0
 //                                            if (it?.valueOfposition != 0.0) {
-                                                    if (worth != 0.0) {
-                                                        risk = it?.usedmargin?.div(worth) ?: 0.0
-                                                    }
+                                                        if (worth != 0.0) {
+                                                            risk = it?.usedmargin?.div(worth) ?: 0.0
+                                                        }
 //                                            text = NumberUtils.roundNum(
 //                                                NumberUtils.doubleDistortion(risk.toString()), 4
 //                                            ).toPercentage2()
 
-                                                    text = risk.toString().toPercentage2()
+                                                        text = risk.toString().toPercentage2()
+                                                    }
                                                 }
                                             }
                                         } else {
@@ -953,7 +976,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                             //预售仓单
                             verticalLayout {
                                 visibility =
-                                    if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                    if (SPUtils.getInstance()
+                                            .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                            .getString(Constant.oem) == "xhcp"
+                                    ) {
                                         View.GONE//任务 2621
                                     } else {
                                         View.VISIBLE
@@ -982,7 +1008,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
                             //商品订单
                             verticalLayout {
                                 visibility =
-                                    if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                    if (SPUtils.getInstance()
+                                            .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                            .getString(Constant.oem) == "xhcp"
+                                    ) {
                                         View.GONE//任务 2621
                                     } else {
                                         View.VISIBLE
@@ -1011,11 +1040,12 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
 
                             //掉期订单
                             verticalLayout {
-                                visibility = if (SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
-                                    View.GONE
-                                } else {
-                                    View.VISIBLE
-                                }
+                                visibility =
+                                    if (SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                        View.GONE
+                                    } else {
+                                        View.VISIBLE
+                                    }
                                 onThrottleFirstClick {
                                     val intent = Intent()
                                     intent.putExtra("type", "2")
@@ -1121,7 +1151,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
 
                         linearLayout {
                             visibility =
-                                if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                if (SPUtils.getInstance()
+                                        .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                        .getString(Constant.oem) == "xhcp"
+                                ) {
                                     View.GONE//任务 2621
                                 } else {
                                     View.VISIBLE
@@ -1176,7 +1209,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
 
                         linearLayout {
                             visibility =
-                                if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                if (SPUtils.getInstance()
+                                        .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                        .getString(Constant.oem) == "xhcp"
+                                ) {
                                     View.GONE//任务 2621
                                 } else {
                                     View.VISIBLE
@@ -1287,7 +1323,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
 
                         linearLayout {
                             visibility =
-                                if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                if (SPUtils.getInstance()
+                                        .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                        .getString(Constant.oem) == "xhcp"
+                                ) {
                                     View.GONE//任务 2621
                                 } else {
                                     View.VISIBLE
@@ -1391,7 +1430,10 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
 
                         linearLayout {
                             visibility =
-                                if (SPUtils.getInstance().getString(Constant.oem) == "tjmd" || SPUtils.getInstance().getString(Constant.oem) == "xhcp") {
+                                if (SPUtils.getInstance()
+                                        .getString(Constant.oem) == "tjmd" || SPUtils.getInstance()
+                                        .getString(Constant.oem) == "xhcp"
+                                ) {
                                     View.VISIBLE
                                 } else {
                                     View.GONE