package com.jld.vod.view

import android.view.View
import android.widget.TextView
import com.jld.vod.R
import com.jld.vod.base.BaseActivity
import com.jld.vod.config.Config
import com.jld.vod.utils.HtmlUtils
import com.jld.vod.view.widget.GlideImageLoader
import com.youth.banner.Banner
import com.youth.banner.BannerConfig
import com.zzhoujay.richtext.RichText
import kotlinx.android.synthetic.main.activity_about.*
import java.util.ArrayList

class AboutActivity : BaseActivity() {
    private lateinit var htmlTextView : TextView
    private val images: MutableList<String> = ArrayList<String>()

    override fun initView() {
        super.initView()

        val intent = intent
        val bundle = intent.extras
        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(Config.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()

        iv_about_back.setOnClickListener {
            this.onBackPressed()
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_about
    }
}