Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。
效果图:
实现代码:
/** * Author : wangning * Email : maoning20080809@163.com * Date : 2022/5/20 21:08 * Description : 收付款 */ class ReceivePaymentFragment : BaseDataBindingFragment(){ override fun getLayoutRes() = R.layout.wc_receive_payment override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) super.builder() .setTitleContent(R.string.wc_base_top_receive_payment) .setTitleColor(R.color.white) .setBack(R.drawable.wc_white_back) UIStatusUtils.setStatusBarColor(requireActivity(), BaseUtils.getColor(R.color.color_48d17a)) //先判断是否已经注册 if(!EventBus.getDefault().isRegistered(this)){ EventBus.getDefault().register(this) } //二维码收款 receive_payment_qrcode.builder() .setLeftImage(R.drawable.wc_receive_payment_item_icon) .setTitle(BaseUtils.getString(R.string.wc_receive_payment_qrcode)) .hideContent() .hideDevideingView() .setTitleColor(R.color.white) .setTitleSize(18f) .setRootClick { Navigation.findNavController(it).navigate(R.id.action_qrcode_receive) } var account = DataStoreUtils.getAccount() var result = CommonUtils.QRCommon.QR_PAYMENT_CODE + account var bitmap = QRUtils.createQRCode(result, 300, 300,null); receive_payment_qrcode_icon.setImageBitmap(bitmap) } //向商家付款成功,显示动画 private fun processMask(account : String, balace: Float){ receive_payment_mask_layout.visibility = View.VISIBLE receive_payment_mask_balance.text = CommonUtils.Base.getFormatBalanceUnit(balace) BaseUtils.showAvatar(account, receive_payment_mask_icon, receive_payment_mask_name) CoroutineScope(Dispatchers.Main).launch { delay(1000) val animationSet = AnimationSet(true) animationSet.setAnimationListener(object : Animation.AnimationListener{ override fun onAnimationEnd(p0: Animation?) { receive_payment_mask_layout.visibility = View.GONE } override fun onAnimationRepeat(p0: Animation?) { } override fun onAnimationStart(p0: Animation?) { } }) var scaleAnimation = ScaleAnimation(1f,0.0f,1f,0.0f, Animation.RELATIVE_TO_SELF,1f, Animation.RELATIVE_TO_SELF,1f) scaleAnimation.duration = 1500 animationSet.addAnimation(scaleAnimation) receive_payment_mask_layout.startAnimation(animationSet) } } @Subscribe(threadMode = ThreadMode.MAIN) fun onMessageCallback(paymentBean: PaymentBean) { if(paymentBean == null){ receive_payment_from_balance.text = "支付失败!" } else if(paymentBean.operator == CommonUtils.User.OPERATOR_MINUS){ TagUtils.d("向商家付款:${paymentBean.balance} , ${paymentBean.fromAccount} , ${paymentBean.toAccount} , ${paymentBean.operator}") receive_payment_from_layout.visibility = View.VISIBLE receive_payment_from_divide.visibility = View.VISIBLE receive_payment_from_balance.text = paymentBean.balance.toString() BaseUtils.showAvatar(paymentBean.fromAccount, receive_payment_from_avatar,receive_payment_from_name) processMask(paymentBean.fromAccount, paymentBean.balance) } } override fun onDestroy() { super.onDestroy() EventBus.getDefault().unregister(this) UIStatusUtils.setStatusBarColor(requireActivity(), BaseUtils.getColor(R.color.wc_base_bg)) } }