|
|
@@ -0,0 +1,420 @@
|
|
|
+package cn.muchinfo.rma.view.base.home.tjmd
|
|
|
+
|
|
|
+import android.content.Intent
|
|
|
+import android.graphics.Rect
|
|
|
+import android.graphics.Typeface
|
|
|
+import android.net.Uri
|
|
|
+import android.os.Bundle
|
|
|
+import android.text.TextUtils
|
|
|
+import android.view.Gravity
|
|
|
+import android.view.LayoutInflater
|
|
|
+import android.view.View
|
|
|
+import android.view.ViewGroup
|
|
|
+import android.widget.FrameLayout
|
|
|
+import android.widget.TextView
|
|
|
+import android.widget.ViewFlipper
|
|
|
+import androidx.annotation.NonNull
|
|
|
+import androidx.annotation.Nullable
|
|
|
+import androidx.cardview.widget.CardView
|
|
|
+import androidx.fragment.app.Fragment
|
|
|
+import androidx.fragment.app.FragmentPagerAdapter
|
|
|
+import androidx.viewpager.widget.ViewPager
|
|
|
+import cn.bingoogolapple.bgabanner.BGABanner
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.data.BannerData
|
|
|
+import cn.muchinfo.rma.global.data.NoticeData
|
|
|
+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.BaseFragment
|
|
|
+import cn.muchinfo.rma.view.base.WebActivity
|
|
|
+import cn.muchinfo.rma.view.base.app.Constant
|
|
|
+import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
+import cn.muchinfo.rma.view.base.hnstmain.bookingwarehouse.BookingWarehouseActivity
|
|
|
+import cn.muchinfo.rma.view.base.hnstmain.performance.PerformanceInformationActivity
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.emptyView
|
|
|
+import cn.muchinfo.rma.view.base.home.reference.ReferenceActivity
|
|
|
+import cn.muchinfo.rma.view.base.home.yrdz.YrdzHomeFragment
|
|
|
+import cn.muchinfo.rma.view.base.home.yrdz.YrdzNoticeActivity
|
|
|
+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.YrdzMarketFragment
|
|
|
+import cn.muchinfo.rma.view.eventbus.MainTabSelectMessageEvent
|
|
|
+import com.blankj.utilcode.util.*
|
|
|
+import com.facebook.drawee.view.SimpleDraweeView
|
|
|
+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.information_management.hnstocks.message.MessageDetailsActivity
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
+import org.jetbrains.anko.*
|
|
|
+import org.jetbrains.anko.support.v4.UI
|
|
|
+import org.jetbrains.anko.support.v4.viewPager
|
|
|
+
|
|
|
+/**
|
|
|
+ * 天津麦顿首页
|
|
|
+ */
|
|
|
+class TjmdHomeFragment : BaseFragment<TjmdHomeViewModel>(){
|
|
|
+
|
|
|
+
|
|
|
+ companion object {
|
|
|
+ fun newInstance() = YrdzHomeFragment()
|
|
|
+ }
|
|
|
+
|
|
|
+ // 下拉刷新
|
|
|
+ private lateinit var swipeToLayout: SwipeToLoadLayout
|
|
|
+ private lateinit var statusLayout: StatusLayout
|
|
|
+
|
|
|
+ lateinit var segment: QMUITabSegment
|
|
|
+ lateinit var segment1: QMUITabSegment
|
|
|
+ var selectedTabIndex: Int = 0
|
|
|
+ private lateinit var viewPager: ViewPager
|
|
|
+
|
|
|
+ lateinit var noticeViewFlipper : ViewFlipper
|
|
|
+
|
|
|
+ private fun initViewFlipper(notice: List<NoticeData>) {
|
|
|
+ for (i in 0 until notice.size) {
|
|
|
+ val view = TextView(context)
|
|
|
+ val params = FrameLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
+ ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
+ )
|
|
|
+ params.gravity = Gravity.LEFT or Gravity.CENTER_VERTICAL
|
|
|
+ view.layoutParams = params
|
|
|
+ view.text = notice[i].title
|
|
|
+ view.maxLines = 1
|
|
|
+ view.ellipsize = TextUtils.TruncateAt.END
|
|
|
+ view.setTextColor(context?.resources?.getColor(R.color.rma_black_33)!!)
|
|
|
+ view.textSize = 12f
|
|
|
+ view.setOnClickListener(View.OnClickListener {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.putExtra("data",notice.get(i))
|
|
|
+ intent.setClass(context!!, MessageDetailsActivity::class.java)
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ })
|
|
|
+ noticeViewFlipper.addView(view)
|
|
|
+ }
|
|
|
+ //是否自动开始滚动
|
|
|
+ noticeViewFlipper.isAutoStart = true
|
|
|
+ //滚动时间
|
|
|
+ noticeViewFlipper.flipInterval = 3000
|
|
|
+ //开始滚动
|
|
|
+ noticeViewFlipper.startFlipping()
|
|
|
+ //出入动画
|
|
|
+ noticeViewFlipper.setOutAnimation(context, R.anim.slide_out_right)
|
|
|
+ noticeViewFlipper.setInAnimation(context, R.anim.slide_in_left)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ override fun onCreateView(
|
|
|
+ inflater: LayoutInflater,
|
|
|
+ container: ViewGroup?,
|
|
|
+ savedInstanceState: Bundle?
|
|
|
+ ): View? {
|
|
|
+ return UI {
|
|
|
+ viewModel.getBanner()
|
|
|
+ viewModel.setDataList()
|
|
|
+ viewModel.queryNotice()
|
|
|
+ verticalLayout {
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.main_title_bg_color)
|
|
|
+ verticalLayout {
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ textView {
|
|
|
+ text = "麦顿"
|
|
|
+ textColorInt = R.color.white
|
|
|
+ textSizeAuto = 36
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(autoSize(620), autoSize(90)) {
|
|
|
+ marginStart = autoSize(140)
|
|
|
+ }
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.setClass(context, YrdzNoticeActivity::class.java)
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ }
|
|
|
+ imageResource = R.mipmap.yrdz_topright_icon
|
|
|
+ }.lparams(autoSize(45), autoSize(45)) {
|
|
|
+ marginStart = autoSize(32)
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(120))
|
|
|
+
|
|
|
+ relativeLayout {
|
|
|
+ nestedScrollView{
|
|
|
+ setOnScrollChangeListener(object : View.OnScrollChangeListener {
|
|
|
+ override fun onScrollChange(
|
|
|
+ p0: View?,
|
|
|
+ p1: Int,
|
|
|
+ p2: Int,
|
|
|
+ p3: Int,
|
|
|
+ p4: Int
|
|
|
+ ) {
|
|
|
+ val scrollRect = Rect()
|
|
|
+ getHitRect(scrollRect)
|
|
|
+ LogUtils.eTag("adakhsfkjahsfa", "x = " + p1 + "y = " + p2)
|
|
|
+ if (p2 > 1000) {
|
|
|
+ segment1.visibility = View.VISIBLE
|
|
|
+ } else {
|
|
|
+ segment1.visibility = View.INVISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ inflateLayout<BGABanner>(R.layout.banner) {
|
|
|
+ // TODO 目前没有banner
|
|
|
+ viewModel.bannerList.bindOptional(context) {
|
|
|
+ setData(
|
|
|
+ R.layout.item_fresco,
|
|
|
+ it,
|
|
|
+ null
|
|
|
+ )
|
|
|
+ }
|
|
|
+ setDelegate { banner, itemView, model, position ->
|
|
|
+ val data = model as BannerData
|
|
|
+ val intent = Intent()
|
|
|
+ intent.putExtra("url",data.url)
|
|
|
+ intent.putExtra("title",data.title)
|
|
|
+ intent.setClass(context, WebActivity::class.java)
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ }
|
|
|
+// setDelegate(new BGABanner.Delegate() {
|
|
|
+// @Override
|
|
|
+// public void onBannerItemClick(BGABanner banner, View itemView, @Nullable Object model, int position) {
|
|
|
+//
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+
|
|
|
+ setAdapter(object : BGABanner.Adapter<CardView, BannerData> {
|
|
|
+ override fun fillBannerItem(
|
|
|
+ banner: BGABanner?,
|
|
|
+ itemView: CardView?,
|
|
|
+ model: BannerData?,
|
|
|
+ position: Int
|
|
|
+ ) {
|
|
|
+ val simpleDraweeView: SimpleDraweeView =
|
|
|
+ itemView!!.findViewById(R.id.sdv_item_fresco_content)
|
|
|
+ simpleDraweeView.setImageURI(
|
|
|
+ Uri.parse(
|
|
|
+ SPUtils.getInstance().getString(
|
|
|
+ Constant.openApiUrl) + model?.imagepath?.substring(1)))
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(400))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.yrdz_nctice_icon
|
|
|
+ }.lparams(autoSize(36), autoSize(36)){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ viewFlipper {
|
|
|
+ noticeViewFlipper = this
|
|
|
+ viewModel.noticeDataList.bindOptional(context){
|
|
|
+ initViewFlipper(it ?: arrayListOf())
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(72)){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(72))
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ //参考行情
|
|
|
+ relativeLayout {
|
|
|
+ verticalLayout {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.setClass(
|
|
|
+ context,
|
|
|
+ ReferenceActivity::class.java
|
|
|
+ )
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ }
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.yrdz_reference_prices
|
|
|
+ }.lparams(autoSize(72), autoSize(72)) {
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "参考行情"
|
|
|
+ textColorInt = R.color.black
|
|
|
+ textSizeAuto = 26
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.GONE
|
|
|
+ textColorInt = R.color.p_global_write_color
|
|
|
+ textSizeAuto = 15
|
|
|
+ setPadding(
|
|
|
+ autoSize(10),
|
|
|
+ autoSize(6),
|
|
|
+ autoSize(10),
|
|
|
+ autoSize(6)
|
|
|
+ )
|
|
|
+ backgroundDrawable =
|
|
|
+ createRoundRectDrawable("#fe671a", 45)
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(130)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(225), matchParent)
|
|
|
+
|
|
|
+ relativeLayout {
|
|
|
+ verticalLayout {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ EventBus.getDefault().post(MainTabSelectMessageEvent(1))// 黄老板说的要跳去仓单贸易
|
|
|
+ }
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.yrdz_home_wymh_icon
|
|
|
+ }.lparams(autoSize(72), autoSize(72)) {
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "我要买货"
|
|
|
+ textColorInt = R.color.black
|
|
|
+ textSizeAuto = 26
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.GONE
|
|
|
+ textColorInt = R.color.p_global_write_color
|
|
|
+ textSizeAuto = 15
|
|
|
+ setPadding(
|
|
|
+ autoSize(10),
|
|
|
+ autoSize(6),
|
|
|
+ autoSize(10),
|
|
|
+ autoSize(6)
|
|
|
+ )
|
|
|
+ backgroundDrawable =
|
|
|
+ createRoundRectDrawable("#fe671a", 45)
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(130)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(225), matchParent)
|
|
|
+
|
|
|
+ relativeLayout {
|
|
|
+ verticalLayout {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.setClass(
|
|
|
+ context,
|
|
|
+ BookingWarehouseActivity::class.java
|
|
|
+ )
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ }
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.yrdz_home_wyys_icon
|
|
|
+ }.lparams(autoSize(72), autoSize(72)) {
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "我要预售"
|
|
|
+ textColorInt = R.color.black
|
|
|
+ textSizeAuto = 26
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.GONE
|
|
|
+ textColorInt = R.color.p_global_write_color
|
|
|
+ textSizeAuto = 15
|
|
|
+ setPadding(
|
|
|
+ autoSize(10),
|
|
|
+ autoSize(6),
|
|
|
+ autoSize(10),
|
|
|
+ autoSize(6)
|
|
|
+ )
|
|
|
+ backgroundDrawable =
|
|
|
+ createRoundRectDrawable("#fe671a", 45)
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(130)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(225), matchParent)
|
|
|
+
|
|
|
+ relativeLayout {
|
|
|
+ verticalLayout {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ val intent = Intent()
|
|
|
+ intent.setClass(
|
|
|
+ context,
|
|
|
+ PerformanceInformationActivity::class.java
|
|
|
+ )
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ }
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.main_business_5
|
|
|
+ }.lparams(autoSize(72), autoSize(72)) {
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = "履约管理"
|
|
|
+ textColorInt = R.color.black
|
|
|
+ textSizeAuto = 26
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ topMargin = autoSize(20)
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ textView {
|
|
|
+ visibility = View.GONE
|
|
|
+ textColorInt = R.color.p_global_write_color
|
|
|
+ textSizeAuto = 15
|
|
|
+ setPadding(
|
|
|
+ autoSize(10),
|
|
|
+ autoSize(6),
|
|
|
+ autoSize(10),
|
|
|
+ autoSize(6)
|
|
|
+ )
|
|
|
+ backgroundDrawable =
|
|
|
+ createRoundRectDrawable("#fe671a", 45)
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(130)
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(225), matchParent)
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(140)) {
|
|
|
+ topMargin = autoSize(40)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, matchParent)
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.view
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|