lmw
2024-06-17 f571288a24fcf10143dcc8015ffbbf38dbc0c614
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package com.dollearn.student.ui.home
 
import android.app.Activity
import android.graphics.Bitmap
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.LinearLayoutManager
import cn.sinata.xldutils.utils.myToast
import cn.sinata.xldutils.utils.showAllowingStateLoss
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
import com.dollearn.student.R
import com.dollearn.student.dialog.TipDialog
import com.dollearn.student.network.HttpManager
import com.dollearn.student.network.entity.Banner
import com.dollearn.student.network.entity.Student
import com.dollearn.student.network.request
import com.dollearn.student.ui.TransparentStatusBarActivity
import com.dollearn.student.ui.home.adapter.HomeBannerAdapter
import com.dollearn.student.ui.home.adapter.StudentAdapter
import com.dollearn.student.utils.extention.loadLongImage
import kotlinx.android.synthetic.main.activity_my_match_deatil.*
import org.jetbrains.anko.backgroundColorResource
 
class MyMatchDetailActivity:TransparentStatusBarActivity() {
    override fun setContentView() = R.layout.activity_my_match_deatil
 
    private val id by lazy { intent.getStringExtra("id")?:"" }
    private val bannerImg = arrayListOf<Banner>()
    private val bannerAdapter by lazy {
        HomeBannerAdapter(bannerImg, this)
    }
    private val students = arrayListOf<Student>()
    private val studentAdapter = StudentAdapter(students, StudentAdapter.TYPE_MY_MATCH_DETAIL)
    override fun initClick() {
        bg_action.setOnClickListener {
            if (tv_action.text == "取消"){
                val tipDialog = TipDialog()
                tipDialog.arguments = bundleOf("msg" to "确认取消吗?取消后相关费用\n将会退还到原支付账户!")
                tipDialog.setCallback(object :TipDialog.OnClickCallback{
                    override fun onOk() {
                        HttpManager.cancelMyCompetition(id).request(this@MyMatchDetailActivity){_,_->
                            myToast("取消成功")
                            bg_action.backgroundColorResource = R.color.disableColor
                            tv_action.text = "已取消"
                            setResult(Activity.RESULT_OK)
                            tv_action.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,0,0)
                        }
                    }
 
                    override fun onCancel() {
                    }
                })
                tipDialog.showAllowingStateLoss(supportFragmentManager,"cancel")
            }
        }
    }
 
    override fun initView() {
        banner.adapter = bannerAdapter
        rv_student.layoutManager = LinearLayoutManager(this)
        rv_student.adapter = studentAdapter
        getData()
    }
 
    private fun getData(){
        HttpManager.queryMyCompetitionInfo(id).request(this){_,data->
            data?.apply {
                val list = imgs.split(",").map {
                    Banner(url = it)
                }
                bannerImg.addAll(list)
                bannerAdapter.notifyDataSetChanged()
                tv_name.text = name
                tv_condition.text = getCondition()+"参与"
                tv_address.text = "${storeName}(${storeAddress})"
                tv_deadline.text = registerEndTime
                tv_start_time.text = startTime
                tv_end_time.text = endTime
                tv_age.text = age
                tv_city.text = "${province}|${city}"
                tv_play_address.text = address
                students.addAll(participant?: arrayListOf())
                studentAdapter.notifyDataSetChanged()
                tv_introduce.text = introduction
                if (!registrationNotes.isNullOrEmpty()){
                    registrationNotes.loadLongImage(this@MyMatchDetailActivity,iv_introduction)
                }
                when(payType){//1=微信,2=支付宝,3=玩湃币,4=课时
                    1,2->{
                       tv_single_price.text = "¥${cashPrice}/人"
                       tv_price.text = "合计:¥${payMoney}"
                    }
                    3->{
                       tv_single_price.text = "%d玩湃币/人".format(playPaiCoin?.toInt())
                       tv_price.text = "合计:%d玩湃币".format(payMoney!!.toDouble().toInt())
                    }
                    4->{
                       tv_single_price.text = "%d课时/人".format(classPrice?.toInt())
                       tv_price.text = "合计:%d课时".format(payMoney!!.toDouble().toInt())
                    }
                }
                if (status == 3){
                    bg_action.backgroundColorResource = R.color.disableColor
                    tv_action.text = "已结束"
                }else if (status == 4){
                    bg_action.backgroundColorResource = R.color.disableColor
                    tv_action.text = "已取消"
                }else{
                    tv_action.text = "取消"
                    bg_action.backgroundColorResource = R.color.colorPrimary
                    tv_action.setCompoundDrawablesRelativeWithIntrinsicBounds(R.mipmap.ic_cancel,0,0,0)
                }
            }
        }
    }
}