|
|
@@ -1,13 +1,779 @@
|
|
|
package cn.muchinfo.rma.view.base.hnstmain.contractorders
|
|
|
|
|
|
+import android.os.Build
|
|
|
+import android.os.Bundle
|
|
|
+import android.view.Gravity
|
|
|
+import android.view.MotionEvent
|
|
|
+import android.view.View
|
|
|
+import android.view.ViewGroup
|
|
|
+import androidx.annotation.RequiresApi
|
|
|
+import androidx.appcompat.app.AppCompatActivity
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
+import androidx.recyclerview.widget.RecyclerView
|
|
|
+import androidx.viewpager.widget.PagerAdapter
|
|
|
+import androidx.viewpager.widget.ViewPager
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
+import cn.muchinfo.rma.view.autoWidget.*
|
|
|
import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
+import cn.muchinfo.rma.view.base.app.Constant
|
|
|
+import cn.muchinfo.rma.view.base.hnstmain.contractorders.adapter.ContractDeliveryContentAdapter
|
|
|
+import cn.muchinfo.rma.view.base.hnstmain.contractorders.adapter.ContractOrderContentAdapter
|
|
|
+import cn.muchinfo.rma.view.base.hnstmain.contractorders.adapter.ContractPositionContentAdapter
|
|
|
+import cn.muchinfo.rma.view.base.hnstmain.contractorders.adapter.ContractTraderContentAdapter
|
|
|
+import cn.muchinfo.rma.view.base.procurement.TopTabAdpater
|
|
|
+import com.blankj.utilcode.util.ConvertUtils
|
|
|
+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.dialog.createLoadingDialog
|
|
|
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
+import org.jetbrains.anko.*
|
|
|
+import org.jetbrains.anko.support.v4.viewPager
|
|
|
|
|
|
/**
|
|
|
* 合约订单页面
|
|
|
*/
|
|
|
class ContractOrdersActivity : BaseActivity<ContractOrdersViewModel>(){
|
|
|
|
|
|
+ lateinit var segment: QMUITabSegment
|
|
|
+ var selectedTabIndex: Int = 0
|
|
|
+ private lateinit var viewPager: ViewPager
|
|
|
|
|
|
+ //合约汇总单
|
|
|
+ val positionUI by lazy { PositionUI(this,viewModel) }
|
|
|
+
|
|
|
+ //委托单
|
|
|
+ val orderUI by lazy { OrderUI(this,viewModel) }
|
|
|
+
|
|
|
+ //成交单
|
|
|
+ val traderUI by lazy { TraderUI(this,viewModel) }
|
|
|
+
|
|
|
+ //交收单
|
|
|
+ val deliveryUI by lazy { DeliveryUI(this,viewModel) }
|
|
|
+
|
|
|
+ //viewpager的适配器
|
|
|
+ private var newPagerAdapter : PagerAdapter? = null
|
|
|
+
|
|
|
+ //tabSegment标题
|
|
|
+ private val newTabsArray : ArrayList<String> = arrayListOf()
|
|
|
+
|
|
|
+ //暂存的页面组
|
|
|
+ private val uiList : ArrayList<_FrameLayout> = arrayListOf()
|
|
|
+
|
|
|
+ fun initMenuData(){
|
|
|
+
|
|
|
+ newTabsArray.add("订单汇总")
|
|
|
+ uiList.add(positionUI.root)
|
|
|
+
|
|
|
+ newTabsArray.add("委托")
|
|
|
+ uiList.add(orderUI.root)
|
|
|
+
|
|
|
+ newTabsArray.add("成交")
|
|
|
+ uiList.add(traderUI.root)
|
|
|
+
|
|
|
+ newTabsArray.add("交收")
|
|
|
+ uiList.add(deliveryUI.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
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ verticalLayout {
|
|
|
+ createLoadingDialog(hintStr = "").bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
+ initMenuData()
|
|
|
+ topBar {
|
|
|
+ commonLeftButton()
|
|
|
+ commonTitle {
|
|
|
+ text = "商品订单"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ })
|
|
|
+ mode = QMUITabSegment.MODE_FIXED
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 合约汇总单UI
|
|
|
+ * @property activity AppCompatActivity
|
|
|
+ * @property viewModel SpotWareHouseViewModel
|
|
|
+ * @constructor
|
|
|
+ */
|
|
|
+class PositionUI(private val activity : AppCompatActivity, private val viewModel: ContractOrdersViewModel) : ContractPositionContentAdapter.OnContentScrollListener {
|
|
|
+
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+ lateinit var horScrollview: CustomHorizontalScrollView
|
|
|
+ lateinit var recyclerView: RecyclerView
|
|
|
+
|
|
|
+ val topAdapter by lazy {
|
|
|
+ TopTabAdpater(activity)
|
|
|
+ }
|
|
|
+
|
|
|
+ val contractPositionContentAdapter by lazy {
|
|
|
+ ContractPositionContentAdapter(
|
|
|
+ activity,
|
|
|
+ viewModel
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onScroll(event: MotionEvent?) {
|
|
|
+ //处理单个item滚动时,顶部tab需要联动
|
|
|
+ if (null != horScrollview) horScrollview.onTouchEvent(event)
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresApi(Build.VERSION_CODES.N)
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.queryContractPositionTitle(Constant.table_mobile_hnst_hydd_hyhz)
|
|
|
+ contractPositionContentAdapter.setOnContentScrollListener(this@PositionUI)
|
|
|
+// viewModel.showCancelDialog.bindOptional(context){
|
|
|
+// if (it == true){
|
|
|
+// activity.createWarningDialog {
|
|
|
+// setTitle("温馨提示")
|
|
|
+// setMessage("确定撤销此挂单吗?")
|
|
|
+// addAction("取消") { dialog, _ ->
|
|
|
+// viewModel.showCancelDialog.postValue(false)
|
|
|
+// dialog.dismiss()
|
|
|
+// }
|
|
|
+// addAction("确定") { dialog, _ ->
|
|
|
+// val data1 = viewModel.selectCancelData.value
|
|
|
+// viewModel.wRTradeFinanceBuyCancelReq(
|
|
|
+// marketid = data1?.marketid?.toInt() ?: 0,
|
|
|
+// AccountID = GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+// FinanceApplyID = data1?.financeapplyid?.toLong() ?: 0
|
|
|
+// ){
|
|
|
+// //撤单成功后再次请求申请单
|
|
|
+// viewModel.queryWrFinanceBuyApply()
|
|
|
+// }
|
|
|
+//
|
|
|
+// viewModel.showCancelDialog.postValue(false)
|
|
|
+// dialog.dismiss()
|
|
|
+// }
|
|
|
+// }.show()
|
|
|
+// }
|
|
|
+ }
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+
|
|
|
+ gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
|
|
+ textView {//待点价头部左侧数据
|
|
|
+ viewModel.positionTitleDataList.bindOptional(context) {
|
|
|
+ text = it?.get(0)?.columntitle?.replace("\\n", "\n") ?: ""
|
|
|
+ }
|
|
|
+ textColorStr = "#AAAAAA"
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(100))
|
|
|
+
|
|
|
+ inflateLayout<CustomHorizontalScrollView>(R.layout.scrollview) {
|
|
|
+ horScrollview = this
|
|
|
+ setOnCustomScrollChangeListener { _, scrollX, _, _, _ ->
|
|
|
+ contractPositionContentAdapter.offestX = scrollX
|
|
|
+ val viewHolderCacheList: List<ContractPositionContentAdapter.ItemViewHolder> =
|
|
|
+ contractPositionContentAdapter.viewHolderCacheList
|
|
|
+
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ scrollX,
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ relativeLayout {
|
|
|
+ recyclerView {//待点价头部右侧数据
|
|
|
+ val linearLayoutManager = LinearLayoutManager(context)
|
|
|
+ linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
|
|
|
+ layoutManager = linearLayoutManager
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = topAdapter
|
|
|
+ }
|
|
|
+ viewModel.positionTitleDataList.bindOptional(context) {
|
|
|
+ val titleStringList = arrayListOf<String>()
|
|
|
+ it?.subList(1, it.size)?.forEach { data ->
|
|
|
+ titleStringList.add(data.columntitle?.replace("\\n", "\n") ?: "")
|
|
|
+ }
|
|
|
+ topAdapter.setDatas(titleStringList)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+ setRetryAction {
|
|
|
+
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(true)
|
|
|
+ setEnableLoadMore(true)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.queryContractTradePosition()
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ recyclerView {//待点价列表
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = contractPositionContentAdapter
|
|
|
+ addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
+ override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
|
+ super.onScrolled(recyclerView, dx, dy)
|
|
|
+ val viewHolderCacheList: List<ContractPositionContentAdapter.ItemViewHolder> =
|
|
|
+ contractPositionContentAdapter.viewHolderCacheList
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ contractPositionContentAdapter.getOffestX(),
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.positionDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+// mHeadHeaderHSView.scrollTo(scrollXView,scrollYView)
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ contractPositionContentAdapter.setDatas(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 委托UI
|
|
|
+ * @property activity AppCompatActivity
|
|
|
+ * @property viewModel SpotWareHouseViewModel
|
|
|
+ * @constructor
|
|
|
+ */
|
|
|
+class OrderUI(private val activity : AppCompatActivity, private val viewModel: ContractOrdersViewModel) : ContractOrderContentAdapter.OnContentScrollListener {
|
|
|
+
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+ lateinit var horScrollview: CustomHorizontalScrollView
|
|
|
+ lateinit var recyclerView: RecyclerView
|
|
|
+
|
|
|
+ val topAdapter by lazy {
|
|
|
+ TopTabAdpater(activity)
|
|
|
+ }
|
|
|
+
|
|
|
+ val contractOrderContentAdapter by lazy {
|
|
|
+ ContractOrderContentAdapter(
|
|
|
+ activity,viewModel
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onScroll(event: MotionEvent?) {
|
|
|
+ //处理单个item滚动时,顶部tab需要联动
|
|
|
+ if (null != horScrollview) horScrollview.onTouchEvent(event)
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresApi(Build.VERSION_CODES.N)
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.queryContractOrderTitle(Constant.table_mobile_hnst_hydd_wt)
|
|
|
+ contractOrderContentAdapter.setOnContentScrollListener(this@OrderUI)
|
|
|
+// viewModel.showCancelDialog.bindOptional(context){
|
|
|
+// if (it == true){
|
|
|
+// activity.createWarningDialog {
|
|
|
+// setTitle("温馨提示")
|
|
|
+// setMessage("确定撤销此挂单吗?")
|
|
|
+// addAction("取消") { dialog, _ ->
|
|
|
+// viewModel.showCancelDialog.postValue(false)
|
|
|
+// dialog.dismiss()
|
|
|
+// }
|
|
|
+// addAction("确定") { dialog, _ ->
|
|
|
+// val data1 = viewModel.selectCancelData.value
|
|
|
+// viewModel.wRTradeFinanceBuyCancelReq(
|
|
|
+// marketid = data1?.marketid?.toInt() ?: 0,
|
|
|
+// AccountID = GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+// FinanceApplyID = data1?.financeapplyid?.toLong() ?: 0
|
|
|
+// ){
|
|
|
+// //撤单成功后再次请求申请单
|
|
|
+// viewModel.queryWrFinanceBuyApply()
|
|
|
+// }
|
|
|
+//
|
|
|
+// viewModel.showCancelDialog.postValue(false)
|
|
|
+// dialog.dismiss()
|
|
|
+// }
|
|
|
+// }.show()
|
|
|
+// }
|
|
|
+// }
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+
|
|
|
+ gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
|
|
+ textView {//待点价头部左侧数据
|
|
|
+ viewModel.orderTitleDataList.bindOptional(context) {
|
|
|
+ text = it?.get(0)?.columntitle?.replace("\\n", "\n") ?: ""
|
|
|
+ }
|
|
|
+ textColorStr = "#AAAAAA"
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(100))
|
|
|
+
|
|
|
+ inflateLayout<CustomHorizontalScrollView>(R.layout.scrollview) {
|
|
|
+ horScrollview = this
|
|
|
+ setOnCustomScrollChangeListener { _, scrollX, _, _, _ ->
|
|
|
+ contractOrderContentAdapter.offestX = scrollX
|
|
|
+ val viewHolderCacheList: List<ContractOrderContentAdapter.ItemViewHolder> =
|
|
|
+ contractOrderContentAdapter.viewHolderCacheList
|
|
|
+
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ scrollX,
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ relativeLayout {
|
|
|
+ recyclerView {//待点价头部右侧数据
|
|
|
+ val linearLayoutManager = LinearLayoutManager(context)
|
|
|
+ linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
|
|
|
+ layoutManager = linearLayoutManager
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = topAdapter
|
|
|
+ }
|
|
|
+ viewModel.orderTitleDataList.bindOptional(context) {
|
|
|
+ val titleStringList = arrayListOf<String>()
|
|
|
+ it?.subList(1, it.size)?.forEach { data ->
|
|
|
+ titleStringList.add(data.columntitle?.replace("\\n", "\n") ?: "")
|
|
|
+ }
|
|
|
+ topAdapter.setDatas(titleStringList)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+ setRetryAction {
|
|
|
+
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(true)
|
|
|
+ setEnableLoadMore(true)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.queryContractTradeOrderDetail()
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ recyclerView {//待点价列表
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = contractOrderContentAdapter
|
|
|
+ addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
+ override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
|
+ super.onScrolled(recyclerView, dx, dy)
|
|
|
+ val viewHolderCacheList: List<ContractOrderContentAdapter.ItemViewHolder> =
|
|
|
+ contractOrderContentAdapter.viewHolderCacheList
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ contractOrderContentAdapter.getOffestX(),
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.orderDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+// mHeadHeaderHSView.scrollTo(scrollXView,scrollYView)
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ contractOrderContentAdapter.setDatas(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 成交单UI
|
|
|
+ * @property activity AppCompatActivity
|
|
|
+ * @property viewModel SpotWareHouseViewModel
|
|
|
+ * @constructor
|
|
|
+ */
|
|
|
+class TraderUI(private val activity : AppCompatActivity, private val viewModel: ContractOrdersViewModel) : ContractTraderContentAdapter.OnContentScrollListener {
|
|
|
+
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+ lateinit var horScrollview: CustomHorizontalScrollView
|
|
|
+ lateinit var recyclerView: RecyclerView
|
|
|
+
|
|
|
+ val topAdapter by lazy {
|
|
|
+ TopTabAdpater(activity)
|
|
|
+ }
|
|
|
+
|
|
|
+ val contractTraderContentAdapter by lazy {
|
|
|
+ ContractTraderContentAdapter(
|
|
|
+ activity, viewModel
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onScroll(event: MotionEvent?) {
|
|
|
+ //处理单个item滚动时,顶部tab需要联动
|
|
|
+ if (null != horScrollview) horScrollview.onTouchEvent(event)
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresApi(Build.VERSION_CODES.N)
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.queryContractTraderTitle(Constant.table_mobile_hnst_hydd_cj)
|
|
|
+ contractTraderContentAdapter.setOnContentScrollListener(this@TraderUI)
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+
|
|
|
+ gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
|
|
+ textView {//待点价头部左侧数据
|
|
|
+ viewModel.traderTitleDataList.bindOptional(context) {
|
|
|
+ text = it?.get(0)?.columntitle?.replace("\\n", "\n") ?: ""
|
|
|
+ }
|
|
|
+ textColorStr = "#AAAAAA"
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(100))
|
|
|
+
|
|
|
+ inflateLayout<CustomHorizontalScrollView>(R.layout.scrollview) {
|
|
|
+ horScrollview = this
|
|
|
+ setOnCustomScrollChangeListener { _, scrollX, _, _, _ ->
|
|
|
+ contractTraderContentAdapter.offestX = scrollX
|
|
|
+ val viewHolderCacheList: List<ContractTraderContentAdapter.ItemViewHolder> =
|
|
|
+ contractTraderContentAdapter.viewHolderCacheList
|
|
|
+
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ scrollX,
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ relativeLayout {
|
|
|
+ recyclerView {//待点价头部右侧数据
|
|
|
+ val linearLayoutManager = LinearLayoutManager(context)
|
|
|
+ linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
|
|
|
+ layoutManager = linearLayoutManager
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = topAdapter
|
|
|
+ }
|
|
|
+ viewModel.traderTitleDataList.bindOptional(context) {
|
|
|
+ val titleStringList = arrayListOf<String>()
|
|
|
+ it?.subList(1, it.size)?.forEach { data ->
|
|
|
+ titleStringList.add(data.columntitle?.replace("\\n", "\n") ?: "")
|
|
|
+ }
|
|
|
+ topAdapter.setDatas(titleStringList)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+ setRetryAction {
|
|
|
+
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(true)
|
|
|
+ setEnableLoadMore(true)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.queryContractTradeDetail()
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ recyclerView {//待点价列表
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = contractTraderContentAdapter
|
|
|
+ addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
+ override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
|
+ super.onScrolled(recyclerView, dx, dy)
|
|
|
+ val viewHolderCacheList: List<ContractTraderContentAdapter.ItemViewHolder> =
|
|
|
+ contractTraderContentAdapter.viewHolderCacheList
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ contractTraderContentAdapter.getOffestX(),
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.traderDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+// mHeadHeaderHSView.scrollTo(scrollXView,scrollYView)
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ contractTraderContentAdapter.setDatas(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 交收单UI
|
|
|
+ * @property activity AppCompatActivity
|
|
|
+ * @property viewModel SpotWareHouseViewModel
|
|
|
+ * @constructor
|
|
|
+ */
|
|
|
+class DeliveryUI(private val activity : AppCompatActivity, private val viewModel: ContractOrdersViewModel) : ContractDeliveryContentAdapter.OnContentScrollListener {
|
|
|
+
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+ lateinit var horScrollview: CustomHorizontalScrollView
|
|
|
+ lateinit var recyclerView: RecyclerView
|
|
|
+
|
|
|
+ val topAdapter by lazy {
|
|
|
+ TopTabAdpater(activity)
|
|
|
+ }
|
|
|
+
|
|
|
+ val contractDeliveryContentAdapter by lazy {
|
|
|
+ ContractDeliveryContentAdapter(
|
|
|
+ activity,viewModel
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onScroll(event: MotionEvent?) {
|
|
|
+ //处理单个item滚动时,顶部tab需要联动
|
|
|
+ if (null != horScrollview) horScrollview.onTouchEvent(event)
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresApi(Build.VERSION_CODES.N)
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.queryContractDeliveryTitle(Constant.table_mobile_hnst_hydd_js)
|
|
|
+ contractDeliveryContentAdapter.setOnContentScrollListener(this@DeliveryUI)
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+
|
|
|
+ gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
|
|
+ textView {//待点价头部左侧数据
|
|
|
+ viewModel.deliveryTitleDataList.bindOptional(context) {
|
|
|
+ text = it?.get(0)?.columntitle?.replace("\\n", "\n") ?: ""
|
|
|
+ }
|
|
|
+ textColorStr = "#AAAAAA"
|
|
|
+ textSizeAuto = 29
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(250), autoSize(100))
|
|
|
+
|
|
|
+ inflateLayout<CustomHorizontalScrollView>(R.layout.scrollview) {
|
|
|
+ horScrollview = this
|
|
|
+ setOnCustomScrollChangeListener { _, scrollX, _, _, _ ->
|
|
|
+ contractDeliveryContentAdapter.offestX = scrollX
|
|
|
+ val viewHolderCacheList: List<ContractDeliveryContentAdapter.ItemViewHolder> =
|
|
|
+ contractDeliveryContentAdapter.viewHolderCacheList
|
|
|
+
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ scrollX,
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ relativeLayout {
|
|
|
+ recyclerView {//待点价头部右侧数据
|
|
|
+ val linearLayoutManager = LinearLayoutManager(context)
|
|
|
+ linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
|
|
|
+ layoutManager = linearLayoutManager
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = topAdapter
|
|
|
+ }
|
|
|
+ viewModel.deliveryTitleDataList.bindOptional(context) {
|
|
|
+ val titleStringList = arrayListOf<String>()
|
|
|
+ it?.subList(1, it.size)?.forEach { data ->
|
|
|
+ titleStringList.add(data.columntitle?.replace("\\n", "\n") ?: "")
|
|
|
+ }
|
|
|
+ topAdapter.setDatas(titleStringList)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+ setRetryAction {
|
|
|
+
|
|
|
+ }
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(true)
|
|
|
+ setEnableLoadMore(true)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.queryWrDeliveryDetail()
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ recyclerView {//待点价列表
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = contractDeliveryContentAdapter
|
|
|
+ addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
+ override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
|
+ super.onScrolled(recyclerView, dx, dy)
|
|
|
+ val viewHolderCacheList: List<ContractDeliveryContentAdapter.ItemViewHolder> =
|
|
|
+ contractDeliveryContentAdapter.viewHolderCacheList
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ contractDeliveryContentAdapter.getOffestX(),
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.deliveryTraderDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+// mHeadHeaderHSView.scrollTo(scrollXView,scrollYView)
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ contractDeliveryContentAdapter.setDatas(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|