Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。
Kotlin高仿微信-项目实践58篇,点击查看详情
效果图:
实现代码:
** * 开通vip确认框 */ private fun showVipConfirmDialog(month: Int, vipBean: VipBean){ if(month < 1 || vipBean == null){ ToastUtils.makeText(R.string.wc_vip_confirm_show_error) return } getFocus(true) var view = LayoutInflater.from(requireContext()).inflate(R.layout.wc_vip_confirm_view, null) var width = DisplayUtils.getScreenWidth() - BaseUtils.getDimension(R.dimen.distance_40) * 2 val popupWindow = PopupWindow(view, width, ViewGroup.LayoutParams.WRAP_CONTENT) popupWindow.isOutsideTouchable = false //点击弹窗外部是否取消弹窗 //弹窗出现外部为阴影 val attributes: WindowManager.LayoutParams = requireActivity().window.getAttributes() attributes.alpha = 0.5f requireActivity().window.setAttributes(attributes) //弹窗取消监听 取消之后恢复阴影 popupWindow.setOnDismissListener { val attributes: WindowManager.LayoutParams = requireActivity().window.getAttributes() attributes.alpha = 1f requireActivity().window.setAttributes(attributes) getFocus(false) } popupWindow.showAtLocation(vip_recyclerview, Gravity.CENTER, 0, 0) var accountTextView = view.findViewById<TextView>(R.id.vip_confirm_account) var nameTextView = view.findViewById<TextView>(R.id.vip_confirm_name) var monthTextView = view.findViewById<TextView>(R.id.vip_confirm_month) accountTextView.text = BaseUtils.getString(R.string.wc_vip_manager_user_account, vipBean.userAccount) nameTextView.text = BaseUtils.getString(R.string.wc_vip_manager_user_name, vipBean.userName) monthTextView.text = BaseUtils.getString(R.string.wc_vip_confirm_month, "${month}") view.findViewById<TextView>(R.id.vip_confirm_cancel).setOnClickListener { popupWindow.dismiss() } view.findViewById<TextView>(R.id.vip_confirm_ok).setOnClickListener { popupWindow.dismiss() vipManagerViewModel.updateVip(vipBean.userAccount, vipBean.operatorAccount, month) } }
/** * vip会员续费 */ fun updateVip(userAccount : String, operatorAccount : String, month : Int){ if(TextUtils.isEmpty(userAccount) ||TextUtils.isEmpty(operatorAccount) || month < 1){ isSuccessLiveData.postValue(false) return } CoroutineScope(Dispatchers.IO).launch { var result = VipManagerRepository.updateVip(userAccount, operatorAccount, month) isSuccessLiveData.postValue(result.isSuccess) } }