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

news2024/9/23 7:22:46

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

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

效果图:

实现代码:

<?xml version="1.0" encoding="utf-8"?>
<layout>
    <androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/color_48d17a">

        <include
            layout="@layout/wc_base_top_title"/>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/receive_payment_layout"
            android:layout_width="match_parent"
            android:layout_height="340dp"
            android:layout_marginVertical="20dp"
            android:layout_marginHorizontal="12dp"
            app:layout_constraintTop_toBottomOf="@+id/base_top_root_layout"
            app:layout_constraintStart_toStartOf="parent"
            android:background="#FFFFFF">

            <androidx.appcompat.widget.AppCompatImageView
                android:id="@+id/receive_payment_icon"
                android:layout_width="26dp"
                android:layout_height="26dp"
                android:layout_marginTop="12dp"
                android:layout_marginLeft="10dp"
                app:layout_constraintTop_toTopOf="@+id/receive_payment_layout"
                app:layout_constraintStart_toStartOf="parent"
                android:src="@drawable/wc_receive_payment_icon"/>

            <TextView
                android:id="@+id/receive_payment_tip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                app:layout_constraintTop_toTopOf="@+id/receive_payment_icon"
                app:layout_constraintBottom_toBottomOf="@+id/receive_payment_icon"
                app:layout_constraintStart_toEndOf="@+id/receive_payment_icon"
                android:text="向商家付款"
                android:textSize="16sp"
                android:textStyle="bold"
                android:textColor="#48d17a"/>


            <ImageView
                android:id="@+id/receive_payment_qrcode_icon"
                app:layout_constraintTop_toTopOf="@+id/receive_payment_layout"
                app:layout_constraintBottom_toBottomOf="@+id/receive_payment_layout"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:layout_marginTop="0dp"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:src="@drawable/ic_launcher"/>

            <LinearLayout
                android:id="@+id/receive_payment_from_divide"
                android:layout_width="match_parent"
                android:layout_height="0.5dp"
                android:layout_marginHorizontal="12dp"
                android:layout_marginTop="8dp"
                android:background="@color/gray"
                android:orientation="horizontal"
                android:visibility="gone"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/receive_payment_qrcode_icon" />

            <LinearLayout
                android:id="@+id/receive_payment_from_layout"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginHorizontal="12dp"
                android:layout_marginTop="12dp"
                android:orientation="horizontal"
                android:visibility="gone"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/receive_payment_qrcode_icon">

                <androidx.appcompat.widget.AppCompatImageView
                    android:id="@+id/receive_payment_from_avatar"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_gravity="center_vertical"
                    android:src="@drawable/ic_launcher" />

                <androidx.appcompat.widget.AppCompatTextView
                    android:id="@+id/receive_payment_from_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="12dp"
                    android:text="名称"
                    android:textColor="@color/black" />

                <androidx.appcompat.widget.AppCompatTextView
                    android:id="@+id/receive_payment_from_balance"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical|right"
                    android:layout_marginRight="12dp"
                    android:gravity="right"
                    android:text="金额"
                    android:textColor="@color/gray" />
            </LinearLayout>


        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/receive_payment_mask_layout"
            android:layout_width="match_parent"
            android:layout_height="340dp"
            android:layout_marginHorizontal="12dp"
            android:layout_marginVertical="20dp"
            android:background="#FFFFFF"
            android:visibility="gone"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/base_top_root_layout">
            <androidx.appcompat.widget.AppCompatImageView
                android:id="@+id/receive_payment_mask_icon"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                android:layout_marginTop="80dp"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:src="@drawable/ic_launcher"/>
            <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/receive_payment_mask_name"
                app:layout_constraintStart_toStartOf="@+id/receive_payment_mask_icon"
                app:layout_constraintEnd_toEndOf="@+id/receive_payment_mask_icon"
                app:layout_constraintTop_toBottomOf="@+id/receive_payment_mask_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="名称"
                android:textSize="20sp"
                android:textColor="@color/black"/>
            <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/receive_payment_mask_balance"
                app:layout_constraintStart_toStartOf="@+id/receive_payment_mask_icon"
                app:layout_constraintEnd_toEndOf="@+id/receive_payment_mask_icon"
                app:layout_constraintTop_toBottomOf="@+id/receive_payment_mask_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="30dp"
                android:text="¥0.00"
                android:textSize="30sp"
                android:textColor="@color/black"/>
        </androidx.constraintlayout.widget.ConstraintLayout>

        <com.wn.wechatclientdemo.view.LineBaseSmallView
            android:id="@+id/receive_payment_qrcode"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/receive_payment_layout"
            android:layout_marginTop="20dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />


    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

/**
 * Author : wangning
 * Email : maoning20080809@163.com
 * Date : 2022/5/20 21:08
 * Description : 收付款
 */
class ReceivePaymentFragment : BaseDataBindingFragment<WcReceivePaymentBinding>(){

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

}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/57483.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

这么简单,还不会使用java8 stream流的map()方法吗?

一、前言 在日常的开发工作中经常碰到要处理list中数据的问题&#xff0c;比如从数据库中查出了很多学生&#xff0c;由于一些原因需要在内存中找出这些学生中的所有姓名&#xff0c;或者把名为“王五”的语文成绩暂时修改为“100”&#xff0c;这些问题怎么处理呐&#xff0c…

初始C语言-1(数据类型、变量、常量、变量的作用域和生命周期、字符串+转义字符+注释)

目录 一、C语言 C语言主要运用于底层&#xff0c;也可以运用于上层软件&#xff08;早期还没有其他的语言的时候&#xff0c;很多游戏就是C语言做的&#xff09; C语言发展至今都是排行前三的计算机语言。 随着物联网&#xff0c;万物互联&#xff0c;以及嵌入式开发和单片机…

Java 面向对象的【三大特征】,你都掌握了吗

文章目录前言一、封装1.封装的概念2.访问修饰限定符3.初识 “ 包 ”4. static 成员static修饰成员变量static修饰成员方法static成员初始化二、继承1.为什么要继承2.继承的概念3.语法4.父类成员访问1.子类中访问父类的成员变量2.子类中访问父类的成员方法5. super 关键字6. 子类…

RabbitMQ之单机多实例部署

单机版安装前面介绍过了&#xff0c;不再介绍。 此处在单机版基础上 &#xff0c;也就是一台Linux虚拟机上启动多个RabbitMQ实例&#xff0c;部署集群。 1、在单个Linux虚拟机上运行多个RabbitMQ实例&#xff1a; 多个RabbitMQ使用的端口号不能冲突多个RabbitMQ使用的磁盘存…

李宏毅《DLHLP》学习笔记6 - 语言模型

视频链接&#xff1a;https://www.youtube.com/watch?vdymfkWtVUdo&listPLJV_el3uVTsO07RpBYFsXg-bN5Lu0nhdG&index8&ab_channelHung-yiLee 课件链接&#xff1a;https://speech.ee.ntu.edu.tw/~tlkagk/courses/DLHLP20/ASR3.pdf 1. Language Model LM的作用是预…

嵌入式Linux 开发经验:注册一个 misc 设备

前言 之前买过好几本Linux 设备驱动的书&#xff0c;不过对设备驱动一知半解&#xff0c;什么叫设备&#xff0c;什么又叫驱动&#xff1f;最近工作需要&#xff0c;从源码级别深入的研究了一下 Linux 下的设备与驱动的概念&#xff0c;略有所收获 一般提起驱动开发&#xff0…

[附源码]Python计算机毕业设计Django基于Java的图书购物商城

项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等等。 环境需要 1.运行环境&#xff1a;最好是python3.7.7&#xff0c;…

visual stduio code 配置高效舒适web生产环境

与webstrom 之前写了一篇webstorm的配置&#xff0c;参考同学的建议&#xff0c;vscode可能使用的人更多&#xff0c;所以配置了一个vs来试用看看。 一直用不习惯的是全文搜索&#xff0c;还是更喜欢webstrom弹窗式的&#xff0c;还可以显示上下文。包括其他的配置&#xff0…

第二证券|小鹏持续萎靡,理想蔚来逆势反弹破月销记录

12月1日&#xff0c;多家造车新势力先后公布11月销量数据。跟着“银十”出售旺季热度淡去&#xff0c;新势力品牌销量也受轿车零售商场逐渐冷却影响出现整体下滑。接连稳居榜首的埃安、哪吒等品牌均出现4位数以上环比销量下滑。上月商场体现低迷的抱负与蔚来则逆势添加&#xf…

TensorFlow之文本分类算法-6

1 前言 2 收集数据 3 探索数据 4 选择模型 5 准备数据 6 模型-构建训练评估 构建输出层 构建n-gram模型 构建序列模型 GloVe&#xff08;英文全称是Global Vectors for Word Representation&#xff09;是一个全球化的英语语境的单词表示的向量集&#xff0c;其使用非…

新变化新营销 这些知识点你得 Get!(文末有 PPT 福利首次放送)

更多技术交流、求职机会&#xff0c;欢迎关注字节跳动数据平台微信公众号&#xff0c;回复【1】进入官方交流群 在刚刚结束的第 7 期火山引擎数智平台 VeDI「增长课堂」上&#xff0c;火山引擎数智平台 VeDI 零售行业解决方案、汽车行业解决方案团队&#xff0c;以及慢慢买平台…

LM2903VQPWRQ1比较器 LM73C0QDDCRQ1传感器的中文资料

1、LM2903-Q1双路差分比较器包含两个独立的电压比较器&#xff0c;这些比较器可在宽电压范围内由单电源供电运行。如果两个电源之间的电压差在2V至36V且VCC比输入共模电压至少高1.5V以上&#xff0c;那么它们也可以由双电源供电运行。电流消耗不受电源电压的影响。可将输出连接…

一文带你深入理解【Java基础】· Java集合(下)

写在前面 Hello大家好&#xff0c; 我是【麟-小白】&#xff0c;一位软件工程专业的学生&#xff0c;喜好计算机知识。希望大家能够一起学习进步呀&#xff01;本人是一名在读大学生&#xff0c;专业水平有限&#xff0c;如发现错误或不足之处&#xff0c;请多多指正&#xff0…

Pikachu靶场全关攻略(超详细!)

一、靶场搭建 准备工具 phpstudy**pikachu靶场下载地址&#xff1a;**https://github.com/zhuifengshaonianhanlu/pikachu 搭建过程 将靶场文件夹放到phpstudy的www目录 进入pikach文件夹的inc目录&#xff0c;修改靶场配置文件config.inc.php&#xff0c;设置数据库账号密…

Ubuntu 安装 Zotero, 并导入原有数据库,然后同步账户

文章目录写在前面一、下载 Linux 下的 Zotero二、安装Zotero三、导入自己的数据库三、同步账户参考链接写在前面 发文时间&#xff1a;2022.12.03 自己的系统是Ubuntu20.04.5&#xff0c;Zotero 是 Zotero-6.0.18_linux-x86_64.tar.bz2 一、下载 Linux 下的 Zotero 直接登录…

魔兽世界开服教程——魔兽世界服务器架设全攻略---战网+Ladder排行版

需要用到的软件&#xff1a; 1. WAMP5 v1.7.exe &#xff08;这个是为排行榜提供数据库服务&#xff0c;为Mysql数据库&#xff09; 2.PvPGN-1.8.2-0-Win32-MySQL-5.0.45-BIN.zip PvPGN-1.8.2-0-Win32-SQLite-3.5.1-BIN.zip &#xff08;这三个是战网主文件&#xff09; pvpgn-…

使用dos命令符操作,感光屏绘图,ccd摄像头采集图像,并按程序进行机械加工的计算机

使用dos命令符操作&#xff0c;感光屏绘图&#xff0c;ccd摄像头采集图像&#xff0c;并按程序进行机械加工的计算机 使用dos命令符操作&#xff0c;感光屏绘图&#xff0c;ccd摄像头采集图像&#xff0c;并按程序进行机械加工的计算机是一种可以按照dos命令符复制磁带程序&…

yolov1算法思想流程简单讲解概述————(究极简单的讲述和理解)

在我想学习算法的时候&#xff0c;我看某些大佬特别喜欢上来就讲论文&#xff0c;给我搞的贼难受&#xff0c;毕竟本人太辣鸡了&#xff0c;上来这么搞看不懂&#xff0c;经过诸多算法的这样折磨。我打算根据自己的亲身经历和学习过程中遇到的问题出一期&#xff0c;先讲算法整…

智能优化算法(源码)—蜣螂优化算法(Dung beetle optimizer,DBO)

获取更多资讯&#xff0c;赶快关注上面的公众号吧&#xff01; 文章目录启发数学模型滚球跳舞繁殖觅食偷窃伪代码2022年11月27日&#xff0c;东华大学沈波教授团队&#xff0c;继麻雀搜索算法之后&#xff0c;又提出了一种全新的群体智能优化算法——蜣螂优化&#xff08;Dung …

功率信号源在超声波及智能骨料损伤监测中的应用

实验名称&#xff1a;超声波及智能骨料损伤监测原理 研究方向&#xff1a;无损检测、损伤定位 实验原理&#xff1a;换能器所产生的高频信号在介质中传播遇到裂缝、空洞等缺陷产生反射、折射、绕射等现象到达接收端时大量衰减&#xff0c;声学参量发生一定的变化&#xff0c;基…