Android在kts中使用navigation及Args

Android在kts中使用navigation及Args

前言:

​ 之前在项目中使用过navigation,但都是以Groory的方式,最近一年多使用kts后忍不住把项目都改成kts的方式,不过其中也遇到不少坑,今天就讲解一下如何在kts中使用navigation和安全地传递参数Args。

1.项目依赖导入:

在libs.versions.toml文件下添加以下依赖:

navigationFragmentKtx = "2.6.0"
navigationUiKtx = "2.6.0"navigation-fragment = {group = "androidx.navigation",name = "navigation-fragment-ktx",version.ref = "navigationFragmentKtx"}
navigation-ui = {group = "androidx.navigation",name = "navigation-ui-ktx",version.ref = "navigationUiKtx"}navigation-safe-args = { id = "androidx.navigation.safeargs.kotlin", version = "2.8.0" }

在这里插入图片描述

2.app目录的build.gradle配置:

plugins {alias(libs.plugins.androidApplication)alias(libs.plugins.jetbrainsKotlinAndroid)alias(libs.plugins.navigation.safe.args)
}implementation(libs.navigation.fragment)implementation(libs.navigation.ui)

在这里插入图片描述

在这里插入图片描述

3.项目的build.gradle配置:

plugins {alias(libs.plugins.androidApplication) apply falsealias(libs.plugins.jetbrainsKotlinAndroid) apply falsealias(libs.plugins.navigation.safe.args) apply false
}

在这里插入图片描述

4.在布局添加导航组件:

在res目录添加navigation——nav_graph文件

<?xml version="1.0" encoding="utf-8"?>
<navigation 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/nav_graph"app:startDestination="@id/mainFragment"><fragmentandroid:id="@+id/mainFragment"android:label="fragment_main"android:name="com.cloud.flowbusdemo.fragment.MainFragment"tools:layout="@layout/fragment_main"><actionandroid:id="@+id/action_mainFragment_to_secondFragment"app:destination="@id/secondFragment"app:popEnterAnim="@anim/slide_in_left"app:popExitAnim="@anim/slide_out_right"app:enterAnim="@anim/slide_in_right"app:exitAnim="@anim/slide_out_left"/><actionandroid:id="@+id/action_mainFragment_to_mineFragment"app:destination="@id/mineFragment"app:enterAnim="@anim/slide_in_left"app:exitAnim="@anim/slide_in_right"app:popEnterAnim="@anim/slide_out_left"app:popExitAnim="@anim/slide_out_right" /><argumentandroid:name="name"app:argType="string"android:defaultValue="xiaozhang"/><argumentandroid:name="age"app:argType="integer"android:defaultValue="1"/></fragment><fragmentandroid:id="@+id/secondFragment"android:label="fragment_second"android:name="com.cloud.flowbusdemo.fragment.SecondFragment"tools:layout="@layout/fragment_second"/><fragmentandroid:id="@+id/mineFragment"android:name="com.cloud.flowbusdemo.fragment.MineFragment"android:label="fragment_mine"tools:layout="@layout/fragment_mine" />
</navigation>

在这里插入图片描述

5.Fragment_main布局:

fragment_mine.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"xmlns:app="http://schemas.android.com/apk/res-auto"><androidx.appcompat.widget.AppCompatTextViewandroid:id="@+id/tvTitle"android:layout_width="0dp"android:layout_height="40dp"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toTopOf="parent"android:textSize="18sp"android:textColor="@color/white"android:gravity="center"android:text="MainFragment"android:layout_margin="20dp"android:background="@color/design_default_color_primary"tools:ignore="MissingConstraints" /><androidx.appcompat.widget.AppCompatTextViewandroid:id="@+id/btnToSecondFragment"android:layout_width="0dp"android:layout_height="40dp"app:layout_constraintTop_toBottomOf="@id/tvTitle"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"android:textAllCaps="false"android:textColor="@color/white"android:gravity="center"android:layout_margin="20dp"android:background="@color/design_default_color_primary"android:text="打开SecondFragment"/><androidx.appcompat.widget.AppCompatTextViewandroid:id="@+id/btnToMineFragment"android:layout_width="0dp"android:layout_height="40dp"app:layout_constraintTop_toBottomOf="@+id/btnToSecondFragment"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"android:textAllCaps="false"android:layout_marginTop="10dp"android:textColor="@color/white"android:gravity="center"android:layout_margin="20dp"android:background="@color/design_default_color_primary"android:text="打开MineFragment"/>
</androidx.constraintlayout.widget.ConstraintLayout>

6.Fragment_mine布局:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"xmlns:tools="http://schemas.android.com/tools"xmlns:app="http://schemas.android.com/apk/res-auto"><TextViewandroid:id="@+id/tvTitle"android:layout_width="200dp"android:layout_height="50dp"android:textSize="20sp"tools:text="姓名"android:gravity="center"android:background="@color/design_default_color_primary"app:layout_constraintTop_toTopOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"android:textColor="@color/white"android:layout_marginTop="20dp"/><TextViewandroid:id="@+id/tvAge"android:layout_width="200dp"android:layout_height="50dp"android:textSize="18sp"tools:text="年龄"android:gravity="center"android:background="@color/design_default_color_primary"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toBottomOf="@id/tvTitle"android:textColor="@color/white"android:layout_marginTop="20dp"/></androidx.constraintlayout.widget.ConstraintLayout>

7.Fragment_second布局:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"xmlns:tools="http://schemas.android.com/tools"xmlns:app="http://schemas.android.com/apk/res-auto"><TextViewandroid:id="@+id/tvTitle"android:layout_width="200dp"android:layout_height="50dp"android:textSize="20sp"tools:text="姓名"android:gravity="center"android:background="@color/design_default_color_primary"app:layout_constraintTop_toTopOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"android:textColor="@color/white"android:layout_marginTop="20dp"/><TextViewandroid:id="@+id/tvAge"android:layout_width="200dp"android:layout_height="50dp"android:textSize="18sp"tools:text="年龄"android:gravity="center"android:background="@color/design_default_color_primary"app:layout_constraintStart_toStartOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toBottomOf="@id/tvTitle"android:textColor="@color/white"android:layout_marginTop="20dp"/></androidx.constraintlayout.widget.ConstraintLayout>

8.activity_main主界面:

<?xml version="1.0" encoding="utf-8"?>
<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"tools:context=".MainActivity"><androidx.recyclerview.widget.RecyclerViewandroid:id="@+id/rv_wallpaper"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingStart="2dp"android:paddingEnd="2dp"android:visibility="gone" /><ProgressBarandroid:id="@+id/pb_loading"android:layout_width="wrap_content"android:layout_height="wrap_content"android:visibility="gone"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><TextViewandroid:id="@+id/btn_get_wallpaper"android:layout_width="0dp"android:layout_height="40dp"android:text="获取壁纸"android:textColor="@color/white"android:gravity="center"android:background="@color/design_default_color_primary"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"android:layout_margin="20dp"/><fragmentandroid:id="@+id/nav_host_fragment"android:name="androidx.navigation.fragment.NavHostFragment"android:layout_width="0dp"android:layout_height="0dp"app:defaultNavHost="true"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toBottomOf="@+id/btn_get_wallpaper"app:navGraph="@navigation/nav_graph"android:layout_marginTop="20dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>

9.MainActivity代码:

package com.cloud.flowbusdemoimport android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import com.blankj.utilcode.util.LogUtils
import com.cloud.flowbusdemo.databinding.ActivityMainBinding
import com.cloud.flowbusdemo.flow.FlowBus
import com.cloud.flowbusdemo.http.HttpUtils
import com.cloud.flowbusdemo.intent.MainIntent
import com.cloud.flowbusdemo.model.MessageEvent
import com.cloud.flowbusdemo.service.FlowBusTestService
import com.cloud.flowbusdemo.ui.adapter.WallpaperAdapter
import com.cloud.flowbusdemo.ui.viewmodel.MainViewModel
import com.cloud.flowbusdemo.ui.viewmodel.ViewModelFactory
import com.cloud.flowbusdemo.uistate.MainUIState
import com.cloud.flowbusdemo.utils.CToast
import com.cloud.flowbusdemo.utils.GenericToast
import com.cloud.flowbusdemo.utils.SingleToast
import kotlinx.coroutines.launchclass MainActivity : AppCompatActivity() {private lateinit var binding: ActivityMainBindingprivate lateinit var mainViewModel: MainViewModelprivate var wallPaperAdapter = WallpaperAdapter(arrayListOf())private val TAG = "flowBusDemo"private var mCToast: CToast? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)binding = ActivityMainBinding.inflate(layoutInflater)setContentView(binding.root)mainViewModel = ViewModelProvider(this,ViewModelFactory(HttpUtils.apiService))[MainViewModel::class.java]initView()observeViewModel()initService()}private fun initService() {val intent = Intent(this@MainActivity, FlowBusTestService::class.java)intent.putExtra("sockUrl","")startService(intent)}/*** ViewModel*/@SuppressLint("NotifyDataSetChanged")private fun observeViewModel() {lifecycleScope.launch {mainViewModel.state.collect {when (it) {is MainUIState.Idle -> {}is MainUIState.Loading -> {binding.btnGetWallpaper.visibility = View.GONEbinding.pbLoading.visibility = View.VISIBLE}is MainUIState.Success -> {     //数据返回binding.btnGetWallpaper.visibility = View.GONEbinding.pbLoading.visibility = View.GONEbinding.rvWallpaper.visibility = View.VISIBLEit.wallpaper.let { paper ->wallPaperAdapter.addData(paper.res.vertical)}wallPaperAdapter.notifyDataSetChanged()}is MainUIState.Error -> {binding.pbLoading.visibility = View.GONEbinding.btnGetWallpaper.visibility = View.VISIBLELog.d("TAG", "observeViewModel: $it.error")Toast.makeText(this@MainActivity, it.error, Toast.LENGTH_LONG).show()}}}}}/*** 初始化*/private fun initView() {binding.rvWallpaper.apply {layoutManager = GridLayoutManager(this@MainActivity, 2)adapter = wallPaperAdapter}binding.btnGetWallpaper.setOnClickListener {lifecycleScope.launch {mainViewModel.mainIntentChannel.send(MainIntent.GetWallpaper)}val intent = Intent(this@MainActivity,TestActivity::class.java)startActivity(intent)val timeToast =SingleToast.makeText(this@MainActivity, "显示时间自定的Toast", 10.0)timeToast.show()}FlowBus.with<MessageEvent>("test").register(this@MainActivity) {LogUtils.d(TAG,it.toString())if(it.message == "stop"){LogUtils.d(TAG,"===接收到的消息为==="+it.message)}}FlowBus.with<MessageEvent>("mineFragment").register(this@MainActivity) {LogUtils.d(TAG,it.toString())if(it.message == "onMine"){LogUtils.d(TAG,"===接收到的消息为1111==="+it.message)}}}
}

在这里插入图片描述

10.MainFragment代码:

package com.cloud.flowbusdemo.fragmentimport android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
import com.cloud.flowbusdemo.R
import com.cloud.flowbusdemo.databinding.FragmentMainBindingprivate const val ARG_PARAM_NAME = "name"
private const val ARG_PARAM_AGE = "age"/*** @auth: njb* @date: 2024/9/17 18:46* @desc: 描述*/
class MainFragment : Fragment() {private lateinit var binding: FragmentMainBindingprivate var name: String? = nullprivate var age: Int? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)arguments?.let {name = it.getString(ARG_PARAM_NAME)age = it.getInt(ARG_PARAM_AGE)}}override fun onCreateView(inflater: LayoutInflater,container: ViewGroup?,savedInstanceState: Bundle?): View {binding = FragmentMainBinding.inflate(layoutInflater)initView()return binding.root}private fun initView() {binding.btnToSecondFragment.setOnClickListener(View.OnClickListener { v ->/*      val bundle = Bundle()bundle.putString("name", "Michael")bundle.putInt("age", 30)*/val args: Bundle = Bundle().apply {this.putString(ARG_PARAM_NAME, "哈哈")this.putInt(ARG_PARAM_AGE, 25)}Navigation.findNavController(v).navigate(R.id.action_mainFragment_to_secondFragment, args)})binding.btnToMineFragment.setOnClickListener{v ->val args: Bundle = Bundle().apply {this.putString(ARG_PARAM_NAME, "Tom")this.putInt(ARG_PARAM_AGE, 18)}val navController = Navigation.findNavController(v)//navController.navigate(R.id.action_mainFragment_to_mineFragment, args)val bundle: Bundle = MainFragmentArgs("haha",20).toBundle()Navigation.findNavController(v).navigate(R.id.action_mainFragment_to_mineFragment,bundle)}}}

11.MineFragment代码:

package com.cloud.flowbusdemo.fragmentimport android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.navArgs
import com.cloud.flowbusdemo.databinding.FragmentMineBinding
import com.cloud.flowbusdemo.flow.FlowBus
import com.cloud.flowbusdemo.model.MessageEvent
import kotlinx.coroutines.launchprivate const val ARG_PARAM_NAME = "name"
private const val ARG_PARAM_AGE = "age"
/*** @auth: njb* @date: 2024/9/17 19:43* @desc: 描述*/
class MineFragment :Fragment(){private lateinit var binding: FragmentMineBindingprivate val TAG = "MineFragment"private var name: String? = nullprivate var age: Int? = 0private val args:MainFragmentArgs by  navArgs()override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)args.let {name = args.nameage = args.age}Log.i(TAG, "传递过来的参数为 name = $name , age = $age")Log.d(TAG, "姓名:" + name + "年龄:" + age)}override fun onCreateView(inflater: LayoutInflater,container: ViewGroup?,savedInstanceState: Bundle?): View {binding = FragmentMineBinding.inflate(layoutInflater)initView()return binding.root}private fun initView() {val messageEvent = MessageEvent()messageEvent.message = "onMine"messageEvent.state = falsebinding.let {it.tvTitle.text = nameit.tvAge.text  = age.toString()it.tvTitle.setOnClickListener {lifecycleScope.launch {FlowBus.with<MessageEvent>("mineFragment").post(this, messageEvent)}}}}
}

12.SecondFragment代码:

package com.cloud.flowbusdemo.fragmentimport android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.cloud.flowbusdemo.constants.Constants
import com.cloud.flowbusdemo.databinding.FragmentMineBinding
import com.cloud.flowbusdemo.databinding.FragmentSecondBinding
import com.cloud.flowbusdemo.flow.FlowBus
import com.cloud.flowbusdemo.model.MessageEvent
import kotlinx.coroutines.launch/*** @auth: njb* @date: 2024/9/17 18:48* @desc: 描述*/
class SecondFragment : Fragment(){private val TAG = "SecondFragment"private var name: String? = nullprivate var age: Int? = nullprivate lateinit var binding: FragmentSecondBindingoverride fun onCreateView(inflater: LayoutInflater,container: ViewGroup?,savedInstanceState: Bundle?): View {binding = FragmentSecondBinding.inflate(layoutInflater)initView()return binding.root}override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)arguments?.let {name = it.getString(Constants.ARG_PARAM_NAME)age = it.getInt(Constants.ARG_PARAM_AGE)}Log.i(TAG, "MainFragment 传递到 SecondFragment 的参数为 name = $name , age = $age")Log.d(TAG, "姓名:" + name + "年龄:" + age)}private fun initView() {binding.let {it.tvTitle.text = nameit.tvAge.text  = age.toString()}}
}

13.传递参数的方式:

13.1使用bundle:

binding.btnToSecondFragment.setOnClickListener(View.OnClickListener { v ->val bundle = Bundle()bundle.putString("name", "Michael")bundle.putInt("age", 30)Navigation.findNavController(v).navigate(R.id.action_mainFragment_to_secondFragment, bundle)
})

在这里插入图片描述

13.2使用Safs安全方式传递:

binding.btnToMineFragment.setOnClickListener{v ->val bundle: Bundle = MainFragmentArgs("haha",20).toBundle()Navigation.findNavController(v).navigate(R.id.action_mainFragment_to_mineFragment,bundle)
}

在这里插入图片描述

14.实现效果如下:

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

15.项目demo地址:

https://gitee.com/jackning_admin/flowbus-demo

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

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

相关文章

解决蓝牙键盘按键错乱的问题

最近发现我的蓝牙键盘按下的键盘与实际不符&#xff0c;于是就上网搜索答案&#xff0c;网上的方法都试了一遍 最后想着准备退货&#xff0c;没想到客服直接给我解决了 原因很简单&#xff0c;就是之前误触了键盘的某些按键导致的 每个键盘品牌的按键因该都不同的&#xff0c;可…

VBA技术资料MF220:删除模块内容

我给VBA的定义&#xff1a;VBA是个人小型自动化处理的有效工具。利用好了&#xff0c;可以大大提高自己的工作效率&#xff0c;而且可以提高数据的准确度。“VBA语言専攻”提供的教程一共九套&#xff0c;分为初级、中级、高级三大部分&#xff0c;教程是对VBA的系统讲解&#…

英伟达GPU算力【自用】

GPU&#xff08;图形处理单元&#xff09;算力的提升是驱动当代科技革命的核心力量之一&#xff0c;尤其在人工智能、深度学习、科学计算和超级计算机领域展现出了前所未有的影响力。2024年的GPU技术发展&#xff0c;不仅体现在游戏和图形处理的传统优势上&#xff0c;更在跨行…

【小白学机器学习21】 理解假设检验的关键:反证法

目录 理解假设检验的关键&#xff1a;反证法 1 假设的检验的出发点&#xff1a;H1假设&#xff0c; 1.1 为什么我们不去直接证明H1是否正确&#xff1f; 2 故意设立一个假设H1的否命题为H0 3 设定显著度α 4 总结假设检验的整个思路就是反证法 5 两类错误的关系 理解假…

ZooKeeper 客户端API操作

文章目录 一、节点信息1、创建节点2、获取子节点并监听节点变化3、判断节点是否存在4、客户端向服务端写入数据写入请求直接发给 Leader 节点写入请求直接发给 follow 节点 二、服务器动态上下线监听1、监听过程2、代码 三、分布式锁1、什么是分布式锁?2、Curator 框架实现分布…

AI视频监控平台教你如何行人追踪+人流量统计

行人追踪与人流量检测技术文档 1. 概述 本项目旨在通过使用ONNX和BYTETracker实现对视频中的行人进行实时追踪&#xff0c;并统计人流量变化。主要功能包括检测视频中的行人、追踪其位置变化、识别人流进出区域、并进行人流量的实时统计。本项目可以用于安全监控、人员流动分…

qt 滚动条 美化

qt QScrollBar 滚动条分为竖直与水平滚动条&#xff0c;两者设置上类似&#xff0c;但也有一些不同&#xff0c;下面主要讲述美化及注意事项。 一、竖直滚动条 竖直滚动条分为7个部分&#xff1a; sub-line、 up-arrow 、sub-page、 hanle、 add-line、 dow-arrow、 add-pag…

线性回归模型与检验 6个适用条件

当因变量与自变量间存在线性相关关系时&#xff0c;可以使用线性回归分析方法确定它们之间的相互依赖的定量关系。此处所说的定量关系&#xff0c;并非严格的因果关系&#xff0c;而是自变量X对因变量Y的影响或预测的作用。 例如分析广告费、产品单价、产品满意度、服务满意度…

说它是谁就是谁—Python语言中的鸭子类型

鸭子类型&#xff08;Duck Typing&#xff09;是动态类型语言中的一种类型推断风格&#xff0c;尤其在Python语言中得到了广泛的应用。它的核心思想是&#xff1a;“如果它走起路来像鸭子&#xff0c;叫起来像鸭子&#xff0c;那么它就是鸭子”。这句话的意思是&#xff0c;我们…

python_httpstat库

Python httpstat是一个基于Python的命令行工具&#xff0c;用于测量HTTP请求的性能和状态信息。它能够向目标服务器发送HTTP请求&#xff0c;并显示详细的统计信息&#xff0c;包括DNS解析时间、建立连接时间、TLS/SSL握手时间、首字节时间、总时间等。这些信息对于排查网络问题…

你是个优秀的人,但不是个好Leader

管理过程中&#xff0c;总有人长叹分身乏术&#xff0c;自己事必躬亲却收效甚微&#xff1b;总有人深陷日常繁琐&#xff0c;四处救火&#xff0c;似乎总有做不完的工作&#xff0c;操不完的心&#xff0c;这是为什么&#xff1f; 很大程度上是因为他们不懂管理的核心。无论…

详解varint,zigzag编码, 以及在Go标准库中的实现

文章目录 为啥需要varint编码为啥需要zigzag编码varint编码解码 zigzag编码解码 局限性 为啥需要varint编码 当我们用定长数字类型int32来表示整数时&#xff0c;为了传输一个整数1&#xff0c;我们需要传输00000000 00000000 00000000 00000001 32 个 bits&#xff0c;而有价…

使用 FastGPT + Ollama 搭建本地 AI 客服小助手

在数字化转型的背景下&#xff0c;越来越多的企业希望在服务体系中引入人工智能&#xff0c;以提供更高效的客户服务。而 AI 客服小助手的构建不仅可以解答客户的常见问题&#xff0c;还能减轻客服人员的工作压力&#xff0c;提高客户满意度。本文将介绍如何使用 FastGPT 和 Ol…

SQLite3库增删改查实现数据管理

1. SQLite3简介 SQLite3是一个轻量级的、嵌入式的关系型数据库管理系统&#xff0c;在保存测序数据或结果等时可使用&#xff0c;简单高效&#xff0c;并且有无需服务器、单文件存储数据、支持标准SQL、支持跨平台等优势。 本文以Sqlite3数据库为基础&#xff0c;创建代码示例…

tomcat基本配置

目录 1.java容器简介介绍 2.部署tomcat 2.1上传jdk 2.2创建一个软连接 2.3配置环境变量 2.4读取环境文件并且查看java版本 2.5检查jdk tomcat信息 2.6启动tomcat 2.7检测 3.tomcat 目录结构 3.1总体目录 3.2 bin目录 3.3conf 3.4 logs日志 4.运行代码 4.…

如何确保电子商务网站服务器的正常运行时间

对于电商网站而言&#xff0c;服务器的正常运行时间至关重要。网站宕机会直接影响销售额、客户体验以及品牌声誉。本文将详细探讨如何监控并保障服务器的正常运行时间&#xff0c;确保您的电商网站始终保持在线状态&#xff0c; 为什么监控正常运行时间很重要&#xff1f; 减…

【Oracle实验】字段为空的,无法通过排除判断

Oracle相关文档&#xff0c;希望互相学习&#xff0c;共同进步 风123456789&#xff5e;-CSDN博客 1.场景描述 需求&#xff1a;查询不是某个机构的数据。 同事SQL&#xff1a;where substr(bank_code,1,9) not in(014009001)&#xff1b; 看SQL似乎没什么问题&#xff0c;分析…

【modbus协议】libmodbus库移植基于linux平台

文章目录 下载库函数源码编译路径添加libmodbus 源码分析核心数据结构常用接口函数 开发 TCP Server 端开发TCP Client 端 下载库函数源码 编译路径添加 libmodbus 源码分析 核心数据结构 modbus_t结构体&#xff1a; 这是 libmodbus 的核心数据结构&#xff0c;代表一个 Mod…

【学术会议投稿】Imagen:重塑图像生成领域的革命性突破

【连续七届已快稳ei检索】第八届电子信息技术与计算机工程国际学术会议&#xff08;EITCE 2024&#xff09;_艾思科蓝_学术一站式服务平台 更多学术会议请看 https://ais.cn/u/nuyAF3 目录 引言 一、Imagen模型的技术原理 1. 模型概述 2. 工作流程 3. 技术创新 二、Ima…

达实智能深度融入鸿蒙生态,自研AIoT平台引领智慧空间新风向

10月22日&#xff0c;华为隆重举办了原生鸿蒙之夜暨华为全场景新品发布会&#xff0c;正式展示了HarmonyOS NEXT鸿蒙操作系统的最新进展和未来规划。华为常务董事、终端BG董事长、智能汽车解决方案BU董事长余承东公布了HarmonyOS NEXT&#xff08;鸿蒙OS5&#xff09;&#xff…