lmw
2024-06-16 03172fc2d9a7717f4a9d8de1c5eca3158a550b30
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
package com.dollearn.student.dialog
 
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.PopupWindow
import com.dollearn.student.R
import com.dollearn.student.utils.interfaces.StringCallback
import kotlinx.android.synthetic.main.layout_filter_time.view.*
import org.jetbrains.anko.dip
 
class TimeFilterPop(context: Context) : PopupWindow(context) {
    private var callback: StringCallback? = null
 
    init {
        val inflate = LayoutInflater.from(context).inflate(R.layout.layout_filter_time, null)
        contentView = inflate
        inflate?.apply {
            tv_all.setOnClickListener {
                callback?.onResult("上课时间")
                dismiss()
            }
            tv_week.setOnClickListener {
                callback?.onResult("最近一周")
                dismiss()
            }
            tv_month.setOnClickListener {
                callback?.onResult("最近一月")
                dismiss()
            }
            tv_year.setOnClickListener {
                callback?.onResult("最近一年")
                dismiss()
            }
        }
        width = context.dip(100)
        height = ViewGroup.LayoutParams.WRAP_CONTENT
        setBackgroundDrawable(context.resources.getDrawable(R.color.transparent))
        isOutsideTouchable = true
        isFocusable = true
    }
 
    fun setCallback(callback: StringCallback) {
        this.callback = callback
    }
 
}