| | |
| | | import com.google.android.material.dialog.MaterialAlertDialogBuilder |
| | | import com.example.firstapp.R |
| | | import com.example.firstapp.activity.ContentDetailActivity |
| | | import com.example.firstapp.activity.ReminderSettingsActivity |
| | | import com.example.firstapp.database.service.RetrofitClient |
| | | import com.example.firstapp.databinding.FragmentNotificationsBinding |
| | | import com.example.firstapp.pay.PayAbility |
| | |
| | | import com.google.android.material.snackbar.Snackbar |
| | | import kotlinx.coroutines.launch |
| | | import com.bumptech.glide.Glide |
| | | import com.example.firstapp.activity.SettingActivity |
| | | import com.example.firstapp.activity.VipActivity |
| | | import com.example.firstapp.database.response.UserInfo |
| | | import com.example.firstapp.ui.invitation.InvitationActivity |
| | | import com.example.firstapp.utils.PreferencesManager |
| | | |
| | | class NotificationsFragment : Fragment() { |
| | |
| | | private val binding get() = _binding!! |
| | | |
| | | // 默认值 |
| | | private val DEFAULT_XIAOHONGSHU_URL = "https://www.xiaohongshu.com/user/profile/64978d5c000000001001ee26" |
| | | private val DEFAULT_EMAIL = "support@example.com" |
| | | private val DEFAULT_SHARE_TEXT = "推荐一个很棒的应用给你!\n下载地址:https://oia.xiaohongshu.com/oia" |
| | | private val DEFAULT_XIAOHONGSHU_URL = "https://www.xiaohongshu.com/user/profile/5812f5507fc5b818ce813383" |
| | | private val DEFAULT_EMAIL = "yuy@cloudroam.com.cn" |
| | | private val DEFAULT_SHARE_TEXT = "推荐一个很棒的应用给你!\n下载地址:http://14.103.144.28:8888/" |
| | | |
| | | // 存储从接口获取的值 |
| | | private var xiaohongshuUrl = "" |
| | |
| | | return binding.root |
| | | } |
| | | |
| | | override fun onResume() { |
| | | super.onResume() |
| | | // 加载用户信息 |
| | | lifecycleScope.launch { |
| | | loadUserInfo() |
| | | } |
| | | } |
| | | |
| | | private suspend fun loadConfigurations() { |
| | | try { |
| | | // 获取小红书链接 |
| | |
| | | |
| | | private fun setupClickListeners() { |
| | | |
| | | |
| | | // 设置提醒 |
| | | binding.layoutReminder.setOnClickListener { |
| | | findNavController().navigate(R.id.action_navigation_notifications_to_reminderSettingsFragment) |
| | | // 判断是否是会员 |
| | | currentUserInfo?.let { user -> |
| | | if (user.isMember) { |
| | | // 是会员,跳转到提醒设置页面 |
| | | val intent = Intent(requireContext(), ReminderSettingsActivity::class.java) |
| | | startActivity(intent) |
| | | } else { |
| | | // 不是会员,跳转到VIP页面 |
| | | val intent = Intent(requireContext(), VipActivity::class.java) |
| | | intent.putExtra("source", "reminder") |
| | | startActivity(intent) |
| | | Toast.makeText(context, "开通会员后可使用提醒功能", Toast.LENGTH_SHORT).show() |
| | | } |
| | | } ?: run { |
| | | Toast.makeText(context, "正在加载用户信息,请稍后再试", Toast.LENGTH_SHORT).show() |
| | | } |
| | | } |
| | | |
| | | // 待办 |
| | |
| | | |
| | | // 好友邀请 |
| | | binding.layoutInvite.setOnClickListener { |
| | | shareToWechat() |
| | | // 跳转到邀请活动页面 |
| | | val intent = Intent(requireActivity(), InvitationActivity::class.java) |
| | | startActivity(intent) |
| | | } |
| | | |
| | | // AI助手 |
| | |
| | | binding.btnRenew.setOnClickListener { |
| | | // Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show() |
| | | // 跳转到vipActivity |
| | | val intent = Intent(requireContext(), VipActivity::class.java) |
| | | startActivity(intent) |
| | | //2025-04-24 取消续费跳转操作 |
| | | // val intent = Intent(requireContext(), VipActivity::class.java) |
| | | // startActivity(intent) |
| | | Toast.makeText(context, "免费体验,无需续费", Toast.LENGTH_SHORT).show() |
| | | } |
| | | |
| | | binding.cardVip.setOnClickListener { |
| | | // Toast.makeText(context, "VIP续费功能开发中", Toast.LENGTH_SHORT).show() |
| | | // 跳转到vipActivity |
| | | val intent = Intent(requireContext(), VipActivity::class.java) |
| | | // val intent = Intent(requireContext(), VipActivity::class.java) |
| | | // startActivity(intent) |
| | | Toast.makeText(context, "免费体验,无需续费", Toast.LENGTH_SHORT).show() |
| | | } |
| | | |
| | | // 设置按钮点击 |
| | | binding.ivSetting.setOnClickListener { |
| | | // 跳转到 |
| | | val intent = Intent(requireContext(), SettingActivity::class.java) |
| | | startActivity(intent) |
| | | } |
| | | |
| | |
| | | currentUserInfo = response.data |
| | | val userInfo = response.data |
| | | |
| | | // 本地保存我的邀请码 |
| | | PreferencesManager.setInviteCode(userInfo.intervialcode); |
| | | // 设置头像 |
| | | Glide.with(this) |
| | | .load(userInfo.cover) |