package com.sinata.xqmuse.ui.mine
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import cn.sinata.xldutils.utils.SpanBuilder
|
import com.sinata.xqmuse.R
|
import com.sinata.xqmuse.dialog.ChooseMonthDialog
|
import com.sinata.xqmuse.network.HttpManager
|
import com.sinata.xqmuse.network.entity.Detail
|
import com.sinata.xqmuse.network.request
|
import com.sinata.xqmuse.ui.TransparentStatusBarActivity
|
import com.sinata.xqmuse.ui.mine.adapter.WithdrawAdapter
|
import com.sinata.xqmuse.utils.extention.clickDelay
|
import com.sinata.xqmuse.utils.interfaces.StringCallback
|
import kotlinx.android.synthetic.main.activity_withdraw_record.*
|
|
class WithdrawRecordActivity : TransparentStatusBarActivity() {
|
override fun setContentView() = R.layout.activity_withdraw_record
|
|
private var page = 1
|
private var year:Int? = null
|
private var month:Int? = null
|
|
private val list = arrayListOf<Detail>()
|
private val adapter = WithdrawAdapter(list)
|
|
override fun initClick() {
|
tv_month.clickDelay {
|
val chooseMonthDialog = ChooseMonthDialog()
|
chooseMonthDialog.setCallback(object : StringCallback {
|
override fun onResult(rst: String) {
|
tv_month.text = rst
|
year = rst.substring(0,4).toInt()
|
month = rst.substring(5,rst.length-1).toInt()
|
page = 1
|
getData()
|
}
|
})
|
chooseMonthDialog.show(supportFragmentManager,"month")
|
}
|
}
|
|
override fun initView() {
|
|
tv_reset.clickDelay {
|
tv_month.text = "请选择"
|
year = null
|
month = null
|
page = 1
|
getData()
|
}
|
|
rv_list.layoutManager = LinearLayoutManager(this)
|
rv_list.adapter = adapter
|
|
refreshLayout.setOnLoadMoreListener {
|
page++
|
getData()
|
}
|
|
refreshLayout.setOnRefreshListener {
|
page = 1
|
getData()
|
}
|
page = 1
|
getData()
|
}
|
|
private fun getData(){
|
HttpManager.withdrawalRecord(page,year, month).request(this,success = { _, data->
|
if (page == 1)
|
list.clear()
|
list.addAll(data?: arrayListOf())
|
adapter.notifyDataSetChanged()
|
if (list.isEmpty())
|
refreshLayout.finishRefreshWithNoMoreData()
|
else if (data?.isNullOrEmpty() == true)
|
refreshLayout.finishLoadMoreWithNoMoreData()
|
else if (page == 1)
|
refreshLayout.finishRefresh()
|
else
|
refreshLayout.finishLoadMore()
|
}){_,_->
|
if (page == 1)
|
refreshLayout.finishRefresh(false)
|
else
|
refreshLayout.finishLoadMore(false)
|
}
|
}
|
|
}
|