罗明文
2024-06-18 c9f6a2283ee7e5595c91c6d721726a89a3ab9ecd
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com.dollearn.student.ui.home
 
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Paint
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf
import cn.sinata.xldutils.gone
import cn.sinata.xldutils.utils.*
import cn.sinata.xldutils.visible
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.WeparkApplication
import com.dollearn.student.dialog.CheckShopsDialog
import com.dollearn.student.dialog.ChooseCouponDialog
import com.dollearn.student.network.HttpManager
import com.dollearn.student.network.entity.Banner
import com.dollearn.student.network.entity.Match
import com.dollearn.student.network.request
import com.dollearn.student.ui.TransparentStatusBarActivity
import com.dollearn.student.ui.home.adapter.HomeBannerAdapter
import com.dollearn.student.utils.extention.clickDelay
import com.dollearn.student.utils.extention.loadLongImage
import kotlinx.android.synthetic.main.activity_match_deatil.*
import org.jetbrains.anko.backgroundColorResource
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
 
class MatchDetailActivity : TransparentStatusBarActivity() {
    override fun setContentView() = R.layout.activity_match_deatil
 
    private val id by lazy { intent.getStringExtra("id")?:"" }
 
    private var match: Match? = null
    private val bannerImg = arrayListOf<Banner>()
    private val bannerAdapter by lazy {
        HomeBannerAdapter(bannerImg, this)
    }
 
    override fun initClick() {
        tv_action.clickDelay {
            if (match != null) {
                startActivity(Intent(this@MatchDetailActivity, JoinMatchActivity::class.java)
                    .apply
                    {
                        putExtra("match", match)
                    })
            }
            // startActivity<JoinMatchActivity>("match" to match)
        }
    }
 
    override fun initView() {
        banner.adapter = bannerAdapter
        getDetail()
    }
 
 
    /**
     * 获取运动营详情,暂时列表数据够用,不需实现
     */
    private fun getDetail() {
        HttpManager.queryCompetitionInfo(id, WeparkApplication.lat, WeparkApplication.lon)
            .request(this) { _, data ->
                match = data
                data?.apply {
                    if (hasPass == 1){//活动已过期
                        tv_action.text = "报名已截止"
                        tv_action.isEnabled = false
                        tv_action.backgroundColorResource = R.color.disableColor
                    }
                    storeInfos?.let {
                        val stores = StringBuffer()
                        for (s in it.indices) {
                            if (s == it.size - 1) stores.append(it[s].name)
                            else stores.append(it[s].name + ",")
                        }
                        tv_shops.text = stores
                        if (stores.length > 40) {
                            mtvcheckmore.visible()
                            mtvcheckmore.clickDelay {
                                val checkShopsDialog = CheckShopsDialog()
                                checkShopsDialog.arguments =
                                    bundleOf("shopinfo" to stores.toString())
                                checkShopsDialog.showAllowingStateLoss(
                                    supportFragmentManager,
                                    "checkshops"
                                )
                            }
                        } else {
                            mtvcheckmore.gone()
                        }
                    }
 
                    val list = imgs.split(",").map {
                        Banner(url = it)
                    }
                    bannerImg.addAll(list)
                    bannerAdapter.notifyDataSetChanged()
                    banner.currentItem = 1
                    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
                    if (cashPrice!=null&&cashPrice.toDouble()!=0.0) {
                        val price = "支付:¥%s/人".format(cashPrice)
                        tv_price.text = SpanBuilder(price).color(
                            this@MatchDetailActivity,
                            0,
                            3,
                            R.color.textColor66
                        ).bold(3, price.length).build()
                        tv_price.visible()
                    }
                    if (playPaiCoin!=null&&playPaiCoin.toInt()!=0) {
                        val coin = "玩湃币:%s币/人".format(playPaiCoin)
                        tv_coin.text = SpanBuilder(coin).color(
                            this@MatchDetailActivity,
                            0,
                            4,
                            R.color.textColor66
                        ).bold(4, coin.length).build()
                        tv_coin.visible()
                    }
                    if (classPrice!=null&&classPrice.toInt()!=0) {
                        val time = "课时:%s课时/人".format(classPrice)
                        tv_course_time.text = SpanBuilder(time).color(
                            this@MatchDetailActivity,
                            0,
                            3,
                            R.color.textColor66
                        ).bold(3, time.length).build()
                        tv_course_time.visible()
                    }
                    tv_introduce.text = introduction
                    if (!registrationNotes.isNullOrEmpty()) {
                        registrationNotes.loadLongImage(this@MatchDetailActivity,iv_introduction)
                    }
                }
            }
    }
 
}