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:id="@+id/svideo_play_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/wc_base_bg">
<include layout="@layout/wc_base_top_title"/>
<com.wn.wechatclientdemo.view.SVideoView
android:id="@+id/svideo_play_view"
app:layout_constraintTop_toBottomOf="@+id/base_top_root_layout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/photo_preview_icon"
app:layout_constraintTop_toBottomOf="@+id/base_top_root_layout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/photo_preview_confirm"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:background="@drawable/wc_base_green_selector"
android:visibility="visible"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
android:text="完成"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
/**
* Author : wangning
* Email : maoning20080809@163.com
* Date : 2022/5/24 16:11
* Description : 朋友圈小视频播放
*/
class SVideoPlayFragment : BaseDataBindingFragment<WcSvideoPlayBinding>(){
override fun getLayoutRes() = R.layout.wc_svideo_play
private var navController: NavController? = null
private var enterType: Int = 0
private var isHideConfirm : Boolean = false
private var svideoView: SVideoView? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
navController = findNavController()
svideoView = svideo_play_view
//2图片、3、小视频
var type = arguments?.get(CommonUtils.Moments.TYPE_NAME) as Int
var filePath = arguments?.get(CommonUtils.Moments.TYPE_IMAGE_PATH).toString()
//小视频路径
var videoFilePath = arguments?.get(CommonUtils.Moments.TYPE_VIDEO_PATH).toString()
//enterType = arguments?.get(CameraFragment.TYPE_ENTER)
arguments?.let {
it.get(CameraFragment.TYPE_ENTER)?.let {
enterType = it as Int
}
it.get(CommonUtils.Chat.IS_HIDE_CONFIRM)?.let {
isHideConfirm = it as Boolean
}
}
if(type.equals(CommonUtils.Moments.TYPE_PICTURE)){
super.builder().setTitleContent(R.string.me_moments_picture_preview)
svideo_play_view.visibility = View.GONE
photo_preview_icon.visibility = View.VISIBLE
var degree = ImageUtils.getExifOrientation(filePath)
TagUtils.d("图片角度:${degree} , 图片路径:${filePath}")
if(degree == 0){
GlideUtils.load(photo_preview_icon, filePath)
} else {
GlideUtils.loadRounded(photo_preview_icon, filePath, degree)
}
} else if(type.equals(CommonUtils.Moments.TYPE_VIDEO)){
super.builder().setTitleContent(R.string.me_moments_video_preview)
svideo_play_view.visibility = View.VISIBLE
photo_preview_icon.visibility = View.GONE
TagUtils.d("播放小视频文件:${videoFilePath}")
svideo_play_view.initData(videoFilePath, true)
}
if(isHideConfirm){
photo_preview_confirm.visibility = View.GONE
}
photo_preview_confirm.setOnClickListener {
TagUtils.d("点击返回按钮:${enterType}")
if(enterType == CameraFragment.TYPE_CHAT){
var sVideoBean : SVideoBean? = null
if(type.equals(CommonUtils.Moments.TYPE_PICTURE)){
//图片
sVideoBean = SVideoBean(type, filePath)
} else if(type.equals(CommonUtils.Moments.TYPE_VIDEO)){
//小视频
sVideoBean = SVideoBean(type, videoFilePath)
}
EventBus.getDefault().post(sVideoBean)
navController?.popBackStack(R.id.nav_chat, false)
} else if(enterType == CameraFragment.TYPE_MOMENT){
TagUtils.d("跳转到发布:${type}, ${videoFilePath} , ${filePath}")
navController?.popBackStack()
var bundle = bundleOf(CommonUtils.Moments.TYPE_NAME to type,
CommonUtils.Moments.TYPE_IMAGE_PATH to filePath,
CommonUtils.Moments.TYPE_VIDEO_PATH to videoFilePath)
navController?.navigate(R.id.action_moments_publish, bundle)
} else {
TagUtils.d("点击返回按钮:else ")
}
}
svideo_play_root.setOnClickListener {
//svideo_play_view.onDestroy()
svideoView?.onDestroy()
Navigation.findNavController(it).popBackStack()
}
}
override fun onResume() {
super.onResume()
}
var isOnPause = false
override fun onStart() {
super.onStart()
if(isOnPause){
svideoView?.onStart()
isOnPause = false
}
}
override fun onPause() {
super.onPause()
isOnPause = true
svideoView?.onStop()
}
override fun onStop() {
super.onStop()
}
override fun onDestroy() {
super.onDestroy()
svideoView?.onDestroy()
}
}











![[附源码]SSM计算机毕业设计疫情期间回乡人员管理系统JAVA](https://img-blog.csdnimg.cn/0603036a6ba94913b9f4406318e0236d.png)



![[附源码]计算机毕业设计springboot汽车租赁管理系统](https://img-blog.csdnimg.cn/82b1f305fd5f4a758e928c18c25e3809.png)

![[附源码]JAVA毕业设计的问卷调查系统设计与实现(系统+LW)](https://img-blog.csdnimg.cn/0c4dd055e93449f0b43bc900526ab768.png)

