|
|
@@ -0,0 +1,308 @@
|
|
|
+package cn.muchinfo.rma.view.base.home.yrdz
|
|
|
+
|
|
|
+import android.annotation.SuppressLint
|
|
|
+import android.view.Gravity
|
|
|
+import androidx.fragment.app.Fragment
|
|
|
+import androidx.recyclerview.widget.RecyclerView
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.data.NoticeData
|
|
|
+import cn.muchinfo.rma.global.data.SiteColumnDetailData
|
|
|
+import cn.muchinfo.rma.global.data.WrSpotGroupTradeSumData
|
|
|
+import cn.muchinfo.rma.global.toShowTime3
|
|
|
+import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
+import cn.muchinfo.rma.lifecycle.getAppCompatActivity
|
|
|
+import cn.muchinfo.rma.view.autoWidget.*
|
|
|
+import cn.muchinfo.rma.view.base.home.AnnouncementViewHolder
|
|
|
+import cn.muchinfo.rma.view.base.home.HomeViewModel
|
|
|
+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.viewholder.YrdzInformationViewHolder
|
|
|
+import cn.muchinfo.rma.view.base.qhjhome.QhjInformationViewHolder
|
|
|
+import com.blankj.utilcode.util.TimeUtils
|
|
|
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
|
|
|
+import org.jetbrains.anko.*
|
|
|
+
|
|
|
+/**
|
|
|
+ * 咨讯
|
|
|
+ */
|
|
|
+
|
|
|
+class YrdzInformationUI(
|
|
|
+ private val baseFragment: Fragment,
|
|
|
+ private val viewModule: YrdzHomeViewModel
|
|
|
+) {
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ lateinit var recyclerView: RecyclerView
|
|
|
+
|
|
|
+ private val informationAdapter: BaseAdapter<SiteColumnDetailData, YrdzInformationViewHolder> =
|
|
|
+ BaseAdapter { _, _ -> YrdzInformationViewHolder(baseFragment, viewModule) }
|
|
|
+ val root = _FrameLayout(baseFragment.context!!).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModule.querySiteColumnDetail()
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+// bindTaskStatus(viewModule.status)
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(false)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = informationAdapter
|
|
|
+ isNestedScrollingEnabled = false
|
|
|
+ }.lparams(matchParent, matchParent) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+ viewModule.SiteColumnDetailList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ informationAdapter.setNewData(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 公告
|
|
|
+ */
|
|
|
+class YrAnnouncementUI(
|
|
|
+ private val baseFragment: Fragment,
|
|
|
+ private val viewModule: YrdzHomeViewModel
|
|
|
+) {
|
|
|
+
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ lateinit var recyclerView: RecyclerView
|
|
|
+
|
|
|
+ private val announcementAdapter: BaseAdapter<NoticeData, AnnouncementViewHolder> =
|
|
|
+ BaseAdapter { _, _ -> AnnouncementViewHolder(baseFragment.getAppCompatActivity()) }
|
|
|
+
|
|
|
+ val root = _FrameLayout(baseFragment.context!!).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModule.queryNotice()
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+// bindTaskStatus(viewModule.status)
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(false)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = announcementAdapter
|
|
|
+ isNestedScrollingEnabled = false
|
|
|
+ }.lparams(matchParent, matchParent) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+ viewModule.noticeDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ announcementAdapter.setNewData(it)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 消息
|
|
|
+ */
|
|
|
+class YrMessageUI(
|
|
|
+ private val baseFragment: Fragment,
|
|
|
+ private val viewModule: YrdzHomeViewModel
|
|
|
+) {
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ lateinit var recyclerView: RecyclerView
|
|
|
+
|
|
|
+ private val announcementAdapter: BaseAdapter<NoticeData, AnnouncementViewHolder> =
|
|
|
+ BaseAdapter { _, _ -> AnnouncementViewHolder(baseFragment.getAppCompatActivity()) }
|
|
|
+
|
|
|
+ val root = _FrameLayout(baseFragment.context!!).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModule.queryMessage()
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+// bindTaskStatus(viewModule.status)
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(false)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = announcementAdapter
|
|
|
+ isNestedScrollingEnabled = false
|
|
|
+ }.lparams(matchParent, matchParent) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+ viewModule.messageDataList.bindOptional(context) {
|
|
|
+ if (it?.isEmpty() == true || it?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ announcementAdapter.setNewData(it)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 指数
|
|
|
+ * @property baseFragment Fragment
|
|
|
+ * @property viewModule YrdzHomeViewModel
|
|
|
+ * @property swipeToLayout SwipeToLoadLayout
|
|
|
+ * @property statusLayout StatusLayout
|
|
|
+ * @property recyclerView RecyclerView
|
|
|
+ * @property indexAdapter BaseAdapter<WrSpotGroupTradeSumData, IndexViewHolder>
|
|
|
+ * @property root _FrameLayout
|
|
|
+ * @constructor
|
|
|
+ */
|
|
|
+class YrdzIndexUI(
|
|
|
+ private val baseFragment: Fragment,
|
|
|
+ private val viewModule: YrdzHomeViewModel
|
|
|
+) {
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ lateinit var recyclerView: RecyclerView
|
|
|
+
|
|
|
+ val indexAdapter: BaseAdapter<WrSpotGroupTradeSumData, IndexViewHolder> =
|
|
|
+ BaseAdapter { _, _ ->
|
|
|
+ IndexViewHolder(
|
|
|
+ baseFragment
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ val root = _FrameLayout(baseFragment.context!!).apply {
|
|
|
+ verticalLayout {
|
|
|
+ viewModule.querySpotGroupTradeSum()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ linearLayout {
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.yrdz_chart_icon
|
|
|
+ }.lparams(autoSize(43), autoSize(43)){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(0, autoSize(70), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ viewModule.spotGroupTradeSumDataList.bindOptional(context){
|
|
|
+ text = it?.prereckondate?.toShowTime3("dd","yyyyMMdd") + "日"
|
|
|
+ }
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(70), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ viewModule.spotGroupTradeSumDataList.bindOptional(context){
|
|
|
+ text = it?.reckondate?.toShowTime3("dd","yyyyMMdd") + "日"
|
|
|
+ }
|
|
|
+ text
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(70), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "涨跌"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(70), 1f)
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "涨幅"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent)
|
|
|
+ }.lparams(0, autoSize(70), 1f)
|
|
|
+ }.lparams(matchParent, autoSize(70))
|
|
|
+ statusLayout(contentBlock = {
|
|
|
+ statusLayout = this
|
|
|
+// bindTaskStatus(viewModule.status)
|
|
|
+ swipeToLoadLayout {
|
|
|
+ swipeToLayout = this
|
|
|
+ setEnableRefresh(false)
|
|
|
+ setEnableLoadMore(false)
|
|
|
+ setEnableScrollContentWhenLoaded(false)
|
|
|
+ setEnableLoadMoreWhenContentNotFull(false)
|
|
|
+ recyclerView {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ adapter = indexAdapter
|
|
|
+ isNestedScrollingEnabled = false
|
|
|
+ }.lparams(matchParent, matchParent) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ marginEnd = autoSize(20)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, emptyBlock = {
|
|
|
+ emptyView(hint = resources.getString(R.string.now_no_data))
|
|
|
+ }).lparams(matchParent, matchParent)
|
|
|
+ viewModule.spotGroupTradeSumDataList.bindOptional(context) {
|
|
|
+ if (it?.lst?.isEmpty() == true || it?.lst?.size == 0) {
|
|
|
+ statusLayout.showEmpty()
|
|
|
+ } else {
|
|
|
+ if (swipeToLayout.getIsRefreshing()) {
|
|
|
+ swipeToLayout.finishRefresh()
|
|
|
+ }
|
|
|
+ statusLayout.showSuccess()
|
|
|
+ indexAdapter.setNewData(it?.lst)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|