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