| | |
| | | import android.widget.Toast |
| | | import androidx.activity.result.contract.ActivityResultContracts |
| | | import androidx.appcompat.app.AppCompatActivity |
| | | import androidx.core.content.ContextCompat |
| | | import androidx.fragment.app.Fragment |
| | | import androidx.lifecycle.Observer |
| | | import androidx.lifecycle.lifecycleScope |
| | | import androidx.navigation.fragment.findNavController |
| | | import com.google.android.material.dialog.MaterialAlertDialogBuilder |
| | |
| | | import com.example.firstapp.activity.ContentDetailActivity |
| | | import com.example.firstapp.database.service.RetrofitClient |
| | | import com.example.firstapp.databinding.FragmentNotificationsBinding |
| | | import com.example.firstapp.pay.PayAbility |
| | | import com.example.firstapp.ui.reminderOther.ReminderOtherAddActivity2 |
| | | import com.example.firstapp.ui.reminderOther.ReminderSettingsFragmentOther |
| | | import com.example.firstapp.ui.profile.EditProfileActivity |
| | | import com.example.firstapp.utils.Log |
| | | import com.google.android.material.snackbar.Snackbar |
| | | import kotlinx.coroutines.launch |
| | | import com.bumptech.glide.Glide |
| | | import com.example.firstapp.activity.VipActivity |
| | | import com.example.firstapp.database.response.UserInfo |
| | | |
| | | class NotificationsFragment : Fragment() { |
| | |
| | | } |
| | | |
| | | private fun setupClickListeners() { |
| | | |
| | | |
| | | // 设置提醒 |
| | | binding.layoutReminder.setOnClickListener { |
| | | findNavController().navigate(R.id.action_navigation_notifications_to_reminderSettingsFragment) |
| | |
| | | } |
| | | |
| | | // 头像点击老的处理逻辑 |
| | | // 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 { |
| | | currentUserInfo?.let { user -> |
| | | val intent = Intent(requireContext(), EditProfileActivity::class.java).apply { |
| | |
| | | |
| | | // VIP续费 |
| | | binding.btnRenew.setOnClickListener { |
| | | Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show() |
| | | // Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show() |
| | | // 跳转到vipActivity |
| | | val intent = Intent(requireContext(), VipActivity::class.java) |
| | | startActivity(intent) |
| | | } |
| | | |
| | | binding.cardVip.setOnClickListener { |
| | | // Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show() |
| | | // 跳转到vipActivity |
| | | val intent = Intent(requireContext(), VipActivity::class.java) |
| | | startActivity(intent) |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | private fun showEmailDialog() { |
| | |
| | | .load(userInfo.cover) |
| | | .placeholder(R.drawable.default_avatar) |
| | | .into(binding.ivAvatar) |
| | | |
| | | |
| | | // 设置昵称和账号 |
| | | binding.tvNickname.text = userInfo.name |
| | | binding.tvUserId.text = "个人账号:${userInfo.contactTel}" |
| | | |
| | | |
| | | // 设置VIP信息 |
| | | if (userInfo.showed) { |
| | | binding.ivVip.visibility = View.VISIBLE |
| | | binding.cardVip.visibility = View.VISIBLE |
| | | binding.tvVipExpire.text = "${userInfo.passTime} 到期" |
| | | binding.tvVipExpire.text = "${userInfo.overTime} 到期" |
| | | } else { |
| | | //非会员信息 |
| | | binding.btnRenew.text = "立即开通" |
| | | binding.linearVipContainer.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.gray)) |
| | | binding.cardVip.visibility = View.GONE |
| | | } |
| | | } |
| | |
| | | |
| | | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| | | super.onViewCreated(view, savedInstanceState) |
| | | |
| | | |
| | | // 加载用户信息 |
| | | lifecycleScope.launch { |
| | | loadUserInfo() |