18034727885
2026-08-20 97da117f2d2a6425039b6a4cd6dcf5a6601041e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.igo.user.dialog
 
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.DialogFragment
import com.igo.user.R
import org.jetbrains.anko.matchParent
import org.jetbrains.anko.support.v4.find
import org.jetbrains.anko.wrapContent
 
class ShareDialog: DialogFragment() {
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.dialog_share,container,false)
    }
 
    private val isTrip by lazy { //true行程分享,短信显示
        arguments?.getBoolean("isTrip",false)?:false
    }
    private val tv_title by lazy { find<TextView>(R.id.tv_title) }
    private val tv_wx by lazy { find<TextView>(R.id.tv_wx) }
    private val tv_moment by lazy { find<TextView>(R.id.tv_moment) }
    private val tv_msg by lazy { find<TextView>(R.id.tv_msg) }
    private val tv_wa by lazy { find<TextView>(R.id.tv_wa) }
    private val tv_fb by lazy { find<TextView>(R.id.tv_fb) }
    private val tv_x by lazy { find<TextView>(R.id.tv_x) }
    private val iv_close by lazy { find<View>(R.id.iv_close) }
 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(STYLE_NO_FRAME,cn.sinata.xldutils.R.style.Dialog)
    }
    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        dialog?.window?.setLayout(matchParent, wrapContent)
        dialog?.window?.setGravity(Gravity.BOTTOM)
        dialog?.setCanceledOnTouchOutside(true)
    }
 
 
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        tv_title.text = getString(if (isTrip) R.string.分享行程 else R.string.分享)
        iv_close.setOnClickListener {
            dismiss()
        }
        tv_wx.setOnClickListener {
            callback?.onOk(0)
        }
        tv_moment.setOnClickListener {
            callback?.onOk(1)
        }
        tv_msg.setOnClickListener {
            callback?.onOk(2)
        }
        tv_wa.setOnClickListener {
            callback?.onOk(3)
        }
        tv_fb.setOnClickListener {
            callback?.onOk(4)
        }
        tv_x.setOnClickListener {
            callback?.onOk(5)
        }
    }
 
 
    interface Callback{
        fun onOk(way: Int)
    }
 
    private var callback: Callback? = null
 
    fun setCallback(callback: Callback){
        this.callback = callback
    }
}