Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。
Kotlin高仿微信-项目实践58篇,点击查看详情
效果图:
实现代码:
//长按 inner class OnItemLongClick : WcOnItemLongClickInterface { override fun onItemLongClick(position: Int) { TagUtils.d("长按position:${position}"); var chatBean = adapter.getItemObject(position); TagUtils.d("长按chatBean:${chatBean?.content}"); showDeleteDialog(position) } }
//显示删除对话框 fun showDeleteDialog(position : Int){ var view = LayoutInflater.from(this.requireActivity()).inflate(R.layout.wc_chat_delete_tip, null) baseDialogUtils = BaseDialogUtils(this.requireActivity()) baseDialogUtils!!.builder() .showView(view) .setCancelable(false) .setOnLoadingClick(object : BaseDialogUtils.OnLoadingClick{ override fun onClickCancel() { } override fun onClickConfirm() { var chatBean = adapter.getItemObject(position) if(chatBean!=null){ chatViewModel.deleteChat(chatBean) } adapter.remove(position) } }) baseDialogUtils?.show() }
删除数据库数据 fun deleteChat(chatBean: ChatBean) { CoroutineScope(Dispatchers.IO).launch { ChatRepository.deleteChat(chatBean) } }