• Kotlin高仿微信-第34篇-支付-向商家付款(二维码)


     Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。

    Kotlin高仿微信-项目实践58篇,点击查看详情

    效果图:

    实现代码:

    
    
        
    
            
    
            
    
                
    
                
    
    
                
    
                
    
                
    
                    
    
                    
    
                    
                
    
    
            
    
            
                
                
                
            
    
            
    
    
        
    

    /**
     * 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))
        }
    
    }

  • 相关阅读:
    复制带随机指针的链表
    Java强软弱虚引用和ThreadLocal工作原理(一)
    面试总结之并发编程
    基于SSM+SpringBoot+Vue+ElementUI的校园疫情防控管理系统
    如何在 Windows Server 2022 阿里云服务器上搭建自己的 MQTT 服务器之一Apache-Apollo服务器。
    C++中的函数重载:多功能而强大的特性
    使用Postman+Xmysql自动化测试CloudOS服务接口
    产品经理想升职加薪?这个证书你考了吗?
    python查找算法_顺序查找
    Mac系统下TestCafe初体验
  • 原文地址:https://blog.csdn.net/maoning20080808/article/details/128132381