|
@@ -48,6 +48,7 @@ import cn.muchinfo.rma.view.base.home.yrdz.market.IndexData
|
|
|
import cn.muchinfo.rma.view.base.home.yrdz.market.IndexViewHolder
|
|
import cn.muchinfo.rma.view.base.home.yrdz.market.IndexViewHolder
|
|
|
import cn.muchinfo.rma.view.base.home.yrdz.market.YrdzMarketFragment
|
|
import cn.muchinfo.rma.view.base.home.yrdz.market.YrdzMarketFragment
|
|
|
import cn.muchinfo.rma.view.eventbus.MainTabSelectMessageEvent
|
|
import cn.muchinfo.rma.view.eventbus.MainTabSelectMessageEvent
|
|
|
|
|
+import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
|
|
|
import com.blankj.utilcode.util.*
|
|
import com.blankj.utilcode.util.*
|
|
|
import com.facebook.drawee.view.SimpleDraweeView
|
|
import com.facebook.drawee.view.SimpleDraweeView
|
|
|
import com.github.aachartmodel.aainfographics.aachartcreator.*
|
|
import com.github.aachartmodel.aainfographics.aachartcreator.*
|
|
@@ -58,6 +59,8 @@ import com.qmuiteam.qmui.widget.tab.QMUITabSegment
|
|
|
import mtp.polymer.com.autowidget.adapter.BaseAdapter
|
|
import mtp.polymer.com.autowidget.adapter.BaseAdapter
|
|
|
import mtp.polymer.com.information_management.hnstocks.message.MessageDetailsActivity
|
|
import mtp.polymer.com.information_management.hnstocks.message.MessageDetailsActivity
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
|
|
+import org.greenrobot.eventbus.ThreadMode
|
|
|
import org.jetbrains.anko.*
|
|
import org.jetbrains.anko.*
|
|
|
import org.jetbrains.anko.support.v4.UI
|
|
import org.jetbrains.anko.support.v4.UI
|
|
|
import org.jetbrains.anko.support.v4.viewPager
|
|
import org.jetbrains.anko.support.v4.viewPager
|
|
@@ -78,14 +81,23 @@ class TjmdHomeFragment : BaseFragment<TjmdHomeViewModel>(){
|
|
|
|
|
|
|
|
lateinit var segment: QMUITabSegment
|
|
lateinit var segment: QMUITabSegment
|
|
|
|
|
|
|
|
|
|
+ var fistShow: Int = 0
|
|
|
|
|
+ var lastShow: Int = 0
|
|
|
|
|
+
|
|
|
var selectedTabIndex: Int = 0
|
|
var selectedTabIndex: Int = 0
|
|
|
private lateinit var viewPager: ViewPager
|
|
private lateinit var viewPager: ViewPager
|
|
|
|
|
|
|
|
lateinit var noticeViewFlipper : ViewFlipper
|
|
lateinit var noticeViewFlipper : ViewFlipper
|
|
|
|
|
|
|
|
|
|
+ lateinit var dataRecyclerview : RecyclerView
|
|
|
|
|
+
|
|
|
|
|
+ val thisTag by lazy {
|
|
|
|
|
+ "TjmdHomeFragment"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//天津麦顿首页参考行情adapter
|
|
//天津麦顿首页参考行情adapter
|
|
|
- private val tjmdHomeMarketViewHolder: BaseAdapter<GoodsInfo, TjmdHomeMarketViewHolder> =
|
|
|
|
|
|
|
+ private val tjmdHomeMarketViewHolder: BaseAdapter<TjmdDemoData, TjmdHomeMarketViewHolder> =
|
|
|
BaseAdapter { _, _ ->
|
|
BaseAdapter { _, _ ->
|
|
|
TjmdHomeMarketViewHolder(
|
|
TjmdHomeMarketViewHolder(
|
|
|
this.getAppCompatActivity(),
|
|
this.getAppCompatActivity(),
|
|
@@ -94,7 +106,7 @@ class TjmdHomeFragment : BaseFragment<TjmdHomeViewModel>(){
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//掉期商品合约列表adapter
|
|
//掉期商品合约列表adapter
|
|
|
- private val tjmdHomeSonAdapter: BaseAdapter<String, TjmdHomeSonViewHolder> =
|
|
|
|
|
|
|
+ private val tjmdHomeSonAdapter: BaseAdapter<GoodsInfo, TjmdHomeSonViewHolder> =
|
|
|
BaseAdapter { _, _ ->
|
|
BaseAdapter { _, _ ->
|
|
|
TjmdHomeSonViewHolder(
|
|
TjmdHomeSonViewHolder(
|
|
|
this.getAppCompatActivity(),
|
|
this.getAppCompatActivity(),
|
|
@@ -102,6 +114,32 @@ class TjmdHomeFragment : BaseFragment<TjmdHomeViewModel>(){
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ override fun onDestroy() {
|
|
|
|
|
+ super.onDestroy()
|
|
|
|
|
+ EventBus.getDefault().unregister(this)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
|
|
+ EventBus.getDefault().register(this)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
|
|
+ fun onQuoteMessageEvent(quoteMessageEvent: QuoteMessageEvent) {
|
|
|
|
|
+ /** 行情推送过来的goodsid **/
|
|
|
|
|
+ quoteMessageEvent.goodsid.forEach { goodid ->
|
|
|
|
|
+ LogUtils.eTag("dadafafsjhdkjahkjdhak",goodid)
|
|
|
|
|
+ //找到相应商品信息
|
|
|
|
|
+ val goodsInfo = viewModel.dataList.value?.find { it.goodsInfo?.goodsid == goodid }
|
|
|
|
|
+ viewModel.dataList.value?.indexOf(goodsInfo)?.let {
|
|
|
|
|
+ if (it != -1) {//刷新相应item
|
|
|
|
|
+ tjmdHomeMarketViewHolder?.notifyItemChanged(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private fun initViewFlipper(notice: List<NoticeData>) {
|
|
private fun initViewFlipper(notice: List<NoticeData>) {
|
|
|
for (i in 0 until notice.size) {
|
|
for (i in 0 until notice.size) {
|
|
|
val view = TextView(context)
|
|
val view = TextView(context)
|
|
@@ -143,7 +181,10 @@ class TjmdHomeFragment : BaseFragment<TjmdHomeViewModel>(){
|
|
|
): View? {
|
|
): View? {
|
|
|
return UI {
|
|
return UI {
|
|
|
viewModel.getBanner()
|
|
viewModel.getBanner()
|
|
|
- viewModel.setDataList()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ viewModel.setDataList(thisTag){isCompleted, err ->
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
viewModel.queryNotice()
|
|
viewModel.queryNotice()
|
|
|
verticalLayout {
|
|
verticalLayout {
|
|
@@ -438,21 +479,45 @@ class TjmdHomeFragment : BaseFragment<TjmdHomeViewModel>(){
|
|
|
topMargin = autoSize(40)
|
|
topMargin = autoSize(40)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ view {
|
|
|
|
|
+ background = resources.getDrawable(R.color.rma_hint_line_color_eee)
|
|
|
|
|
+ }.lparams(matchParent, autoSize(20))
|
|
|
|
|
|
|
|
recyclerView {
|
|
recyclerView {
|
|
|
|
|
+ dataRecyclerview = this
|
|
|
background = resources.getDrawable(R.color.white)
|
|
background = resources.getDrawable(R.color.white)
|
|
|
adapter = tjmdHomeMarketViewHolder
|
|
adapter = tjmdHomeMarketViewHolder
|
|
|
layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
|
layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
|
|
|
|
+
|
|
|
|
|
+ addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
|
|
+ override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
|
|
|
|
+ super.onScrollStateChanged(recyclerView, newState)
|
|
|
|
|
+ // DES: 找出当前可视Item位置
|
|
|
|
|
+ val linearLayoutManager = dataRecyclerview!!.layoutManager as LinearLayoutManager
|
|
|
|
|
+ if (newState == RecyclerView.SCROLL_STATE_IDLE) {// 这个判断是当recyclerview不滚动时
|
|
|
|
|
+ fistShow = linearLayoutManager.findFirstVisibleItemPosition()//获取第一个显示条目
|
|
|
|
|
+ lastShow = linearLayoutManager.findLastVisibleItemPosition()//获取最后一个显示条目
|
|
|
|
|
+ if (fistShow != -1 && lastShow != -1) {
|
|
|
|
|
+ viewModel.queryQuoteDay(
|
|
|
|
|
+ tag = thisTag ?: "",
|
|
|
|
|
+ first = fistShow,
|
|
|
|
|
+ last = lastShow,
|
|
|
|
|
+ list = viewModel.dataList.value ?: arrayListOf()
|
|
|
|
|
+ ) { isCompleted, err ->
|
|
|
|
|
+ if (isCompleted) {
|
|
|
|
|
+ dataRecyclerview.adapter?.notifyItemRangeChanged(fistShow, lastShow)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}.lparams(matchParent, autoSize(300))
|
|
}.lparams(matchParent, autoSize(300))
|
|
|
|
|
|
|
|
viewModel.dataList.bindOptional(context){
|
|
viewModel.dataList.bindOptional(context){
|
|
|
-// tjmdHomeMarketViewHolder.setNewData(it)
|
|
|
|
|
|
|
+ tjmdHomeMarketViewHolder.setNewData(it)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- imageView {
|
|
|
|
|
- imageResource = R.mipmap.tjmd_demo_image
|
|
|
|
|
- }.lparams(matchParent, autoSize(380))
|
|
|
|
|
chartview {
|
|
chartview {
|
|
|
visibility = View.GONE
|
|
visibility = View.GONE
|
|
|
val aaChartModel = AAChartModel()
|
|
val aaChartModel = AAChartModel()
|
|
@@ -476,15 +541,16 @@ class TjmdHomeFragment : BaseFragment<TjmdHomeViewModel>(){
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
viewModel.wrAverageTradePriceDataList.bindOptional(context) {
|
|
viewModel.wrAverageTradePriceDataList.bindOptional(context) {
|
|
|
|
|
+ if (it?.size ?: 0 > 0){
|
|
|
|
|
+ visibility = View.VISIBLE
|
|
|
|
|
+ }
|
|
|
val list = it
|
|
val list = it
|
|
|
val totalexposureelement = AASeriesElement()
|
|
val totalexposureelement = AASeriesElement()
|
|
|
.lineWidth(2f)
|
|
.lineWidth(2f)
|
|
|
.name("成交均价")
|
|
.name("成交均价")
|
|
|
.step(true)
|
|
.step(true)
|
|
|
- .data(list?.map { it.price }!!.toTypedArray())
|
|
|
|
|
-
|
|
|
|
|
-// aaChartModel.tooltipValueSuffix(resp.enumdicname)
|
|
|
|
|
- aaChartModel.categories(list.map { it.time }.toTypedArray())
|
|
|
|
|
|
|
+ .data(list?.map { it.s?.toDouble() ?: 0.0 }!!.toTypedArray())
|
|
|
|
|
+ aaChartModel.categories(list.map { it.getTime() }.toTypedArray())
|
|
|
aaChartModel.series(arrayOf(totalexposureelement))
|
|
aaChartModel.series(arrayOf(totalexposureelement))
|
|
|
aa_drawChartWithChartModel(aaChartModel)
|
|
aa_drawChartWithChartModel(aaChartModel)
|
|
|
}
|
|
}
|
|
@@ -504,7 +570,7 @@ class TjmdHomeFragment : BaseFragment<TjmdHomeViewModel>(){
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}.lparams(matchParent, matchParent)
|
|
}.lparams(matchParent, matchParent)
|
|
|
- viewModel.resetChartViewData()
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}.view
|
|
}.view
|