|
|
@@ -0,0 +1,632 @@
|
|
|
+package cn.muchinfo.rma.view.base.yrdzpurchase.swaps.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 android.widget.ImageView
|
|
|
+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.*
|
|
|
+import cn.muchinfo.rma.global.data.OrderQuoteData
|
|
|
+import cn.muchinfo.rma.global.data.WrTradeOrderDetailData
|
|
|
+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.base.BaseActivity
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.emptyView
|
|
|
+import cn.muchinfo.rma.view.base.warehousereceipt.BusinessHallDetailsActivity
|
|
|
+import cn.muchinfo.rma.view.base.yrdzpurchase.listed.PurchaseListedActivity
|
|
|
+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 SwapsBusinessHallActivity : BaseActivity<SwapsBusinessHallViewModel>() {
|
|
|
+
|
|
|
+ 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") }
|
|
|
+
|
|
|
+ //价格涨跌的上下箭头
|
|
|
+ lateinit var updowm_image : ImageView
|
|
|
+
|
|
|
+ //顶部数据是否展开
|
|
|
+ val priceUpDown: MutableLiveData<Boolean> = MutableLiveData<Boolean>().apply { value = false }
|
|
|
+
|
|
|
+ /** 用于订阅行情的唯一标识 */
|
|
|
+ val thisTag by lazy {
|
|
|
+ "ContractBusinessHallActivity"
|
|
|
+ }
|
|
|
+
|
|
|
+ //买大厅
|
|
|
+ val buyHallUI by lazy { SwapsBuyHallUI(this, viewModel, goodsId ?: "", goodsCode ?: "") }
|
|
|
+
|
|
|
+ //卖大厅
|
|
|
+ val sellHallUI by lazy { SwapsSellHallUI(this, viewModel, goodsId ?: "", goodsCode ?: "") }
|
|
|
+
|
|
|
+ //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)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ override fun onResume() {
|
|
|
+ super.onResume()
|
|
|
+ viewModel.queryBuyDataList(goodsid = goodsId ?: "")
|
|
|
+ viewModel.querySellDataList(goodsid = goodsId ?: "")
|
|
|
+ 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 {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.putExtra("goodsId", goodsId)
|
|
|
+ intent.putExtra("goodsCode", goodsCode)
|
|
|
+ intent.setClass(context, PurchaseListedActivity::class.java)
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ }
|
|
|
+ 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("isCircle","0")
|
|
|
+ intent.putExtra("type", "3")
|
|
|
+ intent.putExtra("goodsId", goodsId)
|
|
|
+ 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 {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "卖价"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ emptyView()
|
|
|
+
|
|
|
+ textView {
|
|
|
+ viewModel.quoteDayData.bindOptional(context) {
|
|
|
+ text = NumberUtils.roundNum(it?.ask?.toString(), 2)?.isZeroBlankString()
|
|
|
+ textColorInt =
|
|
|
+ it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(70),1f)
|
|
|
+
|
|
|
+ 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())?.isZeroBlankString()
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(70),1f)
|
|
|
+
|
|
|
+ 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)?.isZeroBlankString()
|
|
|
+ textColorInt =
|
|
|
+ it?.getPrecloseColor()?.colorType() ?: R.color.rma_black_33
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(70),1f)
|
|
|
+
|
|
|
+ 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())?.isZeroBlankString()
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(70),1f)
|
|
|
+ }.lparams(matchParent, autoSize(70))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "标的"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "IC2014"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_gray_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "1312"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "+90"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "+1.28%"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.rma_red_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(70))
|
|
|
+
|
|
|
+ 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(18f))
|
|
|
+ }.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 SwapsSellHallUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: SwapsBusinessHallViewModel,
|
|
|
+ private val goodsId: String,
|
|
|
+ private val goodsCode: String
|
|
|
+) {
|
|
|
+
|
|
|
+ // 下拉刷新
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ private val businessSellHallAdapter: BaseAdapter<WrTradeOrderDetailData, SwapsBusinessSellHallViewHolder> =
|
|
|
+ BaseAdapter { _, _ ->
|
|
|
+ SwapsBusinessSellHallViewHolder(
|
|
|
+ activity,
|
|
|
+ viewModel,
|
|
|
+ goodsCode
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.querySellDataList(goodsid = goodsId)
|
|
|
+ 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(goodsid = goodsId)
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(true)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.querySellDataList(goodsid = goodsId)
|
|
|
+ }
|
|
|
+ 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 SwapsBuyHallUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: SwapsBusinessHallViewModel,
|
|
|
+ private val goodsId: String,
|
|
|
+ private val goodsCode: String
|
|
|
+) {
|
|
|
+
|
|
|
+ // 下拉刷新
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ private val businessBuyHallAdapter: BaseAdapter<WrTradeOrderDetailData, SwapsBusinessBuyHallViewHolder> =
|
|
|
+ BaseAdapter { _, _ ->
|
|
|
+ SwapsBusinessBuyHallViewHolder(
|
|
|
+ activity,
|
|
|
+ viewModel,
|
|
|
+ goodsCode
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.queryBuyDataList(goodsid = goodsId)
|
|
|
+ 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(goodsid = goodsId)
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(true)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.queryBuyDataList(goodsid = goodsId)
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|