| | |
| | | import com.example.firstapp.ui.profile.EditProfileActivity |
| | | import kotlinx.coroutines.launch |
| | | import com.bumptech.glide.Glide |
| | | import com.example.firstapp.database.response.UserInfo |
| | | |
| | | class NotificationsFragment : Fragment() { |
| | | |
| | |
| | | private var xiaohongshuUrl = "" |
| | | private var contactEmail = "" |
| | | private var shareText = "" |
| | | private var currentUserInfo: UserInfo? = null // 确保使用你的实际数据类 |
| | | |
| | | |
| | | private val editProfileLauncher = registerForActivityResult( |
| | | ActivityResultContracts.StartActivityForResult() |
| | |
| | | startContentActivity("user_guide", "使用教程") |
| | | } |
| | | |
| | | // 头像点击 |
| | | // 头像点击老的处理逻辑 |
| | | // binding.layoutUserInfo.setOnClickListener { |
| | | // val intent = Intent(requireContext(), EditProfileActivity::class.java).apply { |
| | | // putExtra("nickname", binding.tvNickname.text.toString()) |
| | | // putExtra("avatar_url", binding.ivAvatar.toString()) |
| | | // } |
| | | // editProfileLauncher.launch(intent) |
| | | // } |
| | | |
| | | binding.layoutUserInfo.setOnClickListener { |
| | | val intent = Intent(requireContext(), EditProfileActivity::class.java).apply { |
| | | putExtra("nickname", binding.tvNickname.text.toString()) |
| | | // 如果有当前头像的URL,也可以传递 |
| | | // putExtra("avatar_url", currentAvatarUrl) |
| | | currentUserInfo?.let { user -> |
| | | val intent = Intent(requireContext(), EditProfileActivity::class.java).apply { |
| | | putExtra("nickname", user.name) // 使用数据模型中的字段 |
| | | putExtra("avatar_url", user.cover) // 使用正确的URL字段 |
| | | } |
| | | editProfileLauncher.launch(intent) |
| | | } ?: run { |
| | | Toast.makeText(context, "用户信息未加载完成", Toast.LENGTH_SHORT).show() |
| | | } |
| | | editProfileLauncher.launch(intent) |
| | | } |
| | | |
| | | // VIP续费 |
| | |
| | | try { |
| | | val response = RetrofitClient.apiService.getUserInfo("17586582287") |
| | | if (response.code == "0" && response.data != null) { |
| | | // 保存用户信息 |
| | | currentUserInfo = response.data |
| | | val userInfo = response.data |
| | | |
| | | |
| | | // 设置头像 |
| | | Glide.with(this) |
| | | .load(userInfo.cover) |
| | |
| | | |
| | | // 设置VIP信息 |
| | | if (userInfo.showed) { |
| | | binding.ivVip.visibility = View.VISIBLE |
| | | binding.cardVip.visibility = View.VISIBLE |
| | | binding.tvVipExpire.text = "${userInfo.passTime} 到期" |
| | | } else { |
| | |
| | | import androidx.core.app.ActivityCompat |
| | | import androidx.core.content.ContextCompat |
| | | import com.bumptech.glide.Glide |
| | | import com.example.firstapp.R |
| | | import com.example.firstapp.databinding.ActivityEditProfileBinding |
| | | |
| | | class EditProfileActivity : AppCompatActivity() { |
对比新文件 |
| | |
| | | <vector xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:width="128dp" |
| | | android:height="128dp" |
| | | android:viewportWidth="1024" |
| | | android:viewportHeight="1024"> |
| | | <path |
| | | android:pathData="M511,831.7c-23.5,0 -45.5,-9.9 -61.6,-27.2L139,468.1c-28.7,-31.3 -29.8,-79.4 -1.6,-111.8l117.6,-135.3c15.7,-18.3 38.7,-28.7 63.2,-28.7H705.3c24,0 47,10.4 62.7,28.7l118.1,135.3c28.2,32.4 27.7,80.5 -1.6,111.8L572.1,804.6c-15.7,17.2 -38.1,27.2 -61.1,27.2z" |
| | | android:fillColor="#F2CB51"/> |
| | | <path |
| | | android:pathData="M506.8,642.6c-5.2,0 -11,-2.1 -15.2,-6.3l-203.8,-209c-7.8,-8.4 -7.8,-21.4 0.5,-29.8 8.4,-7.8 21.4,-7.8 29.8,0.5l189.1,193.8 199.1,-194.4c8.4,-7.8 21.4,-7.8 29.8,0.5 7.8,8.4 7.8,21.4 -0.5,29.8l-214.2,209c-4.2,3.7 -9.4,5.7 -14.6,5.7z" |
| | | android:fillColor="#FFF7E1"/> |
| | | </vector> |
| | |
| | | android:scaleType="centerCrop" |
| | | app:shapeAppearanceOverlay="@style/CircleImageView" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_vip" |
| | | android:layout_width="24dp" |
| | | android:layout_height="24dp" |
| | | android:layout_alignBottom="@id/tv_nickname" |
| | | android:layout_marginStart="8dp" |
| | | android:layout_toEndOf="@id/tv_nickname" |
| | | android:contentDescription="VIP标识" |
| | | android:src="@drawable/me_vip" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_nickname" |
| | | android:layout_width="wrap_content" |