package com.dollearn.student.dialog
|
|
import android.annotation.SuppressLint
|
import android.view.Gravity
|
import androidx.core.os.bundleOf
|
import androidx.fragment.app.FragmentManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import cn.sinata.xldutils.utils.showAllowingStateLoss
|
import com.dollearn.student.R
|
import com.dollearn.student.network.entity.MyCourse
|
import com.dollearn.student.ui.course.adapter.ClassHourChooseAdapter
|
import com.dollearn.student.utils.interfaces.StringCallback
|
import kotlinx.android.synthetic.main.dialog_exchange_count.tv_action
|
import kotlinx.android.synthetic.main.dialog_exchange_count.tv_cancel
|
import kotlinx.android.synthetic.main.dialog_wfp_classhour.*
|
|
class UndistributedClassHourialog : BaseDialogFragment() {
|
override fun setContentView() = R.layout.dialog_wfp_classhour
|
|
var callback: StringCallback? = null
|
|
val count by lazy {
|
arguments?.getInt("count") ?: 0
|
}
|
|
val list by lazy {
|
arguments?.getSerializable("list") as ArrayList<MyCourse>
|
}
|
|
val adapter by lazy {
|
ClassHourChooseAdapter(list)
|
}
|
|
override fun setGravity() = Gravity.CENTER
|
|
@SuppressLint("SetTextI18n", "NotifyDataSetChanged")
|
override fun initView() {
|
mtvinfo.text = "未分配课时数:$count"
|
tv_action.setOnClickListener {
|
callback?.onResult(list[adapter.checked].id)
|
dismissAllowingStateLoss()
|
}
|
tv_cancel.setOnClickListener { dismissAllowingStateLoss() }
|
|
mrl.layoutManager = LinearLayoutManager(context)
|
mrl.adapter = adapter
|
adapter.setOnItemClickListener { _, position ->
|
run {
|
adapter.checked = position
|
adapter.notifyDataSetChanged()
|
}
|
|
}
|
}
|
|
companion object {
|
fun show(
|
fm: FragmentManager,
|
count: Int,
|
list: ArrayList<MyCourse>,
|
callback: StringCallback
|
) :UndistributedClassHourialog{
|
val exchangeCountDialog = UndistributedClassHourialog()
|
exchangeCountDialog.callback = callback
|
exchangeCountDialog.arguments = bundleOf(
|
"count" to count,
|
"list" to list
|
)
|
exchangeCountDialog.showAllowingStateLoss(fm, "")
|
|
return exchangeCountDialog
|
}
|
}
|
}
|