|
|
@@ -2,96 +2,125 @@ package cn.muchinfo.rma.view.base.spot.associated
|
|
|
|
|
|
import android.content.Intent
|
|
|
import android.os.Bundle
|
|
|
-import android.view.Gravity
|
|
|
-import android.view.LayoutInflater
|
|
|
-import android.view.View
|
|
|
-import android.view.ViewGroup
|
|
|
+import android.view.*
|
|
|
+import android.widget.EditText
|
|
|
import androidx.annotation.NonNull
|
|
|
import androidx.annotation.Nullable
|
|
|
+import androidx.appcompat.app.AppCompatActivity
|
|
|
import androidx.fragment.app.Fragment
|
|
|
import androidx.fragment.app.FragmentPagerAdapter
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
+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.global.GlobalDataCollection
|
|
|
import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
import cn.muchinfo.rma.lifecycle.getAppCompatActivity
|
|
|
import cn.muchinfo.rma.view.autoWidget.*
|
|
|
import cn.muchinfo.rma.view.base.BaseFragment
|
|
|
+import cn.muchinfo.rma.view.base.app.Constant
|
|
|
+import cn.muchinfo.rma.view.base.procurement.TopTabAdpater
|
|
|
import cn.muchinfo.rma.view.base.spot.associated.externalorder.ExternalOrderAssociationFragment
|
|
|
+import cn.muchinfo.rma.view.base.spot.associated.externalorder.OutAssociationContentAdapter
|
|
|
import cn.muchinfo.rma.view.base.spot.associated.perioddocuments.BusinessAssociationsActivity
|
|
|
import cn.muchinfo.rma.view.base.spot.associated.perioddocuments.FillSingleConnectionActivity
|
|
|
+import cn.muchinfo.rma.view.base.spot.associated.perioddocuments.PeriodAssociationContentAdapter
|
|
|
import cn.muchinfo.rma.view.base.spot.associated.perioddocuments.PeriodDocumentsFragment
|
|
|
+import cn.muchinfo.rma.view.base.spot.associated.relationalrecord.RelationalRecordContentAdapter
|
|
|
import cn.muchinfo.rma.view.base.spot.associated.relationalrecord.RelationalRecordFragment
|
|
|
import com.blankj.utilcode.util.ActivityUtils
|
|
|
import com.blankj.utilcode.util.ConvertUtils
|
|
|
+import com.blankj.utilcode.util.SizeUtils
|
|
|
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.SelectData
|
|
|
+import mtp.polymer.com.autowidget.dialog.creatBottomSheetDialog
|
|
|
import org.jetbrains.anko.*
|
|
|
import org.jetbrains.anko.support.v4.UI
|
|
|
import org.jetbrains.anko.support.v4.viewPager
|
|
|
|
|
|
-class PeriodAssociatedFragment : BaseFragment<PeriodAssociatedViewModel>(){
|
|
|
+class PeriodAssociatedFragment : BaseFragment<PeriodAssociatedViewModel>() {
|
|
|
|
|
|
lateinit var segment: QMUITabSegment
|
|
|
var selectedTabIndex: Int = 0
|
|
|
private lateinit var viewPager: ViewPager
|
|
|
|
|
|
- val selectedTabIndexData : MutableLiveData<Int> = MutableLiveData()
|
|
|
+ val selectedTabIndexData: MutableLiveData<Int> = MutableLiveData()
|
|
|
+
|
|
|
+ var indexFirst: Int = 0
|
|
|
|
|
|
//外部成交单关联
|
|
|
- val externalOrderAssociationFragment by lazy {
|
|
|
- ExternalOrderAssociationFragment()
|
|
|
+ val externalOrderAssociationUI by lazy {
|
|
|
+ ExternalOrderAssociationUI(this.getAppCompatActivity(), viewModel)
|
|
|
}
|
|
|
|
|
|
//期现单据关联
|
|
|
- val periodDocumentsFragment by lazy {
|
|
|
- PeriodDocumentsFragment()
|
|
|
+ val periodDocumentsUI by lazy {
|
|
|
+ PeriodDocumentsUI(this.getAppCompatActivity(), viewModel)
|
|
|
}
|
|
|
|
|
|
//关联记录
|
|
|
- val relationalRecordFragment by lazy {
|
|
|
- RelationalRecordFragment()
|
|
|
+ val relationalRecordUI by lazy {
|
|
|
+ RelationalRecordUI(this.getAppCompatActivity(), viewModel)
|
|
|
}
|
|
|
|
|
|
//viewpager的适配器
|
|
|
- private var newPagerAdapter: FragmentPagerAdapter? = null
|
|
|
+ private var newPagerAdapter: PagerAdapter? = null
|
|
|
|
|
|
//tabSegment标题
|
|
|
private val newTabsArray: ArrayList<String> = arrayListOf()
|
|
|
|
|
|
- //viewpager绑定的页面集合
|
|
|
- private val newTabFragment: ArrayList<Fragment> = arrayListOf()
|
|
|
+ //暂存的页面组
|
|
|
+ private val uiList: ArrayList<_FrameLayout> = arrayListOf()
|
|
|
|
|
|
fun initMenuData() {
|
|
|
|
|
|
- newTabsArray.add("外部成交单关联")
|
|
|
- newTabFragment.add(externalOrderAssociationFragment)
|
|
|
+ if (uiList.size > 0) {
|
|
|
+ newPagerAdapter = null
|
|
|
+ newTabsArray.clear()
|
|
|
+ uiList.clear()
|
|
|
+ }
|
|
|
|
|
|
- newTabsArray.add("期现单据关联")
|
|
|
- newTabFragment.add(periodDocumentsFragment)
|
|
|
+ if (GlobalDataCollection.instance?.getThreeLevelMenu("client_spots","client_spots_link","client_spots_link_outorder") == true){
|
|
|
+ newTabsArray.add("外部成交单关联")
|
|
|
+ uiList.add(externalOrderAssociationUI.root)
|
|
|
+ }
|
|
|
|
|
|
- newTabsArray.add("关联记录")
|
|
|
- newTabFragment.add(relationalRecordFragment)
|
|
|
+ if (GlobalDataCollection.instance?.getThreeLevelMenu("client_spots","client_spots_link","client_spots_link_pa") == true) {
|
|
|
+ newTabsArray.add("期现单据关联")
|
|
|
+ uiList.add(periodDocumentsUI.root)
|
|
|
+ }
|
|
|
+ if (GlobalDataCollection.instance?.getThreeLevelMenu("client_spots","client_spots_link","client_spots_link_logs") == true) {
|
|
|
+ newTabsArray.add("关联记录")
|
|
|
+ uiList.add(relationalRecordUI.root)
|
|
|
+ }
|
|
|
|
|
|
- newPagerAdapter = object : FragmentPagerAdapter(
|
|
|
- getAppCompatActivity().supportFragmentManager,
|
|
|
- BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
|
|
|
- ) {
|
|
|
- @NonNull
|
|
|
- override fun getItem(position: Int): Fragment {
|
|
|
- return newTabFragment[position]
|
|
|
- }
|
|
|
+ newPagerAdapter = object : PagerAdapter() {
|
|
|
|
|
|
- override fun getCount(): Int {
|
|
|
- return newTabFragment.size
|
|
|
+ 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)
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @Nullable
|
|
|
- override fun getPageTitle(position: Int): CharSequence? {
|
|
|
- return newTabsArray[position]
|
|
|
+ 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
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -101,6 +130,12 @@ class PeriodAssociatedFragment : BaseFragment<PeriodAssociatedViewModel>(){
|
|
|
savedInstanceState: Bundle?
|
|
|
): View? {
|
|
|
initMenuData()
|
|
|
+
|
|
|
+ if (indexFirst > 0) {
|
|
|
+ segment.reset()
|
|
|
+ viewPager.adapter = newPagerAdapter
|
|
|
+ }
|
|
|
+ indexFirst++
|
|
|
return UI {
|
|
|
verticalLayout {
|
|
|
|
|
|
@@ -128,15 +163,15 @@ class PeriodAssociatedFragment : BaseFragment<PeriodAssociatedViewModel>(){
|
|
|
)
|
|
|
|
|
|
setDefaultTextSize(ConvertUtils.sp2px(16f), ConvertUtils.sp2px(16f))
|
|
|
- }.lparams(0, autoSize(80),4f)
|
|
|
+ }.lparams(0, autoSize(80), 4f)
|
|
|
|
|
|
linearLayout {
|
|
|
gravity = Gravity.CENTER
|
|
|
visibility = View.INVISIBLE
|
|
|
- selectedTabIndexData.bindOptional(context){
|
|
|
- if (it == 1){
|
|
|
+ selectedTabIndexData.bindOptional(context) {
|
|
|
+ if (it == 1) {
|
|
|
visibility = View.VISIBLE
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
visibility = View.INVISIBLE
|
|
|
}
|
|
|
}
|
|
|
@@ -152,7 +187,7 @@ class PeriodAssociatedFragment : BaseFragment<PeriodAssociatedViewModel>(){
|
|
|
textSizeAuto = 29
|
|
|
textColorInt = R.color.rma_blue_color
|
|
|
}.lparams(autoSize(150), autoSize(50))
|
|
|
- }.lparams(0, autoSize(80),1f)
|
|
|
+ }.lparams(0, autoSize(80), 1f)
|
|
|
}.lparams(matchParent, autoSize(80))
|
|
|
|
|
|
|
|
|
@@ -178,4 +213,637 @@ class PeriodAssociatedFragment : BaseFragment<PeriodAssociatedViewModel>(){
|
|
|
}.view
|
|
|
}
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 外部期限关联ui
|
|
|
+ */
|
|
|
+class ExternalOrderAssociationUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: PeriodAssociatedViewModel
|
|
|
+) : OutAssociationContentAdapter.OnContentScrollListener {
|
|
|
+
|
|
|
+ //输入的搜索外部订单号
|
|
|
+ lateinit var order_in_edittext: EditText
|
|
|
+
|
|
|
+ //输入的搜索合约名称/代码
|
|
|
+ lateinit var code_in_edittext: EditText
|
|
|
+
|
|
|
+ //选择的是否是关联和未关联的
|
|
|
+ val seleAssociatedType: MutableLiveData<SelectData> = MutableLiveData()
|
|
|
+
|
|
|
+
|
|
|
+ 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 contentAdapter by lazy {
|
|
|
+ OutAssociationContentAdapter(
|
|
|
+ activity
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onScroll(event: MotionEvent?) {
|
|
|
+ //处理单个item滚动时,顶部tab需要联动
|
|
|
+ if (null != horScrollview) horScrollview.onTouchEvent(event)
|
|
|
+ }
|
|
|
+
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ viewModel.queryOutOrderAssociationTitle(
|
|
|
+ tableKey = Constant.table_mobile_spotfuturerelate_outertradeorder,
|
|
|
+ hasinnerorder = "0"
|
|
|
+ )
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ backgroundResource = R.drawable.qyfg_search_item_bg
|
|
|
+ editText {
|
|
|
+ order_in_edittext = this
|
|
|
+ hint = "搜索外部订单号"
|
|
|
+ background = null
|
|
|
+// inputType = EditorInfo.TYPE_CLASS_NUMBER or EditorInfo.TYPE_NUMBER_FLAG_DECIMAL or EditorInfo.TYPE_NUMBER_FLAG_SIGNED
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(90)) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(100), 1f) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(16)
|
|
|
+ }
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ backgroundResource = R.drawable.qyfg_search_item_bg
|
|
|
+ editText {
|
|
|
+ code_in_edittext = this
|
|
|
+ hint = "搜索合约名称/代码"
|
|
|
+ background = null
|
|
|
+// inputType = EditorInfo.TYPE_CLASS_NUMBER or EditorInfo.TYPE_NUMBER_FLAG_DECIMAL or EditorInfo.TYPE_NUMBER_FLAG_SIGNED
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(90)) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(100), 1f) {
|
|
|
+ marginStart = autoSize(16)
|
|
|
+ marginEnd = autoSize(32)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(120))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ backgroundResource = R.drawable.rma_time_click_bg
|
|
|
+ onThrottleFirstClick {
|
|
|
+ val selectDataList = arrayListOf<SelectData>(
|
|
|
+ SelectData(id = "0", value = "未关联"),
|
|
|
+ SelectData(id = "1", value = "已关联")
|
|
|
+ )
|
|
|
+ activity.creatBottomSheetDialog("请选择指定交易用户", selectDataList) {
|
|
|
+ seleAssociatedType.postValue(this)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ seleAssociatedType.bindOptional(context) {
|
|
|
+ text = it?.value
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(0, autoSize(90), 1f) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(16)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ backgroundDrawable = createCommonBottomRoundBg(color = "#2481DD", corner = 5)
|
|
|
+ onThrottleFirstClick {
|
|
|
+ viewModel.queryOutTradeLink(
|
|
|
+ outtradeid = order_in_edittext.text.toString(),
|
|
|
+ goodsname = code_in_edittext.text.toString(),
|
|
|
+ hasinnerorder = seleAssociatedType.value?.id ?: "0"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ text = "查询"
|
|
|
+ textColorInt = R.color.white
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(0, autoSize(90), 1f) {
|
|
|
+ marginStart = autoSize(16)
|
|
|
+ marginEnd = autoSize(32)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(120))
|
|
|
+
|
|
|
+ contentAdapter.setOnContentScrollListener(this@ExternalOrderAssociationUI)
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
|
|
+ textView {//待点价头部左侧数据
|
|
|
+ viewModel.orderAssociationTitleList.bindOptional(context) {
|
|
|
+ text = it?.get(0)?.columntitle?.replace("\\n", "\n") ?: ""
|
|
|
+ }
|
|
|
+ textColorStr = "#AAAAAA"
|
|
|
+ textSizeAuto = 24
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(SizeUtils.dp2px(135f)), autoSize(100))
|
|
|
+
|
|
|
+ inflateLayout<CustomHorizontalScrollView>(R.layout.scrollview) {
|
|
|
+ horScrollview = this
|
|
|
+ setOnCustomScrollChangeListener { _, scrollX, _, _, _ ->
|
|
|
+ contentAdapter.offestX = scrollX
|
|
|
+ val viewHolderCacheList: List<OutAssociationContentAdapter.ItemViewHolder> =
|
|
|
+ contentAdapter.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.orderAssociationTitleList.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
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(false)
|
|
|
+ setEnableLoadMore(true)
|
|
|
+ setOnRefreshListener {
|
|
|
+ viewModel.queryOutTradeLink(
|
|
|
+ outtradeid = order_in_edittext.text.toString(),
|
|
|
+ goodsname = code_in_edittext.text.toString(),
|
|
|
+ hasinnerorder = seleAssociatedType.value?.id ?: "0"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ recyclerView {//待点价列表
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = contentAdapter
|
|
|
+ addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
+ override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
|
+ super.onScrolled(recyclerView, dx, dy)
|
|
|
+ val viewHolderCacheList: List<OutAssociationContentAdapter.ItemViewHolder> =
|
|
|
+ contentAdapter.viewHolderCacheList
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ contentAdapter.getOffestX(),
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.orderAssociationDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+// mHeadHeaderHSView.scrollTo(scrollXView,scrollYView)
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ contentAdapter.setDatas(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 期现单据关联页面
|
|
|
+ * @property activity AppCompatActivity
|
|
|
+ * @property viewModel PeriodAssociatedViewModel
|
|
|
+ * @property swipeToLayout SwipeToLoadLayout
|
|
|
+ * @property statusLayout StatusLayout
|
|
|
+ * @property horScrollview CustomHorizontalScrollView
|
|
|
+ * @property recyclerView RecyclerView
|
|
|
+ * @property topAdapter TopTabAdpater
|
|
|
+ * @property contentAdapter PeriodAssociationContentAdapter
|
|
|
+ * @property root _FrameLayout
|
|
|
+ * @constructor
|
|
|
+ */
|
|
|
+class PeriodDocumentsUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: PeriodAssociatedViewModel
|
|
|
+) : PeriodAssociationContentAdapter.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 contentAdapter by lazy {
|
|
|
+ PeriodAssociationContentAdapter(
|
|
|
+ activity
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onScroll(event: MotionEvent?) {
|
|
|
+ //处理单个item滚动时,顶部tab需要联动
|
|
|
+ if (null != horScrollview) horScrollview.onTouchEvent(event)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ viewModel.queryPeriodAssociationTitle(tableKey = Constant.table_mobile_spotfuturerelate_order)
|
|
|
+ verticalLayout {
|
|
|
+ contentAdapter.setOnContentScrollListener(this@PeriodDocumentsUI)
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
|
|
+ textView {//待点价头部左侧数据
|
|
|
+ viewModel.periodAssociationTitleList.bindOptional(context) {
|
|
|
+ text = it?.get(0)?.columntitle?.replace("\\n", "\n") ?: ""
|
|
|
+ }
|
|
|
+ textColorStr = "#AAAAAA"
|
|
|
+ textSizeAuto = 24
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(SizeUtils.dp2px(135f)), autoSize(100))
|
|
|
+
|
|
|
+ inflateLayout<CustomHorizontalScrollView>(R.layout.scrollview) {
|
|
|
+ horScrollview = this
|
|
|
+ setOnCustomScrollChangeListener { _, scrollX, _, _, _ ->
|
|
|
+ contentAdapter.offestX = scrollX
|
|
|
+ val viewHolderCacheList: List<PeriodAssociationContentAdapter.ItemViewHolder> =
|
|
|
+ contentAdapter.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.periodAssociationTitleList.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
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(false)
|
|
|
+ setEnableLoadMore(true)
|
|
|
+ setOnRefreshListener {
|
|
|
+
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ recyclerView {//待点价列表
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = contentAdapter
|
|
|
+ addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
+ override fun onScrolled(
|
|
|
+ recyclerView: RecyclerView,
|
|
|
+ dx: Int,
|
|
|
+ dy: Int
|
|
|
+ ) {
|
|
|
+ super.onScrolled(recyclerView, dx, dy)
|
|
|
+ val viewHolderCacheList: List<PeriodAssociationContentAdapter.ItemViewHolder> =
|
|
|
+ contentAdapter.viewHolderCacheList
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ contentAdapter.getOffestX(),
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.periodAssociationDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+// mHeadHeaderHSView.scrollTo(scrollXView,scrollYView)
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ contentAdapter.setDatas(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+class RelationalRecordUI(
|
|
|
+ private val activity: AppCompatActivity,
|
|
|
+ private val viewModel: PeriodAssociatedViewModel
|
|
|
+) : RelationalRecordContentAdapter.OnContentScrollListener {
|
|
|
+
|
|
|
+ //搜索期货订单号
|
|
|
+ lateinit var futures_order_number: EditText
|
|
|
+
|
|
|
+ //搜索现货编号
|
|
|
+ lateinit var spot_number: EditText
|
|
|
+
|
|
|
+ //搜索期货账户
|
|
|
+ lateinit var futures_account: EditText
|
|
|
+
|
|
|
+ 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 contentAdapter by lazy {
|
|
|
+ RelationalRecordContentAdapter(
|
|
|
+ activity
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onScroll(event: MotionEvent?) {
|
|
|
+ //处理单个item滚动时,顶部tab需要联动
|
|
|
+ if (null != horScrollview) horScrollview.onTouchEvent(event)
|
|
|
+ }
|
|
|
+
|
|
|
+ val root = _FrameLayout(activity).apply {
|
|
|
+ viewModel.queryRelationRecordTitle(tableKey = Constant.table_mobile_spotfuturerelate_order)
|
|
|
+ verticalLayout {
|
|
|
+
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ backgroundResource = R.drawable.qyfg_search_item_bg
|
|
|
+ editText {
|
|
|
+ futures_order_number = this
|
|
|
+ hint = "搜索期货订单号"
|
|
|
+ background = null
|
|
|
+// inputType = EditorInfo.TYPE_CLASS_NUMBER or EditorInfo.TYPE_NUMBER_FLAG_DECIMAL or EditorInfo.TYPE_NUMBER_FLAG_SIGNED
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(90)) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(100), 1f) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(16)
|
|
|
+ }
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ backgroundResource = R.drawable.qyfg_search_item_bg
|
|
|
+ editText {
|
|
|
+ spot_number = this
|
|
|
+ hint = "搜索现货编号"
|
|
|
+ background = null
|
|
|
+// inputType = EditorInfo.TYPE_CLASS_NUMBER or EditorInfo.TYPE_NUMBER_FLAG_DECIMAL or EditorInfo.TYPE_NUMBER_FLAG_SIGNED
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(90)) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(100), 1f) {
|
|
|
+ marginStart = autoSize(16)
|
|
|
+ marginEnd = autoSize(32)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(120))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ linearLayout {
|
|
|
+ backgroundResource = R.drawable.qyfg_search_item_bg
|
|
|
+ editText {
|
|
|
+ futures_account = this
|
|
|
+ hint = "搜索期货账户"
|
|
|
+ background = null
|
|
|
+// inputType = EditorInfo.TYPE_CLASS_NUMBER or EditorInfo.TYPE_NUMBER_FLAG_DECIMAL or EditorInfo.TYPE_NUMBER_FLAG_SIGNED
|
|
|
+// setDecimalInputType()
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
+ textSizeAuto = 31
|
|
|
+ textColorStr = "#333333"
|
|
|
+ }.lparams(matchParent, autoSize(90)) {
|
|
|
+ marginStart = autoSize(20)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(100), 1f) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(16)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ backgroundDrawable = createCommonBottomRoundBg(color = "#2481DD", corner = 5)
|
|
|
+ onThrottleFirstClick {
|
|
|
+ viewModel.queryRelationRecordTitle(
|
|
|
+ tableKey = Constant.table_mobile_spotfuturerelate_order,
|
|
|
+ tradeid = futures_order_number.text.toString(),
|
|
|
+ contractno = spot_number.text.toString(),
|
|
|
+ taname = futures_account.text.toString()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ text = "查询"
|
|
|
+ textColorInt = R.color.white
|
|
|
+ textSizeAuto = 31
|
|
|
+ }.lparams(0, autoSize(90), 1f) {
|
|
|
+ marginStart = autoSize(16)
|
|
|
+ marginEnd = autoSize(32)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(120))
|
|
|
+
|
|
|
+ contentAdapter.setOnContentScrollListener(this@RelationalRecordUI)
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
|
|
+ textView {//待点价头部左侧数据
|
|
|
+ viewModel.relationRecordTitleList.bindOptional(context) {
|
|
|
+ text = it?.get(0)?.columntitle?.replace("\\n", "\n") ?: ""
|
|
|
+ }
|
|
|
+ textColorStr = "#AAAAAA"
|
|
|
+ textSizeAuto = 24
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(30)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(SizeUtils.dp2px(135f)), autoSize(100))
|
|
|
+
|
|
|
+ inflateLayout<CustomHorizontalScrollView>(R.layout.scrollview) {
|
|
|
+ horScrollview = this
|
|
|
+ setOnCustomScrollChangeListener { _, scrollX, _, _, _ ->
|
|
|
+ contentAdapter.offestX = scrollX
|
|
|
+ val viewHolderCacheList: List<RelationalRecordContentAdapter.ItemViewHolder> =
|
|
|
+ contentAdapter.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.relationRecordTitleList.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
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(false)
|
|
|
+ setEnableLoadMore(true)
|
|
|
+ setOnRefreshListener {
|
|
|
+
|
|
|
+ }
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+
|
|
|
+ recyclerView {//待点价列表
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = contentAdapter
|
|
|
+ addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
+ override fun onScrolled(
|
|
|
+ recyclerView: RecyclerView,
|
|
|
+ dx: Int,
|
|
|
+ dy: Int
|
|
|
+ ) {
|
|
|
+ super.onScrolled(recyclerView, dx, dy)
|
|
|
+ val viewHolderCacheList: List<RelationalRecordContentAdapter.ItemViewHolder> =
|
|
|
+ contentAdapter.viewHolderCacheList
|
|
|
+ if (null != viewHolderCacheList) {
|
|
|
+ val size = viewHolderCacheList.size
|
|
|
+ for (i in 0 until size) {
|
|
|
+ viewHolderCacheList[i].horItemScrollview.scrollTo(
|
|
|
+ contentAdapter.getOffestX(),
|
|
|
+ 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ viewModel.relationRecordDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+// mHeadHeaderHSView.scrollTo(scrollXView,scrollYView)
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ contentAdapter.setDatas(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|