tj
2025-04-02 b25b3dbd7d277731449f3b4fca089fb017828eb3
app/src/main/java/com/example/firstapp/activity/VipActivity.kt
@@ -1,6 +1,7 @@
package com.example.firstapp.activity
import android.app.AlertDialog
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.util.TypedValue
@@ -18,6 +19,7 @@
import androidx.cardview.widget.CardView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.ContentProviderCompat.requireContext
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
@@ -96,6 +98,10 @@
        // 勾选协议点击事件
        handlePrototalClick()
        // VIP会员服务协议
        handleVipProtocolClick()
    }
@@ -105,11 +111,11 @@
        // 监听 RadioButton 选中状态
        protocol.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { buttonView, isChecked ->
            isPaymentSelected = isChecked // 更新全局变量
            if(isChecked){
                protocol.background = ContextCompat.getDrawable(this, R.drawable.checkbox_round_selected)
            }else{
                protocol.background = ContextCompat.getDrawable(this, R.drawable.checkbox_round)
            }
//            if(isChecked){
//                protocol.background = ContextCompat.getDrawable(this, R.drawable.checkbox_round_selected)
//            }else{
//                protocol.background = ContextCompat.getDrawable(this, R.drawable.checkbox_round)
//            }
        })
    }
@@ -472,9 +478,6 @@
    private fun loadUserInfo() {
        // 获取Fragment实例
        val memberInfoCardFragment = supportFragmentManager.findFragmentById(R.id.memberInfoCardFragment) as MemberInfoCardFragment?
        lifecycleScope.launch {
            try {
                // 从本地获取保存的手机号
@@ -501,4 +504,21 @@
    }
    // VIP会员服务协议
    private fun handleVipProtocolClick(){
        binding.protocolVip.setOnClickListener{
            startContentActivity("VIP会员服务协议", "VIP会员服务协议")
        }
    }
    private fun startContentActivity(type: String, title: String) {
        val intent = Intent(this, ContentDetailActivity::class.java).apply {
            putExtra(ContentDetailActivity.ID, type)
            putExtra(ContentDetailActivity.EXTRA_TITLE, title)
        }
        startActivity(intent)
    }
}