YdlHomeFragment.kt 22.2 KB
Newer Older
徐健 committed
1 2 3
package com.yidianling.home.ui.fragment

import android.app.Dialog
YKai committed
4
import android.content.Context
徐健 committed
5 6 7 8
import android.graphics.Typeface
import android.os.Build
import android.text.TextUtils
import android.view.View
konghaorui committed
9
import android.widget.FrameLayout
徐健 committed
10 11 12
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
YKai committed
13
import androidx.core.content.ContextCompat
YKai committed
14
import androidx.fragment.app.FragmentActivity
YKai committed
15 16
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
konghaorui committed
17
import com.alibaba.android.arouter.facade.annotation.Route
YKai committed
18
import com.google.android.material.tabs.TabLayout
徐健 committed
19 20 21 22 23 24 25 26 27 28 29 30 31
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.base.BaseMvpFragment
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.consultant.api.IConsultantService
import com.yidianling.home.R
import com.yidianling.home.adapter.YdlHomeAdapter
konghaorui committed
32 33
import com.yidianling.home.constants.HomeBIConstants
import com.yidianling.home.constract.HomeViewConfig
徐健 committed
34 35 36 37 38 39 40 41
import com.yidianling.home.constract.IHomeContract
import com.yidianling.home.dialog.ActivityDialog
import com.yidianling.home.dialog.ActivityGuideDialog
import com.yidianling.home.event.HomeImpl
import com.yidianling.home.listener.HomeConfideRecyleSuspendListener
import com.yidianling.home.model.bean.*
import com.yidianling.home.presenter.HomePresenterImpl
import com.yidianling.home.ui.view.CouponDialog
42
import com.yidianling.home.ui.view.HomeSpaceItemDecoration
徐健 committed
43
import com.yidianling.home.utils.HomeAnimUtils
徐健 committed
44
import com.yidianling.user.api.service.IUserService
konghaorui committed
45
import kotlinx.android.synthetic.ydl.home_fragment.*
徐健 committed
46 47 48 49 50 51 52 53 54


/**
 * @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
 * @描述: 壹点灵首页fragment
 * @Copyright Copyright (c) 2019
 * @Company 壹点灵
 * @date 2019/02/12
 */
konghaorui committed
55
@Route(path = "/home/home")
56
open class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>(),
YKai committed
57 58
    IHomeContract.View,
    SwipeRefreshLayout.OnRefreshListener {
YKai committed
59 60
    private lateinit var mActivity:FragmentActivity
    private lateinit var mContext:Context
konghaorui committed
61 62 63
    open var adapter: YdlHomeAdapter? = null
    open var homeEvent: HomeImpl? = null
    open var dialog: CouponDialog? = null
YKai committed
64

徐健 committed
65
    //双11活动弹窗
konghaorui committed
66
    open var aa: Dialog? = null
徐健 committed
67 68 69 70 71 72


    /**
     * tablayou上次选中的tab下标
     */
    private var confideLastSelectPosition = 0
73
    private var confideLastSelectType = ""
YKai committed
74

徐健 committed
75 76 77 78 79
    /**
     * TabLayout.OnTabSelectedListener
     */
    private var consultTabListener: TabLayout.OnTabSelectedListener? = null
    private var confideTabListener: TabLayout.OnTabSelectedListener? = null
YKai committed
80

徐健 committed
81 82 83 84
    /**
     * 咨询tablayout上次选中的下标
     */
    private var consultLastSelectPosition = 0
YKai committed
85 86
    private var consultLastSelectType = ""

徐健 committed
87 88 89
    /**
     * 悬浮tablayout监听事件
     */
YKai committed
90 91
    open lateinit var scrollListner: HomeConfideRecyleSuspendListener

徐健 committed
92 93 94
    //咨询模块数据缓存
    private var consultCategoryDate: MutableList<HomeHeaderBean.ConsultCategoryDateBean>? = null

konghaorui committed
95 96
    open var searchText: String = ""
    open var doctorName: String = ""
徐健 committed
97

98 99 100 101 102
    /**
     * 如果是第一次加载,则调用所有接口进行刷新,否则,只调用咨询和倾诉接口
     */
    private var isFromCreate: Boolean = true

徐健 committed
103
    override fun layoutResId(): Int {
konghaorui committed
104
        return R.layout.home_fragment
徐健 committed
105 106 107
    }

    override fun initDataAndEvent() {
108 109 110
//        val homeViewOrder = HomeViewConfig.HomeViewOrder()
//
//        homeViewOrder.bannerIndex = -1
111
//        homeViewOrder.testsIndex = 1
112 113 114 115 116 117 118 119 120 121 122 123
//        homeViewOrder.consultIndex = 2
//        homeViewOrder.footerIndex = 3
//
//        homeViewOrder.fmIndex = null
//        homeViewOrder.articleIndex = null
//        homeViewOrder.dynamicIndex = null
//        homeViewOrder.museIndex = null
//        homeViewOrder.confideIndex = null
//        homeViewOrder.courseIndex = null
//        homeViewOrder.buttonIndex = null
//
//        HomeViewConfig.setOrder(homeViewOrder)
YKai committed
124 125
        mActivity = requireActivity()
        mContext = requireContext()
konghaorui committed
126 127 128 129 130
        initHomeEvent()
        initView()
        initTopButtonBanner()
        initAdapter()
    }
徐健 committed
131

konghaorui committed
132
    open fun initHomeEvent() {
YKai committed
133
        homeEvent = HomeImpl(mActivity, this)
徐健 committed
134 135 136
    }

    private fun initAdapter() {
YKai committed
137 138
        mPresenter?.localHomeData(mContext, "home_data.json")
        adapter = YdlHomeAdapter(mContext, homeEvent!!, ArrayList())
徐健 committed
139 140 141
        val layoutManager = LinearLayoutManager(context)
        home_module_fragment_recycler.layoutManager = layoutManager
        home_module_fragment_recycler.adapter = adapter
142 143
        val space = resources.getDimension(R.dimen.platform_dp_24).toInt()
        home_module_fragment_recycler.addItemDecoration(HomeSpaceItemDecoration(space))
konghaorui committed
144 145
        initRvListener()
    }
徐健 committed
146

konghaorui committed
147
    open fun initRvListener() {
YKai committed
148 149 150 151 152 153
        if (HomeViewConfig.getOrder().bannerIndex != -1) {
            home_module_fragment_recycler.addOnScrollListener(
                homeEvent!!.onPageScroll(
                    view_rl_top_bg
                )!!
            )
154
        }
徐健 committed
155 156 157 158 159 160
        scrollListner = HomeConfideRecyleSuspendListener()
        home_module_fragment_recycler.addOnScrollListener(scrollListner)
        setSuspendListener()
    }

    private fun initView() {
YKai committed
161
        if (HomeViewConfig.getOrder().bannerIndex == null || HomeViewConfig.getOrder().bannerIndex == -1) {
konghaorui committed
162 163
            var marginTop = this.resources.getDimension(R.dimen.home_home_title_bar_height)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
YKai committed
164
                val statusBarHeight = StatusBarUtils.getStatusBarHeight(mActivity)
konghaorui committed
165 166 167 168 169 170 171
                marginTop += statusBarHeight
            }
            val lp = home_swipe_refresh_layout.layoutParams as FrameLayout.LayoutParams
            lp.topMargin = marginTop.toInt()
            home_swipe_refresh_layout.layoutParams = lp
        }
        searchText = this.resources.getText(R.string.home_search_hint).toString()
徐健 committed
172
        home_swipe_refresh_layout?.setOnRefreshListener(this)
YKai committed
173 174
        home_swipe_refresh_layout?.setColorSchemeColors(
            ContextCompat.getColor(
YKai committed
175
                mContext,
YKai committed
176 177 178
                R.color.platform_main_theme
            )
        )
徐健 committed
179 180
        home_swipe_refresh_layout?.setProgressViewOffset(false, 0, 200)
        home_service_call.setOnClickListener { homeEvent?.serviceCallClick() }
konghaorui committed
181
        initSearchBar()
徐健 committed
182 183 184
        initStatus()
    }

konghaorui committed
185
    open fun initSearchBar() {
YKai committed
186
        if (!TextUtils.isEmpty(doctorName)) {
konghaorui committed
187 188 189 190 191 192
            searchText = doctorName
        }
        home_tv.setOnClickListener { homeEvent?.searchTvClick(searchText) }
        home_tv.text = searchText
    }

徐健 committed
193 194 195 196 197
    /**
     * 初始化状态栏位置
     */
    private fun initStatus() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
YKai committed
198
            val statusBarHeight = StatusBarUtils.getStatusBarHeight(mActivity)
konghaorui committed
199
            var homeTitleBarHeight = resources.getDimension(R.dimen.home_home_title_bar_height)
徐健 committed
200 201 202 203 204 205 206 207 208 209 210 211
            val lp1 = view_rl_top_bg.layoutParams as RelativeLayout.LayoutParams
            lp1.height = (homeTitleBarHeight + statusBarHeight).toInt()
            view_rl_top_bg.layoutParams = lp1

            val lp2 = rl_top.layoutParams as RelativeLayout.LayoutParams
            lp2.topMargin = statusBarHeight
            rl_top.layoutParams = lp2
        }
    }

    override fun initDataAndEventLazy() {
    }
YKai committed
212

konghaorui committed
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
    /**
     * 设置顶部导航栏 功能点击事件
     */
    private fun initTopButtonBanner() {

        tv_consult.setOnClickListener {
            homeEvent?.reservationExpertsClick()
        }
        tv_confide.setOnClickListener {
            homeEvent?.nowConfideClick()
        }
        tv_course.setOnClickListener {
            homeEvent?.psychologyClassClick()
        }
        tv_test.setOnClickListener {
            homeEvent?.psychologyTestClick()
        }
        rl_backTop.setOnClickListener {
            home_module_fragment_recycler.scrollToPosition(0)
        }
    }
YKai committed
234

konghaorui committed
235
    override fun startAnim() {
YKai committed
236
        HomeAnimUtils.startAnim(mContext, rl_top, rl_search, home_service_call, home_tv)
YKai committed
237 238 239 240 241 242 243
        HomeAnimUtils.startSearchShow(
            ll_top_function,
            view_search_input_bg,
            home_tv,
            iv_search_icon,
            img_ad
        )
konghaorui committed
244 245 246
    }

    override fun endAnim() {
YKai committed
247
        HomeAnimUtils.endAnim(mContext, rl_top, rl_search, home_tv, home_service_call, this)
YKai committed
248 249 250 251 252 253 254
        HomeAnimUtils.startSearchHide(
            ll_top_function,
            view_search_input_bg,
            home_tv,
            iv_search_icon,
            img_ad
        )
konghaorui committed
255 256 257 258 259
    }

    override fun getSearchContent(): String {
        return searchText
    }
徐健 committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279

    override fun createPresenter(): HomePresenterImpl {
        return HomePresenterImpl()
    }

    override fun onRefresh() {
        home_swipe_refresh_layout.isRefreshing = true
        mPresenter?.refreshHomeData()
    }

    override fun resetModuleTabPosition() {
        adapter?.confideSelectPosition = 0
        adapter?.consultSelectPosition = 0
    }


    /**
     * 设置悬浮顶部监听数据
     */
    private fun setSuspendListener() {
280 281 282 283 284 285
        scrollListner.setContext(mContext)
        scrollListner.setHomeView(this)
        scrollListner.setConfideFilterView(ll_layout)
        scrollListner.setConsultFilterView(ll_consultLayout)
        scrollListner.setSectionAdapter(adapter!!)
        scrollListner.setPhoneCallImageView(home_service_call)
徐健 committed
286 287 288 289 290 291 292 293 294
    }

    /**
     * 获取倾述列表数据
     * @param type 倾述类型
     * @param selectPosition 选中的position
     */
    override fun getConfideData(type: String, selectPosition: Int) {
        confideLastSelectPosition = selectPosition
295
        confideLastSelectType = type
徐健 committed
296 297 298 299 300 301 302 303
        mPresenter?.getConfideData(type, selectPosition)
    }

    /**
     * 获取咨询列表数据
     */
    override fun getConsultData(type: String, selectPosition: Int) {
        consultLastSelectPosition = selectPosition
304
        consultLastSelectType = type
徐健 committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
        mPresenter?.getConsultData(type, selectPosition)
    }

    override fun homeHeadResponse(homeHeaderBean: HomeHeaderBean) {
        //展示活动数据
        val act = homeHeaderBean.activityResponse

        if (act != null) {
            if (!TextUtils.isEmpty(act!!.imageUrl)) {
                img_ad.visibility = View.VISIBLE
                GlideApp.with(this).load(act!!.imageUrl).into(img_ad)
                img_ad.setOnClickListener {
                    if (Utils.isFastClick()) {
                        //防止连击
                        return@setOnClickListener
                    }
                    if (act.btnLinkurl != null && act.btnLinkurl!!.startsWith("http")) {
                        NewH5Activity.start(activity, H5Params(act.btnLinkurl!!, null))
                    } else {
                        YDLRouterManager.router(act.btnLinkurl)
                    }
                }
            } else {
                img_ad.visibility = View.GONE
            }

            if (!TextUtils.isEmpty(act.imageBanner)) {
                val va = SharedPreferencesEditor.getString(act.imageBanner)
                if (TextUtils.equals("yes", va)) {
                    //已经显示过,不再弹出
                    return
                }
            }

徐健 committed
339
            if (!ModularServiceManager.provide(IUserService::class.java).isLogin()) {
徐健 committed
340 341 342 343 344 345
                //未登录不显示
                return
            }
            if (!TextUtils.isEmpty(act.imageBanner)) {
                //展示弹窗
                if (aa == null) {
YKai committed
346
                    aa = ActivityDialog(mActivity, act.imageBanner, act.linkUrl, act.title)
徐健 committed
347 348 349
                    aa?.show()
                    aa?.setOnDismissListener {
                        //文案不为空才显示引导--李思开
YKai committed
350
                        if (!TextUtils.isEmpty(act.title)) {
YKai committed
351
                            ActivityGuideDialog(mActivity, act.imageUrl, act.title).show()
徐健 committed
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
                        }
                    }
                }
                //仅展示一次,以后不再展示
                SharedPreferencesEditor.putString(act.imageBanner, "yes")
            }
        }
    }

    override fun homeDataResponse(list: MutableList<HomePagerDataBean>) {
        home_swipe_refresh_layout.isRefreshing = false
        //更新首页数据
        adapter?.updateItems(list)

        if (!TextUtils.isEmpty(list[0].headerBean?.doctorName)) {
konghaorui committed
367 368
            doctorName = list[0].headerBean?.doctorName!!
            initSearchBar()
徐健 committed
369 370 371 372 373 374 375
        }

        //每次全局更新后重置下标位
        confideLastSelectPosition = 0
        consultLastSelectPosition = 0
        //初始化fragment中的tablayout布局,悬停效果使用
        for (bean in list) {
徐健 committed
376
            //咨询模块
konghaorui committed
377
            if (bean.type == HomeViewConfig.getOrder().bannerIndex) {
徐健 committed
378 379
                initTabLayout(bean.headerBean!!.listenCategoryDate)
                initConsultTabLayout(bean.headerBean!!.consultCategoryData)
380
                consultLastSelectType = bean.headerBean!!.consultCategoryData!![0].id.toString()
徐健 committed
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
            }
        }
    }

    /**
     * 初始化fragment中的tablayout布局,悬停效果使用
     */
    private fun initTabLayout(listenCategoryDate: List<HomeHeaderBean.ListenCategoryDateBean>?) {
        if (confideTabListener == null) {
            confideTabListener = ConfideExpertTabSelectedListener(listenCategoryDate!!, tab_layout)
            tab_layout.addOnTabSelectedListener(confideTabListener!!)
        }

        tab_layout.removeAllTabs()
        for ((index, bean) in listenCategoryDate!!.withIndex()) {
YKai committed
396 397 398 399 400 401 402 403 404
            tab_layout.addTab(
                tab_layout.newTab().setText(bean.name),
                index == confideLastSelectPosition
            )
        }
        var textView =
            ((tab_layout!!.getChildAt(0) as LinearLayout).getChildAt(confideLastSelectPosition) as LinearLayout).getChildAt(
                1
            )
徐健 committed
405 406
        if (textView != null && textView is TextView) {
            textView.textSize = 17f
YKai committed
407
            textView.setTextColor(ContextCompat.getColor(mActivity, R.color.platform_color_242424))
徐健 committed
408 409 410 411 412 413 414 415 416
            textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
        }
    }

    /**
     * 初始化fragment中咨询tablayout布局,悬停效果使用
     */
    private fun initConsultTabLayout(listenCategoryDate: List<HomeHeaderBean.ConsultCategoryDateBean>?) {
        if (consultTabListener == null) {
YKai committed
417 418
            consultTabListener =
                ConsultExpertTabSelectedListener(listenCategoryDate!!, tab_consultLayout)
徐健 committed
419 420 421 422 423 424
            tab_consultLayout.addOnTabSelectedListener(consultTabListener!!)
        }
        if (null == consultCategoryDate) {
            consultCategoryDate = ArrayList()
        }
        //如果 数据不变 则不重新构建
YKai committed
425 426 427 428
        if (null != listenCategoryDate && consultCategoryDate!!.size == listenCategoryDate.size && consultCategoryDate!!.retainAll(
                listenCategoryDate
            )
        ) {
徐健 committed
429 430 431 432 433 434 435 436
            return
        }
        consultCategoryDate?.clear()
        if (null != listenCategoryDate) {
            consultCategoryDate?.addAll(listenCategoryDate)
        }
        tab_consultLayout.removeAllTabs()
        for ((index, bean) in listenCategoryDate!!.withIndex()) {
YKai committed
437 438 439 440
            tab_consultLayout.addTab(
                tab_consultLayout.newTab().setText(bean.name),
                index == confideLastSelectPosition
            )
徐健 committed
441 442
        }

YKai committed
443 444 445
        val textView = ((tab_consultLayout!!.getChildAt(0) as LinearLayout).getChildAt(
            confideLastSelectPosition
        ) as LinearLayout).getChildAt(1)
徐健 committed
446 447
        if (textView != null && textView is TextView) {
            textView.textSize = 17f
YKai committed
448
            textView.setTextColor(ContextCompat.getColor(mActivity, R.color.platform_color_242424))
徐健 committed
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
            textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
        }
    }

    override fun confideDataResponse(data: HomeConfideBean, selectPosition: Int) {
        //更新倾述列表数据
        adapter?.updateConfideData(data, selectPosition)
    }

    override fun consultDataResponse(data: HomeConsultBean, selectPosition: Int) {
        //更新咨询列表数据
        adapter?.updateConsultData(data, selectPosition)
    }

    override fun askDataResponse(data: HomeAskBean, position: Int) {
        //更新问答模块数据
        adapter?.updateAskData(data, position)
    }

    override fun homeDataFail(msg: String) {
        home_swipe_refresh_layout?.isRefreshing = false
//        ToastHelper.show(msg)
    }

    override fun askZan(position: Int, index: Int, id: String) {
        mPresenter?.askZan(position, index, id)
    }

    override fun askFocus(position: Int, id: String) {
        mPresenter?.askFocus(position, id)
    }

    override fun showHomeProgress() {
        showHomeProgress()
    }

    override fun showRefreshLayout() {
        home_swipe_refresh_layout?.isRefreshing = true
    }

    override fun dismissHomeProgress() {
        dismissHomeProgress()
    }

    override fun setUserVisibleHint(isVisibleToUser: Boolean) {
        super.setUserVisibleHint(isVisibleToUser)
        if (isVisibleToUser && isResumed) {
            showConsultAssistantDialog()
        } else {
            hideConsultAssistantDialog()
        }
        if (isVisibleToUser && isResumed) {
            onResume()
        }
    }

    private fun showConsultAssistantDialog() {
YKai committed
506
        ModularServiceManager.provide(IConsultantService::class.java)
YKai committed
507
            .showConsultAssistantDialog(mActivity)
徐健 committed
508 509 510 511 512 513 514 515 516 517
    }

    private fun hideConsultAssistantDialog() {
        ModularServiceManager.provide(IConsultantService::class.java).hideConsultAssistantDialog()
    }

    override fun onResume() {
        super.onResume()
        if (userVisibleHint) {
            ActionCountUtils.count(HomeBIConstants.YDL_USER_MAIN_PAGE_VISIT)
518 519 520 521

            if (isFromCreate) {
                isFromCreate = false
                mPresenter?.loadHomeData()
YKai committed
522
            } else {
523 524 525
                mPresenter?.getConsultData(consultLastSelectType, consultLastSelectPosition)
                mPresenter?.getConfideData(confideLastSelectType, confideLastSelectPosition)
            }
徐健 committed
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546

            showConsultAssistantDialog()
        }
    }

    /**
     * 咨询楼层tablayout
     */
    inner class ConsultExpertTabSelectedListener : TabLayout.OnTabSelectedListener {
        private var list: List<HomeHeaderBean.ConsultCategoryDateBean>? = null
        private var tabLayout: TabLayout? = null

        constructor(list: List<HomeHeaderBean.ConsultCategoryDateBean>, tabLayout: TabLayout) {
            this.list = list
            this.tabLayout = tabLayout
        }

        override fun onTabReselected(tab: TabLayout.Tab?) {
        }

        override fun onTabUnselected(tab: TabLayout.Tab?) {
YKai committed
547 548 549 550
            var textView =
                ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
                    1
                )
徐健 committed
551 552
            if (textView != null && textView is TextView) {
                textView.textSize = 15f
YKai committed
553 554 555 556 557 558
                textView.setTextColor(
                    ContextCompat.getColor(
                        activity!!,
                        R.color.platform_color_333333
                    )
                )
徐健 committed
559 560 561 562 563 564 565
            }
        }

        override fun onTabSelected(tab: TabLayout.Tab?) {
            if (tab!!.position == consultLastSelectPosition) {
                return
            }
YKai committed
566 567 568 569
            var textView =
                ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
                    1
                )
徐健 committed
570 571
            if (textView != null && textView is TextView) {
                textView.textSize = 17f
YKai committed
572 573 574 575 576 577
                textView.setTextColor(
                    ContextCompat.getColor(
                        activity!!,
                        R.color.platform_color_242424
                    )
                )
徐健 committed
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
                textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
            }
            homeEvent!!.getConsultData(list!![tab!!.position], tab!!.position)
        }
    }

    inner class ConfideExpertTabSelectedListener : TabLayout.OnTabSelectedListener {
        private var list: List<HomeHeaderBean.ListenCategoryDateBean>? = null
        private var tabLayout: TabLayout? = null

        constructor(list: List<HomeHeaderBean.ListenCategoryDateBean>, tabLayout: TabLayout) {
            this.list = list
            this.tabLayout = tabLayout
        }

        override fun onTabReselected(tab: TabLayout.Tab?) {
        }

        override fun onTabUnselected(tab: TabLayout.Tab?) {
YKai committed
597 598 599 600
            var textView =
                ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
                    1
                )
徐健 committed
601 602
            if (textView != null && textView is TextView) {
                textView.textSize = 15f
YKai committed
603 604 605 606 607 608
                textView.setTextColor(
                    ContextCompat.getColor(
                        activity!!,
                        R.color.platform_color_333333
                    )
                )
徐健 committed
609 610 611 612 613 614 615 616
            }
        }

        override fun onTabSelected(tab: TabLayout.Tab?) {
            if (tab!!.position == confideLastSelectPosition) {
                return
            }

YKai committed
617 618 619 620
            var textView =
                ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
                    1
                )
徐健 committed
621 622
            if (textView != null && textView is TextView) {
                textView.textSize = 17f
YKai committed
623 624 625 626 627 628
                textView.setTextColor(
                    ContextCompat.getColor(
                        activity!!,
                        R.color.platform_color_242424
                    )
                )
徐健 committed
629 630 631 632 633 634 635 636 637 638 639
                textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
            }
            homeEvent!!.getConfideData(list!![tab!!.position], tab!!.position)
        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        HomeAnimUtils.clear()
    }
}