SecretDialog.kt 1.28 KB
Newer Older
徐健 committed
1 2 3 4 5 6 7
package com.yidianling.user.widget

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
yjiucheng committed
8
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
徐健 committed
9 10 11
import com.yidianling.user.R
import kotlinx.android.synthetic.main.user_secret_dialog_layout.*

yjiucheng committed
12 13
class SecretDialog(context: Context, private val listener: OnSecretDialogListener?) :
    Dialog(context, R.style.platform_dialog_default_style) {
徐健 committed
14 15 16 17 18 19 20 21 22 23 24 25 26

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(R.layout.user_secret_dialog_layout)

        val params = window.attributes
        params.width = WindowManager.LayoutParams.MATCH_PARENT
        params.height = WindowManager.LayoutParams.WRAP_CONTENT
        window.setGravity(Gravity.CENTER)
        window.attributes = params

        user_secret_dialog_agree.setOnClickListener {
yjiucheng committed
27
            agreeAction()
徐健 committed
28 29 30 31 32 33 34 35 36 37 38 39
        }

        user_secret_dialog_no_agree.setOnClickListener {
            listener?.onCancel()
        }
    }

    interface OnSecretDialogListener {
        fun onCancel()
        fun onSure()
    }

yjiucheng committed
40 41 42 43
    private fun agreeAction() {
        SharedPreferencesEditor.putString("hasAgreeSecret", "true")
        listener?.onSure()
    }
徐健 committed
44 45

}