YdlHomeFragment.kt 23.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
import android.graphics.Color
徐健 committed
6
import android.graphics.Typeface
范玉宾 committed
7
import android.media.MediaPlayer
徐健 committed
8 9 10
import android.os.Build
import android.text.TextUtils
import android.view.View
konghaorui committed
11
import android.widget.FrameLayout
徐健 committed
12 13 14
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
YKai committed
15
import androidx.core.content.ContextCompat
YKai committed
16
import androidx.fragment.app.FragmentActivity
YKai committed
17 18
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
konghaorui committed
19
import com.alibaba.android.arouter.facade.annotation.Route
YKai committed
20
import com.google.android.material.tabs.TabLayout
徐健 committed
21 22 23 24 25 26
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
27
import com.ydl.ydlcommon.utils.*
徐健 committed
28 29 30 31
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
import kotlinx.android.synthetic.ydl.home_fragment.tab_layout
import kotlinx.android.synthetic.ydl.home_muse_view.*
import kotlinx.android.synthetic.ydl.home_muse_view.view.*
49
import kotlin.properties.Delegates
徐健 committed
50 51 52 53 54 55 56 57 58 59



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

徐健 committed
70
    //双11活动弹窗
konghaorui committed
71
    open var aa: Dialog? = null
徐健 committed
72 73 74 75 76 77


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

徐健 committed
80 81 82 83 84
    /**
     * TabLayout.OnTabSelectedListener
     */
    private var consultTabListener: TabLayout.OnTabSelectedListener? = null
    private var confideTabListener: TabLayout.OnTabSelectedListener? = null
YKai committed
85

徐健 committed
86 87 88 89
    /**
     * 咨询tablayout上次选中的下标
     */
    private var consultLastSelectPosition = 0
YKai committed
90 91
    private var consultLastSelectType = ""

徐健 committed
92 93 94
    /**
     * 悬浮tablayout监听事件
     */
YKai committed
95 96
    open lateinit var scrollListner: HomeConfideRecyleSuspendListener

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

konghaorui committed
100 101
    open var searchText: String = ""
    open var doctorName: String = ""
霍志良 committed
102 103
    var startTime =0L
    var endTime =0L
徐健 committed
104

105 106 107 108 109
    /**
     * 如果是第一次加载,则调用所有接口进行刷新,否则,只调用咨询和倾诉接口
     */
    private var isFromCreate: Boolean = true

徐健 committed
110
    override fun layoutResId(): Int {
konghaorui committed
111
        return R.layout.home_fragment
徐健 committed
112 113 114
    }

    override fun initDataAndEvent() {
YKai committed
115 116
        mActivity = requireActivity()
        mContext = requireContext()
konghaorui committed
117 118 119 120 121
        initHomeEvent()
        initView()
        initTopButtonBanner()
        initAdapter()
    }
徐健 committed
122

konghaorui committed
123
    open fun initHomeEvent() {
YKai committed
124
        homeEvent = HomeImpl(mActivity, this)
徐健 committed
125 126 127
    }

    private fun initAdapter() {
YKai committed
128 129
        mPresenter?.localHomeData(mContext, "home_data.json")
        adapter = YdlHomeAdapter(mContext, homeEvent!!, ArrayList())
徐健 committed
130 131 132
        val layoutManager = LinearLayoutManager(context)
        home_module_fragment_recycler.layoutManager = layoutManager
        home_module_fragment_recycler.adapter = adapter
133 134
        val space = resources.getDimension(R.dimen.platform_dp_24).toInt()
        home_module_fragment_recycler.addItemDecoration(HomeSpaceItemDecoration(space))
konghaorui committed
135 136
        initRvListener()
    }
徐健 committed
137

konghaorui committed
138
    open fun initRvListener() {
YKai committed
139 140 141 142 143 144
        if (HomeViewConfig.getOrder().bannerIndex != -1) {
            home_module_fragment_recycler.addOnScrollListener(
                homeEvent!!.onPageScroll(
                    view_rl_top_bg
                )!!
            )
145
        }
徐健 committed
146 147 148 149 150 151
        scrollListner = HomeConfideRecyleSuspendListener()
        home_module_fragment_recycler.addOnScrollListener(scrollListner)
        setSuspendListener()
    }

    private fun initView() {
YKai committed
152
        if (HomeViewConfig.getOrder().bannerIndex == null || HomeViewConfig.getOrder().bannerIndex == -1) {
konghaorui committed
153
            var marginTop = this.resources.getDimension(R.dimen.home_home_title_bar_height)
upwork.021 committed
154 155 156
            //4.4以下不支持状态栏变色
            val statusBarHeight = StatusBarUtils.getStatusBarHeight(mActivity)
            marginTop += statusBarHeight
konghaorui committed
157 158 159 160 161
            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
162
        home_swipe_refresh_layout?.setOnRefreshListener(this)
YKai committed
163 164
        home_swipe_refresh_layout?.setColorSchemeColors(
            ContextCompat.getColor(
YKai committed
165
                mContext,
YKai committed
166 167 168
                R.color.platform_main_theme
            )
        )
徐健 committed
169 170
        home_swipe_refresh_layout?.setProgressViewOffset(false, 0, 200)
        home_service_call.setOnClickListener { homeEvent?.serviceCallClick() }
konghaorui committed
171
        initSearchBar()
徐健 committed
172 173 174
        initStatus()
    }

konghaorui committed
175
    open fun initSearchBar() {
YKai committed
176
        if (!TextUtils.isEmpty(doctorName)) {
konghaorui committed
177 178
            searchText = doctorName
        }
179 180 181 182 183 184 185
        home_tv.setOnClickListener {
            homeEvent?.searchTvClick(searchText)
        }

        iv_search_icon.setOnClickListener {
            homeEvent?.searchTvClick(searchText)
        }
konghaorui committed
186 187 188
        home_tv.text = searchText
    }

徐健 committed
189 190 191 192
    /**
     * 初始化状态栏位置
     */
    private fun initStatus() {
upwork.021 committed
193 194 195 196 197 198 199 200 201 202
        //4.4以下不支持状态栏变色
        val statusBarHeight = StatusBarUtils.getStatusBarHeight(mActivity)
        val homeTitleBarHeight = resources.getDimension(R.dimen.home_home_title_bar_height)
        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
徐健 committed
203 204 205 206
    }

    override fun initDataAndEventLazy() {
    }
YKai committed
207

konghaorui committed
208 209 210 211 212 213 214 215 216
    /**
     * 设置顶部导航栏 功能点击事件
     */
    private fun initTopButtonBanner() {

        tv_consult.setOnClickListener {
            homeEvent?.reservationExpertsClick()
        }
        tv_confide.setOnClickListener {
万齐军 committed
217
            homeEvent?.nowConfideClick(adapter?.listenFree ?: false)
konghaorui committed
218 219 220 221 222 223 224 225 226 227 228
        }
        tv_course.setOnClickListener {
            homeEvent?.psychologyClassClick()
        }
        tv_test.setOnClickListener {
            homeEvent?.psychologyTestClick()
        }
        rl_backTop.setOnClickListener {
            home_module_fragment_recycler.scrollToPosition(0)
        }
    }
YKai committed
229

konghaorui committed
230
    override fun startAnim() {
YKai committed
231
        HomeAnimUtils.startAnim(mContext, rl_top, rl_search, home_service_call, home_tv)
YKai committed
232 233 234 235 236 237 238
        HomeAnimUtils.startSearchShow(
            ll_top_function,
            view_search_input_bg,
            home_tv,
            iv_search_icon,
            img_ad
        )
konghaorui committed
239 240 241
    }

    override fun endAnim() {
YKai committed
242
        HomeAnimUtils.endAnim(mContext, rl_top, rl_search, home_tv, home_service_call, this)
YKai committed
243 244 245 246 247 248 249
        HomeAnimUtils.startSearchHide(
            ll_top_function,
            view_search_input_bg,
            home_tv,
            iv_search_icon,
            img_ad
        )
konghaorui committed
250 251 252 253 254
    }

    override fun getSearchContent(): String {
        return searchText
    }
徐健 committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274

    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() {
275 276 277 278 279 280
        scrollListner.setContext(mContext)
        scrollListner.setHomeView(this)
        scrollListner.setConfideFilterView(ll_layout)
        scrollListner.setConsultFilterView(ll_consultLayout)
        scrollListner.setSectionAdapter(adapter!!)
        scrollListner.setPhoneCallImageView(home_service_call)
徐健 committed
281 282 283 284 285 286 287 288 289
    }

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

    /**
     * 获取咨询列表数据
     */
    override fun getConsultData(type: String, selectPosition: Int) {
        consultLastSelectPosition = selectPosition
299
        consultLastSelectType = type
徐健 committed
300 301 302 303
        mPresenter?.getConsultData(type, selectPosition)
    }

    override fun homeHeadResponse(homeHeaderBean: HomeHeaderBean) {
霍志良 committed
304 305
        //更新倾述列表数据
        adapter?.updateConfideFreeData(homeHeaderBean)
徐健 committed
306 307 308 309
        //展示活动数据
        val act = homeHeaderBean.activityResponse

        if (act != null) {
upwork.021 committed
310
            if (!TextUtils.isEmpty(act.imageUrl)) {
徐健 committed
311
                img_ad.visibility = View.VISIBLE
312 313
                ActionCountUtils.count(HomeBIConstants.YDL_HOME_SEARCH_TAG,act.title?:"1")

徐健 committed
314 315 316 317 318 319 320 321 322 323 324
                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)
                    }
325
                    //定制咨询点击事件埋点
326
                    ActionCountUtils.count(HomeBIConstants.YDL_HOME_SEARCH_TAG_CLICK,act.title?:"1")
徐健 committed
327 328 329 330 331 332 333 334 335 336 337 338 339
                }
            } else {
                img_ad.visibility = View.GONE
            }

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

徐健 committed
340
            if (!ModularServiceManager.provide(IUserService::class.java).isLogin()) {
徐健 committed
341 342 343 344 345 346
                //未登录不显示
                return
            }
            if (!TextUtils.isEmpty(act.imageBanner)) {
                //展示弹窗
                if (aa == null) {
347
                    ActionCountUtils.count(HomeBIConstants.YDL_HOME_POPUPWINDOWS_PAGE_POPUP,act?.title?:"1")
YKai committed
348
                    aa = ActivityDialog(mActivity, act.imageBanner, act.linkUrl, act.title)
徐健 committed
349 350 351
                    aa?.show()
                    aa?.setOnDismissListener {
                        //文案不为空才显示引导--李思开
YKai committed
352
                        if (!TextUtils.isEmpty(act.title)) {
YKai committed
353
                            ActivityGuideDialog(mActivity, act.imageUrl, act.title).show()
徐健 committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367
                        }
                    }
                }
                //仅展示一次,以后不再展示
                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
368 369
            doctorName = list[0].headerBean?.doctorName!!
            initSearchBar()
徐健 committed
370 371 372 373 374 375 376
        }

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

    /**
     * 初始化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
397 398 399 400 401 402 403 404 405
            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
406 407
        if (textView != null && textView is TextView) {
            textView.textSize = 17f
YKai committed
408
            textView.setTextColor(ContextCompat.getColor(mActivity, R.color.platform_color_242424))
徐健 committed
409 410 411 412 413 414 415 416 417
            textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
        }
    }

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

YKai committed
444 445 446
        val textView = ((tab_consultLayout!!.getChildAt(0) as LinearLayout).getChildAt(
            confideLastSelectPosition
        ) as LinearLayout).getChildAt(1)
徐健 committed
447 448
        if (textView != null && textView is TextView) {
            textView.textSize = 17f
YKai committed
449
            textView.setTextColor(ContextCompat.getColor(mActivity, R.color.platform_color_242424))
徐健 committed
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
            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) {
霍志良 committed
497
            startTime=System.currentTimeMillis()
徐健 committed
498 499 500
            showConsultAssistantDialog()
        } else {
            hideConsultAssistantDialog()
霍志良 committed
501 502 503 504 505 506
            if (startTime!=0L){
                endTime=System.currentTimeMillis()
                ActionCountUtils.count(HomeBIConstants.YDL_HOME_DWELL_TIME,(endTime-startTime).toString())
                startTime=0L
            }

徐健 committed
507 508 509 510 511 512 513
        }
        if (isVisibleToUser && isResumed) {
            onResume()
        }
    }

    private fun showConsultAssistantDialog() {
YKai committed
514
        ModularServiceManager.provide(IConsultantService::class.java)
YKai committed
515
            .showConsultAssistantDialog(mActivity)
徐健 committed
516 517 518 519 520 521
    }

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

霍志良 committed
522

徐健 committed
523 524 525
    override fun onResume() {
        super.onResume()
        if (userVisibleHint) {
526 527 528
            if (isFromCreate) {
                isFromCreate = false
                mPresenter?.loadHomeData()
YKai committed
529
            } else {
霍志良 committed
530
                mPresenter?.loadHomeData()
531 532 533
                mPresenter?.getConsultData(consultLastSelectType, consultLastSelectPosition)
                mPresenter?.getConfideData(confideLastSelectType, confideLastSelectPosition)
            }
霍志良 committed
534 535
            ActionCountUtils.count(HomeBIConstants.YDL_USER_MAIN_PAGE_VISIT)
            ActionCountUtils.count("daoyi_advertisement_page|daoyi_advertisement_visit","1")
徐健 committed
536
            showConsultAssistantDialog()
范玉宾 committed
537 538 539 540 541 542 543 544

            video_view?.setOnInfoListener { mp, what, extra ->
                if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START){
                    video_view?.setBackgroundColor(Color.TRANSPARENT)
                }
                true
            }
            video_view?.start()
徐健 committed
545 546 547
        }
    }

霍志良 committed
548 549 550 551 552 553 554
    override fun onPause() {
        super.onPause()
        if (startTime!=0L){
            endTime=System.currentTimeMillis()
            ActionCountUtils.count(HomeBIConstants.YDL_HOME_DWELL_TIME,(endTime-startTime).toString())
            startTime=0L
        }
范玉宾 committed
555
        video_view?.pause()
霍志良 committed
556 557
    }

徐健 committed
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
    /**
     * 咨询楼层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
574 575 576 577
            var textView =
                ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
                    1
                )
徐健 committed
578 579
            if (textView != null && textView is TextView) {
                textView.textSize = 15f
YKai committed
580 581 582 583 584 585
                textView.setTextColor(
                    ContextCompat.getColor(
                        activity!!,
                        R.color.platform_color_333333
                    )
                )
徐健 committed
586 587 588 589 590 591 592
            }
        }

        override fun onTabSelected(tab: TabLayout.Tab?) {
            if (tab!!.position == consultLastSelectPosition) {
                return
            }
YKai committed
593 594 595 596
            var textView =
                ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
                    1
                )
徐健 committed
597 598
            if (textView != null && textView is TextView) {
                textView.textSize = 17f
YKai committed
599 600 601 602 603 604
                textView.setTextColor(
                    ContextCompat.getColor(
                        activity!!,
                        R.color.platform_color_242424
                    )
                )
徐健 committed
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
                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
624 625 626 627
            var textView =
                ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
                    1
                )
徐健 committed
628 629
            if (textView != null && textView is TextView) {
                textView.textSize = 15f
YKai committed
630 631 632 633 634 635
                textView.setTextColor(
                    ContextCompat.getColor(
                        activity!!,
                        R.color.platform_color_333333
                    )
                )
徐健 committed
636 637 638 639 640 641 642 643
            }
        }

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

YKai committed
644 645 646 647
            var textView =
                ((tabLayout!!.getChildAt(0) as LinearLayout).getChildAt(tab!!.position) as LinearLayout).getChildAt(
                    1
                )
徐健 committed
648 649
            if (textView != null && textView is TextView) {
                textView.textSize = 17f
YKai committed
650 651 652 653 654 655
                textView.setTextColor(
                    ContextCompat.getColor(
                        activity!!,
                        R.color.platform_color_242424
                    )
                )
徐健 committed
656 657 658 659 660 661 662 663 664 665 666
                textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
            }
            homeEvent!!.getConfideData(list!![tab!!.position], tab!!.position)
        }
    }

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