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)
|
}
|
}
|
}
|
}
|
|
}
|