package com.jld.vod.view.fragment

import android.view.View
import android.widget.TextView
import com.jld.vod.R
import com.jld.vod.base.BaseFragment
import com.jld.vod.config.Config
import com.jld.vod.config.Config.ApiBaseUrl
import com.jld.vod.model.bean.Audio
import com.jld.vod.utils.HtmlUtils
import com.jld.vod.utils.LogUtils
import com.jld.vod.view.widget.GlideImageLoader
import com.xuexiang.xpage.annotation.Page
import com.xuexiang.xpage.enums.CoreAnim
import com.xuexiang.xui.widget.actionbar.TitleBar
import com.youth.banner.Banner
import com.youth.banner.BannerConfig
import com.zzhoujay.richtext.RichText
import java.util.*

@Page(anim = CoreAnim.none)
class AboutDetailsFragment : BaseFragment() {

    private lateinit var htmlTextView : TextView
    private val images: MutableList<String> = ArrayList<String>()
    override fun getLayoutId(): Int {
        return R.layout.fragment_about_details
    }

    override fun initViews() {
        val bundle = arguments
        val info = bundle!!.getString("info")
        val pictures = bundle!!.getString("pictures")
        htmlTextView = findViewById(R.id.html_text)

        //图片集合
        val pic = pictures!!.split(",")
        for((index,e) in pic.withIndex())
        {
            images.add(ApiBaseUrl+"/synchronization/previewImg?imgUrl="+pic[index])
        }

        //加载html
        RichText.fromHtml(HtmlUtils.translation(info!!.trim())).into(htmlTextView);

        //轮播
        val banner = findViewById<View>(R.id.about_banner) as Banner
        //设置图片加载器
        banner.setImageLoader(GlideImageLoader())

        //设置图片集合
        banner.setImages(images)
        //banner设置方法全部调用完毕时最后调用
        banner.setBannerStyle(BannerConfig.NOT_INDICATOR)
        banner.setDelayTime(3000)
        banner.start()
    }

    override fun initTitle(): TitleBar? {
        return null
    }

}