ActivityGuideDialog.kt 1.31 KB
Newer Older
徐健 committed
1 2 3 4 5 6 7 8
package com.yidianling.home.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Window
import com.yidianling.home.R
import com.ydl.ydl_image.module.GlideApp
konghaorui committed
9
import kotlinx.android.synthetic.ydl.home_dialog_guide_activity.*
徐健 committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
import java.util.*

/**
 * 首页活动引导弹窗
 */
class ActivityGuideDialog : Dialog {

    private var imgUrl: String? = null
    private var title: String? = null

    constructor(context: Context, imgUrl: String?, title: String?) : super(
        context,
        R.style.activityDialog
    ) {
        this.imgUrl = imgUrl
        this.title = title
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        window.setBackgroundDrawableResource(android.R.color.transparent)

konghaorui committed
33
        setContentView(R.layout.home_dialog_guide_activity)
徐健 committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

        initView()
    }

    private fun initView() {

        c_body.setOnClickListener {
            dismiss()
        }

        tv_content.text = this.title

        GlideApp.with(context).load(imgUrl).into(img_activity)

        //3秒自动消失
        Timer().schedule(object : TimerTask() {
            override fun run() {
                dismiss()
            }
        }, 3000)
    }

}