lmw
2025-04-24 718f31c92e2029d05260810435a2c70cef6e6ce5
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
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)
        }
    }
 
}