Kotlin高仿微信-第6篇-主页-我的
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。
Kotlin高仿微信-项目实践58篇,点击查看详情
效果图:
实现代码:
<?xml version="1.0" encoding="utf-8"?> <layout> <androidx.core.widget.NestedScrollView 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"><androidx.constraintlayout.widget.ConstraintLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginBottom="100dp"><TextViewandroid:layout_width="match_parent"android:layout_height="0.5dp"android:layout_marginStart="80dp"android:layout_marginTop="10dp"android:layout_marginEnd="20dp"android:background="@color/gray"android:text="-"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/me_personal_avatar" /><androidx.constraintlayout.widget.ConstraintLayoutandroid:id="@+id/me_personal_avatar"android:layout_width="match_parent"android:layout_height="wrap_content"android:foreground="?selectableItemBackground"android:layout_marginTop="36dp"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"><androidx.appcompat.widget.AppCompatImageViewandroid:id="@+id/me_personal_img"android:layout_width="80dp"android:layout_height="80dp"android:layout_marginStart="22dp"android:scaleType="center"android:src="@drawable/contacts_default_icon"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><androidx.appcompat.widget.AppCompatImageViewandroid:id="@+id/me_personal_right"android:layout_width="20dp"android:layout_height="20dp"android:layout_marginRight="10dp"android:src="@drawable/me_base_arrowright"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toTopOf="@+id/me_personal_account" /><androidx.appcompat.widget.AppCompatTextViewandroid:id="@+id/me_personal_account"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_marginBottom="10dp"android:text="账号:"android:textColor="@color/gray"android:textSize="18sp"app:layout_constraintBottom_toBottomOf="@+id/me_personal_img"app:layout_constraintStart_toEndOf="@+id/me_personal_img" /><androidx.appcompat.widget.AppCompatTextViewandroid:id="@+id/me_personal_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_marginTop="10dp"android:text="昵称"android:textColor="@color/black"android:textSize="22sp"android:textStyle="bold"app:layout_constraintStart_toEndOf="@+id/me_personal_img"app:layout_constraintTop_toTopOf="@+id/me_personal_img" /></androidx.constraintlayout.widget.ConstraintLayout><com.wn.wechatclientdemo.view.LineBaseViewandroid:id="@+id/me_payment"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/me_personal_avatar"android:layout_marginTop="22dp"android:layout_width="match_parent"android:layout_height="wrap_content"/><com.wn.wechatclientdemo.view.LineBaseViewandroid:id="@+id/me_scan"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/me_payment"android:layout_marginTop="6dp"android:layout_width="match_parent"android:layout_height="wrap_content"/><com.wn.wechatclientdemo.view.LineBaseViewandroid:id="@+id/me_moments"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/me_scan"android:layout_marginTop="6dp"android:layout_width="match_parent"android:layout_height="wrap_content"/><com.wn.wechatclientdemo.view.LineBaseViewandroid:id="@+id/me_setting"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/me_moments"android:layout_marginTop="6dp"android:layout_width="match_parent"android:layout_height="wrap_content"/></androidx.constraintlayout.widget.ConstraintLayout> </androidx.core.widget.NestedScrollView> </layout>
/*** Author : wangning* Email : maoning20080809@163.com* Date : 2022/4/21 12:24* Description : 一行通用控件, 左边一个图标, 右边一个箭头, 中间有标题和描述*/ class LineBaseView : LinearLayout {constructor(context:Context) : this(context, null)constructor(context: Context, attributeSet: AttributeSet?) : this(context, attributeSet, 0)constructor(context: Context, attributeSet: AttributeSet? , defStyleAttr : Int) : super(context, attributeSet, defStyleAttr){}var baseView : View? = nullinit {baseView = LayoutInflater.from(context).inflate(R.layout.wc_line_base_view, this)}fun builder() : Builder{return Builder(line_base_left, line_base_right, line_base_title, line_base_content, line_base_root, line_base_dividing)}class Builder(leftImageView : ImageView, rightImageView : ImageView, titleTextView : TextView,contentTextView : TextView, rootView : ConstraintLayout, dividingView : TextView) {private var leftImageView : ImageView = leftImageViewprivate var rightImageView = rightImageViewprivate var titleTextView = titleTextViewprivate var contentTextView = contentTextViewprivate var rootView = rootViewprivate var dividingView = dividingViewfun setLeftImage(resId : Int) : Builder{leftImageView.setImageResource(resId)return this}fun setLeftClick(onClickListener: OnClickListener) : Builder{leftImageView.setOnClickListener(onClickListener)return this}fun hideLeftImage() : Builder {leftImageView.visibility = GONEreturn this}fun setTitle(resId: Int) : Builder {titleTextView.text = WcApp.getContext().resources.getString(resId)return this}fun setTitle(title: String) : Builder {titleTextView.text = titlereturn this}fun setTitleColor(colorId : Int) : Builder {titleTextView.setTextColor(WcApp.getContext().resources.getColor(colorId))return this}fun setTitleSize(size : Float) : Builder{titleTextView.setTextSize(size)return this}fun setContentSize(size : Float) : Builder{contentTextView.setTextSize(size)return this}fun setContentColor(colorId : Int) : Builder {contentTextView.setTextColor(WcApp.getContext().resources.getColor(colorId))return this}fun setContent(resId : Int) : Builder {contentTextView.text = WcApp.getContext().resources.getString(resId)return this}fun setContent(content : String) : Builder {contentTextView.text = contentreturn this}fun hideContent() : Builder{contentTextView.visibility = GONEreturn this}fun showContent() : Builder{contentTextView.visibility = VISIBLEreturn this}fun setRightImage(resId : Int) : Builder{rightImageView.setImageResource(resId)return this}fun setRightClick(onClickListener: OnClickListener) : Builder {rightImageView.setOnClickListener(onClickListener)return this}fun hideRightImage() : Builder {rightImageView.visibility = GONEreturn this}fun setRootClick(onClickListener: OnClickListener) : Builder {rootView.setOnClickListener(onClickListener)return this}fun hideDevideingView() : Builder{dividingView.visibility = View.GONEreturn this}}}
/*** author : wangning* email : maoning20080809@163.com* Date : 2022/4/7 13:12* description : 我的页面*/ class MeFragment : BaseDataBindingFragment<WcFragmentMeBinding>() {override fun getLayoutRes()= R.layout.wc_fragment_me//文件存储权限private val REQ_CODE_STORAGE = 1private val userViewModel : UserViewModel by viewModels()override fun onViewCreated(view: View, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState)initView()me_personal_avatar.setOnClickListener {Navigation.findNavController(it).navigate(R.id.action_me_personal)}//handlePermission()initData()//先判断是否已经注册if(!EventBus.getDefault().isRegistered(this)){EventBus.getDefault().register(this)}}@Subscribe(threadMode = ThreadMode.MAIN)fun onMessageCallback(obj: Any) {if(obj == null){return}if(obj is EventMsgBean){if(obj.type == EventMsgBean.TYPE_REFRESH_USER_NAME){//刷新昵称me_personal_name.text = obj.obj as String} else if(obj.type == EventMsgBean.TYPE_REFRESH_AVATAR){//刷新头像GlideUtils.load(me_personal_img, obj.obj as String)}}}override fun onDestroy() {super.onDestroy()EventBus.getDefault().unregister(this)}fun initView() {//支付me_payment.builder().setLeftImage(R.drawable.me_base_payment).setTitle(BaseUtils.getString(R.string.me_base_payment)).hideContent().setRootClick {Navigation.findNavController(it).navigate(R.id.action_me_payment)}/*//收藏me_collection.builder().setLeftImage(R.drawable.me_base_collection).setTitle(BaseUtils.getString(R.string.me_base_collection)).hideContent().setRootClick {Navigation.findNavController(it).navigate(R.id.action_me_collection)}*///朋友圈me_moments.builder().setLeftImage(R.drawable.me_base_moments).setTitle(BaseUtils.getString(R.string.me_base_moments)).hideContent().setRootClick {//旧的没实现 navCollection?.navigate(R.id.action_me_moments)Navigation.findNavController(it).navigate(R.id.action_discover_moments)}//扫一扫me_scan.builder().setLeftImage(R.drawable.wc_moments_scan).setTitle(BaseUtils.getString(R.string.me_moments_sanc)).hideContent().setRootClick {Navigation.findNavController(it).navigate(R.id.nav_qrcode_scan)}/*//视频号me_video.builder().setLeftImage(R.drawable.me_base_video).setTitle(BaseUtils.getString(R.string.me_base_video)).hideContent().setRootClick {Navigation.findNavController(it).navigate(R.id.action_me_video)}*///卡包/*me_card_bag.builder().setLeftImage(R.drawable.me_base_card_bag).setTitle(BaseUtils.getString(R.string.me_base_card_bag)).hideContent().setRootClick {Navigation.findNavController(it).navigate(R.id.action_me_card_bag)}*//*//表情me_expression.builder().setLeftImage(R.drawable.me_base_expression).setTitle(BaseUtils.getString(R.string.me_base_expression)).hideContent().setRootClick {Navigation.findNavController(it).navigate(R.id.action_me_expression)}*///设置me_setting.builder().setLeftImage(R.drawable.me_base_setting).setTitle(BaseUtils.getString(R.string.me_base_setting)).hideContent().setRootClick {Navigation.findNavController(it).navigate(R.id.action_me_setting)}}fun initData(){var account = DataStoreUtils.getAccount()userViewModel.getUserLocal(account)userViewModel.userBeanLocal.observe(viewLifecycleOwner){if(it == null) return@observeme_personal_name.text = it.nickNamevar accountResult = getString(R.string.wc_me_show_account, it.account)me_personal_account.text = accountResultGlideUtils.load(me_personal_img, it.getReallyAvatar(), R.drawable.contacts_default_icon)}userViewModel.avatarFilePathLiveData.observe(viewLifecycleOwner){if(!TextUtils.isEmpty(it)){GlideUtils.load(me_personal_img, it)}}}//授权成功,刷新页面fun refresh(){initData()}}
Kotlin高仿微信-第6篇-主页-我的相关推荐
- Kotlin高仿微信-第11篇-单聊-语音
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜 ...
- Kotlin高仿微信-第14篇-单聊-视频通话
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜索 ...
- Kotlin高仿微信-第34篇-支付-向商家付款(二维码)
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜 ...
- Kotlin高仿微信-第20篇-个人信息
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜 ...
- Kotlin高仿微信-第58篇-开通VIP
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫. ...
- Kotlin高仿微信-第26篇-朋友圈-选择图片、小视频对话框
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜 ...
- Kotlin高仿微信-第35篇-支付-二维码收款(二维码)
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫. ...
- Kotlin高仿微信-第8篇-单聊
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜索 ...
- Kotlin高仿微信-第23篇-个人信息-二维码名片
Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜 ...
最新文章
- myeclipse搭建php,MyEclipse常用配置图文教程
- 2022-2027年中国PPR管材行业发展态势及市场需求分析报告
- CodeBlocks 汉化教程及多语言
- matlab寻找函数对应的工具箱
- java开发简历编写_如何通过几个简单的步骤编写出色的初级开发人员简历
- JAVA使用FTPClient类读写FTP
- 用Eclipse搭建web项目
- java中RIGHT的值_java循环遍历, reduce(),reduceRight()方法和Object,keys遍历对象的属性...
- python免费课件-python入门ppt下载
- 计算机找不到网络链接,找不到宽带连接的解决办法-电脑故障
- 台积电、高通“示好”华为:恢复供货?
- 【备忘】Word在任意第M-N页间插入页码
- 关注渐冻症|菌群助力探索其发病机理及相关干预措施
- 《BREW进阶与精通——3G移动增值业务的运营、定制与开发》连载之27---BREW 应用定价
- Java中StringBuffer的相关运用与实践
- 为vim添加php和css函数字典
- 强烈推荐这11个Python开源项目,非常值得入门学习(从入门到Python高级开发)
- http访问服务器文件夹,HTTP访问网站文件夹的细节
- 微信收款助手消息不弹窗的解决办法
- 一图读懂赛灵思 UltraScale+ 新成员
热门文章
- .Net 5中对于http请求的压缩和解压缩(GZip,Brotli)
- Cisco配置发送日志到日志服务器
- Unity用户手册2019.3(中文版)1.3.1 常见资源类型
- NeurIPS 2019 | DetNAS:首个搜索物体检测Backbone的方法
- tcp 粘包 丢包 解决方案
- 吉林大学计算机伦理学,王爱民-吉林大学计算机科学与技术学院
- 第七讲:专注创造现实 第八讲:专注感激 第九讲:感激改变
- Qt 添加 QtNetwork 库文件(包括vs中和qt中)
- scratch3.0自定义logo
- 1.1双摇杆遥控器电路部分--stm32最小系统