18034727885
2026-08-11 74a412c8160dfeb8a3e9f6383d45b0495a928818
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
package com.fangxinxing.xxfxx.ui.mine
 
import android.app.Activity
import android.content.Intent
import androidx.recyclerview.widget.LinearLayoutManager
import cn.sinata.xldutils.view.SwipeRefreshRecyclerLayoutKt
import com.fangxinxing.xxfxx.R
import com.fangxinxing.xxfxx.base.MyBaseActivity
import com.fangxinxing.xxfxx.bean.BankCardListBean
import com.fangxinxing.xxfxx.bean.MyBank
import com.fangxinxing.xxfxx.netUtls.Api
import com.fangxinxing.xxfxx.netUtls.callNet
import com.fangxinxing.xxfxx.netUtls.getMapByAny
import com.fangxinxing.xxfxx.ui.adapter.MyBankAdapter
import kotlinx.android.synthetic.main.activity_bank_list.*
import org.jetbrains.anko.startActivityForResult
 
class BankListActivity : MyBaseActivity(),SwipeRefreshRecyclerLayoutKt.OnRefreshListener {
    override fun setContentView() {
        setContentView(R.layout.activity_bank_list)
    }
    private val canChoose by lazy { intent.getBooleanExtra("canChoose",false) }
 
    private val list = arrayListOf<MyBank>()
    private val adapter = MyBankAdapter(list)
 
    override fun initView() {
        setTitleText("银行卡")
        rv_card.setLayoutManager(LinearLayoutManager(this))
        rv_card.setMode(SwipeRefreshRecyclerLayoutKt.Mode.Top)
        rv_card.setOnRefreshListener(this)
        rv_card.setAdapter(adapter)
        getData()
    }
 
    override fun setOnclick() {
        tv_action.setOnClickListener {
            startActivityForResult<WithdrawAccountActivity>(1)
        }
        if (canChoose)
            adapter.setOnItemClickListener { view, position ->
                val intent = Intent()
                intent.putExtra("bankName",list[position].bankName).putExtra("cardName",list[position].openAccountName).putExtra("cardNum",list[position].code)
                setResult(Activity.RESULT_OK,intent)
                finish()
            }
    }
 
    private fun getData(){
        val map = getMapByAny()
        map["pageNumber"] = 1
        map["pageSize"] = 100
        callNet(Api.getBindCardList,map,{
            val data = gson.fromJson(it, BankCardListBean::class.java)
            rv_card.isRefreshing = false
            list.clear()
            list.addAll(data.data?: arrayListOf())
            adapter.notifyDataSetChanged()
        }){
            rv_card.isRefreshing = false
        }
    }
 
    override fun onRefresh() {
        getData()
    }
 
    override fun onLoadMore() {
    }
 
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == Activity.RESULT_OK){
            rv_card.isRefreshing = true
            onRefresh()
        }
    }
 
}