帧动画如何实现,网上一搜一堆,不再赘述。

这里记录下实现的一个需求。

播放卫星云图,所谓云图,就是很多张图片连起来。所以播放的效果就是帧动画的效果。

那么首先想到的实现方式就是帧动画-----AnimationDrawable。

也确实是这样,用帧动画实现此效果很简单,就是常规的实现方式。

主要实现如下:

private fun loadFrameImages() {for (pos in mImageList.indices) {loadImage(mImageList[pos], pos)}}private fun loadImage(url: String?, pos: Int) {runSafety {url?.let {val simpleTarget = object: SimpleTarget<Drawable>() {override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {mHashMap[pos] = resourceaddFrameToPlay()}}Glide.with(this).load(it).into(simpleTarget)}}}private fun addFrameToPlay() {if (mHashMap.size > 0 && mHashMap.size == mImageList.size) {tvFrameEnd?.text = "" + mHashMap.sizefor (index in mImageList.indices) {mAnimationDrawable?.addFrame(mHashMap[index], 500)}ivCloud?.setImageDrawable(mAnimationDrawable)isPlaying = truemAnimationDrawable?.startAuto()ivPlay?.setBackgroundResource(R.mipmap.icon_cloud_pause)tvFrameStart?.text = "" + getCurrentIndex()}}

AnimationDrawable其实就是个Drawable,本身并没有监听。而我们需要监听动画播放开始,结束。所以自定义实现。

class CustomAnimationDrawable: AnimationDrawable() {private var mHandler = Handler()private val mAnimationRunnable = Runnable { dealWithCallback() }private var mMaxDuration: Long = 0Lprivate var mOnFrameAnimationListener: OnFrameAnimationListener? = nullprivate fun dealWithCallback() {//获取最后一帧,和当前帧做比较,如果相等,就结束动画,调用动画结束回调Trace.e("dealWithCallback", "当前帧是: $current")if (getFrame(numberOfFrames - 1) != current) {mOnFrameAnimationListener?.onFramePlaying(current)initHandlerFrame(current) //如果不是最后一帧,重新启动handler} else {onFinish() //如果是最后一帧,触发结束回调}}private fun initHandler(index: Int) {Trace.e("initHandler", "重新播放: $index")val delayMills = if (mMaxDuration == 0L) getMaxDurationIndex(index) else mMaxDurationmHandler?.postDelayed(mAnimationRunnable, delayMills)}private fun initHandlerFrame(frame: Drawable?) {val delayMills = if (mMaxDuration == 0L) getMaxDuration(frame) else mMaxDurationmHandler?.postDelayed(mAnimationRunnable, delayMills)}private fun onFinish() {mOnFrameAnimationListener?.onFrameEnd()mHandler.removeCallbacks(mAnimationRunnable)}/*** 说明:重写开始方法监听动画* 作者:* 添加时间:2020/7/9 16:28* 修改人:* 修改时间:2020/7/9 16:28*/override fun start() {super.start()}override fun scheduleSelf(what: Runnable, `when`: Long) {super.scheduleSelf(what, `when`)}override fun stop() {super.stop()}fun startAuto() {initHandlerFrame(current)mOnFrameAnimationListener?.onFrameStart();//触发动画开始回调start()}fun startManual(currentIndex: Int) {initHandler(currentIndex)mOnFrameAnimationListener?.onFrameStart();//触发动画开始回调start()}fun stopManual(currentIndex: Int) {mHandler?.removeCallbacks(mAnimationRunnable)stop()mOnFrameAnimationListener?.onTempStop(current)}/*** 获取持续时间最长的帧的持续时间** @return 时间  如果这一帧大于1秒,则返回 1 秒,否则返回这一帧的持续时间*/private fun getMaxDuration(frame: Drawable?): Long {for (i in 0 until this.numberOfFrames) {if (mMaxDuration < getDuration(i)) {mMaxDuration = getDuration(i).toLong()}}return if (mMaxDuration > 1000) 1000 else mMaxDuration}private fun getMaxDurationIndex(index: Int): Long {for (i in 0 until index) {if (mMaxDuration < getDuration(i)) {mMaxDuration = getDuration(i).toLong()}}return if (mMaxDuration > 1000) 1000 else mMaxDuration}private fun getTotalDuration(): Long {var iDuration = 0for (i in 0 until this.numberOfFrames) {iDuration += getDuration(i)}return iDuration.toLong()}/*** 设置动画监听器** @param onFrameAnimationListener 监听器*/fun setOnFrameAnimationListener(onFrameAnimationListener: OnFrameAnimationListener?) {mOnFrameAnimationListener = onFrameAnimationListener}/*** 动画监听器*/interface OnFrameAnimationListener {/*** 动画开始*/fun onFrameStart()fun onFramePlaying(currentFrame: Drawable)fun onTempStop(currentFrame: Drawable?) //播放到某一帧,暂停/*** 动画结束*/fun onFrameEnd()}}

这样可以实现自动播放。

但是,无法实现暂停-播放效果。因为start()方法每次都是从第一帧开始播放的。

这种情况下就无法满足需求了。

那就换一种方式:

public class SurfaceViewAnimation extends TextureView implements TextureView.SurfaceTextureListener, Runnable {private String TAG = "SurfaceViewAnimation2";private boolean mIsThreadRunning = true; // 线程运行开关public boolean mIsDestroy = false;// 是否已经销毁private HashMap<Integer, Bitmap> mBitmapMaps = new HashMap<>();private int totalCount;//资源总数private Canvas mCanvas;private Bitmap mBitmap;// 显示的图片private int mCurrentIndext;// 当前动画播放的位置private int mGapTime = 50;// 每帧动画持续存在的时间private OnFrameFinishedListener mOnFrameFinishedListener;// 动画监听事件private Thread thread;Rect mSrcRect, mDestRect;public SurfaceViewAnimation(Context context) {this(context, null);initView();}public SurfaceViewAnimation(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);initView();}public SurfaceViewAnimation(Context context, AttributeSet attrs) {this(context, attrs, 0);initView();}private void initView() {try {initVariables();setOpaque(false);//设置背景透明,记住这里是[是否不透明]} catch (Exception e) {e.printStackTrace();}}@Overridepublic void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {}@Overridepublic void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {}@Overridepublic boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {try {destroy();} catch (Exception e) {e.printStackTrace();}return false;}@Overridepublic void onSurfaceTextureUpdated(SurfaceTexture surface) {}public void drawIndex(int pos) {mCurrentIndext = pos;drawView();}public void drawPreIndex(int pos) {if (pos < totalCount + 1) {mCurrentIndext = pos - 1;drawView();}}public void drawAfterIndex() {drawView();}/*** 绘制*/private void drawView() {// 无资源文件退出if (mBitmapMaps == null) {mIsThreadRunning = false;return;}if (mOnFrameFinishedListener != null) {mOnFrameFinishedListener.onFramePlaying(mCurrentIndext);}Log.e(TAG, "drawView: mCurrentIndext=" + mCurrentIndext);Log.e(TAG, "drawView: Thread id = " + Thread.currentThread().getId());//防止是获取不到Canvas// 锁定画布mCanvas = lockCanvas();if (mCanvas == null) {return;}try {if (mCanvas != null && mBitmapMaps != null) {synchronized (mBitmapMaps) {if (mBitmapMaps != null && mBitmapMaps.size() > 0 && mCurrentIndext > -1 && mCurrentIndext < mBitmapMaps.size()) {mBitmap = mBitmapMaps.get(mCurrentIndext);}}if (mBitmap == null || mBitmap.isRecycled()) {return;}if (!mBitmap.isRecycled()) {mBitmap.setHasAlpha(true);}Paint paint = new Paint();paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));mCanvas.drawPaint(paint);paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));paint.setAntiAlias(true);paint.setStyle(Paint.Style.STROKE);mSrcRect = new Rect(0, 0, mBitmap.getWidth(), mBitmap.getHeight());mDestRect = new Rect(0, 0, getWidth(), getHeight());mCanvas.drawBitmap(mBitmap, mSrcRect, mDestRect, paint);}} catch (Exception e) {Log.d(TAG, "drawView: e =" + e.toString());e.printStackTrace();} finally {if (mCurrentIndext == totalCount) {mIsThreadRunning = false;if (thread != null) {thread.interrupt();thread = null;}if (mOnFrameFinishedListener != null) {mOnFrameFinishedListener.onFrameEnd();}} else {mCurrentIndext++;if (mCurrentIndext > totalCount) {mCurrentIndext = 0;}}if (mCanvas != null) {// 将画布解锁并显示在屏幕上unlockCanvasAndPost(mCanvas);}}}@Overridepublic void run() {if (mOnFrameFinishedListener != null) {mOnFrameFinishedListener.onFrameStart();}Log.e(TAG, "run: mIsThreadRunning=" + mIsThreadRunning);// 每隔150ms刷新屏幕while (mIsThreadRunning) {drawView();try {Thread.sleep(mGapTime);} catch (Exception e) {e.printStackTrace();}}if (mOnFrameFinishedListener != null) {mOnFrameFinishedListener.onFrameStop();}}/*** 开始动画*/public void start() {if (mCurrentIndext == totalCount) {mIsDestroy = false;}if (!mIsDestroy) {mCurrentIndext = 0;mIsThreadRunning = true;thread = new Thread(this);thread.start();} else {// 如果SurfaceHolder已经销毁抛出该异常try {throw new Exception("IllegalArgumentException:Are you sure the SurfaceHolder is not destroyed");} catch (Exception e) {e.printStackTrace();}}}/*** 防止内存泄漏*/private void destroy() {//当surfaceView销毁时, 停止线程的运行. 避免surfaceView销毁了线程还在运行而报错.mIsThreadRunning = false;try {Thread.sleep(mGapTime);} catch (InterruptedException e) {e.printStackTrace();}mIsDestroy = true;if (thread != null) {thread.interrupt();thread = null;}if (mBitmap != null && !mBitmap.isRecycled()) {mBitmap.recycle();mBitmap = null;}}void destroyListener() {if (mOnFrameFinishedListener != null) {mOnFrameFinishedListener = null;}}public void setBitmapArrays(HashMap<Integer, Bitmap> bitmapArrays) {synchronized (mBitmapMaps) {mBitmapMaps = bitmapArrays;totalCount = mBitmapMaps.size();}}/*** 设置每帧时间*/public void setGapTime(int gapTime) {this.mGapTime = gapTime;}/*** 结束动画*/public void stop() {mIsThreadRunning = false;}/*** 继续动画*/public void reStart() {try {Log.e("reStart", "当前位置: " + mCurrentIndext);mIsThreadRunning = true;thread = new Thread(this);thread.start();} catch (Exception e) {e.printStackTrace();}}public void pause() {mIsThreadRunning = false;}/*** 设置动画监听器*/public void setOnFrameFinisedListener(OnFrameFinishedListener onFrameFinishedListener) {this.mOnFrameFinishedListener = onFrameFinishedListener;}/*** 动画监听器** @author qike*/public interface OnFrameFinishedListener {/*** 动画开始*/void onFrameStart();void onFramePlaying(int framePos);/*** 动画结束*/void onFrameStop();//停止(可能未播放完)void onFrameEnd();//播放完毕}/*** 当用户点击返回按钮时,停止线程,反转内存溢出*/@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {// 当按返回键时,将线程停止,避免surfaceView销毁了,而线程还在运行而报错if (keyCode == KeyEvent.KEYCODE_BACK) {mIsThreadRunning = false;}return super.onKeyDown(keyCode, event);}private SizeCalculator mSizeCalculator = null;@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {if (mSizeCalculator != null) {ViewSize size =mSizeCalculator.measure(widthMeasureSpec, heightMeasureSpec);setMeasuredDimension(size.width, size.height);}}class ViewSize {int width = 0;int height = 0;}class SizeCalculator {private int mVideoWidth = 0;private int mVideoHeight = 0;void setVideoSize(int width, int height) {mVideoWidth = width;mVideoHeight = height;}ViewSize measure(int widthMeasureSpec, int heightMeasureSpec) {int width = View.getDefaultSize(mVideoWidth, widthMeasureSpec);int height = View.getDefaultSize(mVideoHeight, heightMeasureSpec);if (mVideoWidth > 0 && mVideoHeight > 0) {int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);if (widthSpecMode == MeasureSpec.EXACTLY && heightSpecMode == MeasureSpec.EXACTLY) {// the size is fixedwidth = widthSpecSize;height = heightSpecSize;// for compatibility, we adjust size based on aspect ratioif (mVideoWidth * height < width * mVideoHeight) {width = height * mVideoWidth / mVideoHeight;} else if (mVideoWidth * height > width * mVideoHeight) {height = width * mVideoHeight / mVideoWidth;}} else if (widthSpecMode == MeasureSpec.EXACTLY) {// only the width is fixed, adjust the height to match aspect ratio if possiblewidth = widthSpecSize;height = width * mVideoHeight / mVideoWidth;if (heightSpecMode == MeasureSpec.AT_MOST && height > heightSpecSize) {// couldn't match aspect ratio within the constraintsheight = heightSpecSize;}} else if (heightSpecMode == MeasureSpec.EXACTLY) {// only the height is fixed, adjust the width to match aspect ratio if possibleheight = heightSpecSize;width = height * mVideoWidth / mVideoHeight;if (widthSpecMode == MeasureSpec.AT_MOST && width > widthSpecSize) {// couldn't match aspect ratio within the constraintswidth = widthSpecSize;}} else {// neither the width nor the height are fixed, try to use actual video sizewidth = mVideoWidth;height = mVideoHeight;if (heightSpecMode == MeasureSpec.AT_MOST && height > heightSpecSize) {// too tall, decrease both width and heightheight = heightSpecSize;width = height * mVideoWidth / mVideoHeight;}if (widthSpecMode == MeasureSpec.AT_MOST && width > widthSpecSize) {// too wide, decrease both width and heightwidth = widthSpecSize;height = width * mVideoHeight / mVideoWidth;}}}ViewSize size = new ViewSize();size.width = width;size.height = height;return size;}}private void initVariables() {mSizeCalculator = new SizeCalculator();mSizeCalculator.setVideoSize(0, 0);}}

这样,可以基本实现需求。

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

相关文章

  1. 《数学建模算法与应用第二版》——chapter12. 现代优化算法

    1. 模拟退火算法 1.1 算法简介1.2 应用举例clc, clear sj0=load(sj.txt); %加载100个目标的数据,数据按照表格中的位置保存在纯文本文件sj.txt中 x=sj0(:,[1:2:8]);x=x(:); y=sj0(:,[2:2:8]);y=y(:); sj=[x y]; d1=[70,40]; sj=[d1;sj;d1]; sj=sj*pi/180; %角度化成弧度 d…...

    2024/4/15 20:18:44
  2. 运筹学修炼日记:如何写出大规模线性规划的对偶

    运筹学修炼日记:如何写出大规模线性规划的对偶问题运筹学修炼日记:如何写出大规模线性规划的对偶问题最短路问题多商品流问题`Multicommodity Network Flow Problem`借助`Excel`和`具体小算例`写出大规模LP的对偶Dual Problem :Shortest Path Problem(最短路问题)小算例`Exc…...

    2024/4/15 20:18:43
  3. 从AR光学开始,了解AR眼镜

    转自:https://baijiahao.baidu.com/s?id=1656396755348563765&wfr=spider&for=pc本文来自投稿,作者:梁宏恩,HTC VIVE X加速器,HTC VIVE X加速器 资深技术经理Magic Leap作为最早开始被人记住的AR硬件公司,迄今为止的融资总额达到了26亿美元左右,它的股东包括了…...

    2024/4/18 13:31:20
  4. python之数据分析函数及单词汇总积累之字符串常用功能和格式化字符:数字格式化的那些坑

    字符串常用功能 st = “i`m handsome!” st2 = st.replace(‘handsome’,‘ugly’) st = ‘hahaha’ st2 = st.replace(‘ha’,‘he’,2) str.replace(old,new,count):修改字符串,count:更换几个 st = “poi01,116.446238,39.940166” lst = st.split(’,’) str.split(obj)…...

    2024/4/15 20:18:42
  5. inno setup安装制作软件详细使用步骤(含检测net版本环境)

    一、下载inno setup软件(环境设置)官方下载地址:https://jrsoftware.org/isinfo.php我这里有个现成的inno setup下载包,可自提:链接:https://pan.baidu.com/s/1vk_O9TgPGwBszqr5IXTU7w 提取码:xzvwnet4.6.1版本:https://www.microsoft.com/en-us/download/details.aspx?id=…...

    2024/4/15 20:18:40
  6. 定时任务组件Quartz

    定时任务组件Quartz Quartz介绍 Quartz是Job scheduling(作业调度)领域的一个开源项目,Quartz既可以单独使用也可以跟spring框 架整合使用,在实际开发中一般会使用后者。使用Quartz可以开发一个或者多个定时任务,每个定时任 务可以单独指定执行的时间,例如每隔1小时执行一…...

    2024/4/15 20:18:39
  7. #Datawhale_Python基础 Task09:datetime模块

    学习链接 文章目录 datetime是Python中处理日期的标准模块,它提供了4中对日期和时间进行处理的类:datetime date time timedelta 具体定义详见学习链接...

    2024/4/15 20:18:39
  8. I/O框架

    流的概念概念:内存与存储设备之间存储数据的通道。 数据借助流来进行传输IO流 i:input输入(读取)输入:把硬盘中的数据,读取到内存中使用 o:output输出(写入)输出:把内存中的数据,写入到硬盘中保存 流:数据(字符,字节) 1个字符=2个字节 1个字节=8个二进制位字节流…...

    2024/4/15 20:18:37
  9. Linux 工具

    1.vmstat 可以获得有关进程、内存页面交换、虚拟内存、线程上下文切换、等待队列等信息。能够反映系统的负载情况。一般用来查看进程等待数量、内存换页情况、系统上下文切换是否频繁等。 2.iostat 工具可以对系统的磁盘操作活动进行监视,同时也可以显示 CPU 使用情况,一般用…...

    2024/4/15 13:41:05
  10. leetcode_116 Binary Tree Level Order Traversal II

    题目:Given a binary tree, return the bottom-up level order traversal of its nodes values. (ie, from left to right, level by level from leaf to root).For example: Given binary tree [3,9,20,null,null,15,7],3/ \9 20/ \15 7return its bottom-up level order…...

    2024/4/18 0:44:43
  11. 块设备虚拟化

    https://www.cnblogs.com/Bozh/p/5788402.html这个文章介绍了块设备的虚拟化,非常详细,包括文件系统的框架,cache。他的KVM虚拟化的文章目录:https://www.cnblogs.com/Bozh/p/5788431.html...

    2024/4/15 13:41:03
  12. Divisibility(规律)

    题意 对任意的b进制整数y f(y)代表b的所有位之和 命题:能通过判断 f(f(f(…f(y)…)))(无穷多个)是否被x整除 来确定y是否能被x整除 给出不同的b和x,判断命题是否成立 题意很重要,人问的是整个命题的对错,而我一开始认为是判断f(f(f(…f(y)…)))能否被x整除,就化身wrong an…...

    2024/4/19 12:37:25
  13. DOM事件流和冒泡、捕获

    事件流描述的是从页面中接受事件的顺序。事件最早是在IE3和Netscape Navigator2中出现的,在IE4和Navigator4发布时,这两种浏览器都提供了相似但不相同的API。IE的事件流是事件冒泡流,而Netscape的事件流是事件捕获流事件冒泡即事件开始时由最具体的元素接收,然后逐级向上传…...

    2024/4/17 4:39:51
  14. kubebuilder实现k8s operator模式

    背景 在Kubernetes中,希望通过CRD的方式定义业务资源,并通过Watch这些CR Object来做出相应的业务操作,也就是K8S Operator的实现,但是从零开始实现K8S Operator,是一件非常繁杂和困难的事情,好在当前社区提供了丰富的Operator实现框架,最热门的当属kubebuilder。 本文将…...

    2024/4/15 20:18:38
  15. python模块第三方库安装,镜像地址参数,cmd命令安装模块,设置默认的镜像源

    1.python 模块安装常用镜像源 阿里云 https://mirrors.aliyun.com/pypi/simple/ 豆瓣 https://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple/ 2.安装模块命令 如下为简易的cmd下的安…...

    2024/4/15 20:18:34
  16. Spring boot打包项目

    刚学spring boot今天想试一下怎么进行项目打包,新建了一个工程,先是用了IDEA的打包方式,出现了一下问题,都没有解决(尴尬)。No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct. …...

    2024/4/17 4:39:51
  17. Springboot--对于配置的环境管理-ymal多模块化

    profile是Spring对不同环境提供不同配置功能的支持,可以通过激活不同的环境版本,实现快速切换环境; 多配置文件(yaml和properties同理) 我们在主配置文件编写的时候,文件名可以是 application-{profile}.properties/yml , 用来指定多个环境版本; 例如: application.yaml …...

    2024/4/15 20:18:33
  18. map集合对时间排序

    map集合对时间排序List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();Map<String, Object> map = new HashMap<>();//时间也可以是15:31:45map.put("logdate", "2020-08-01 15:31:45");map.…...

    2024/4/15 20:18:31
  19. springcloud @EnableDiscoveryClient注解作用

    https://blog.csdn.net/zheng199172/article/details/82466139...

    2024/4/15 20:18:31
  20. 装饰器、迭代器和生成器的使用方法

    装饰器 定义: 装饰器的本质就是一个实参高阶函数和返回值高阶函数 装饰器是用来给函数添加功能(在不修改原函数的基础上给函数添加功能) 无参装饰器 语法: def 函数1(func):def test(*args,**kwargs):func(*args,**kwargs)添加新的功能return test说明: 函数名1 - 装饰器对…...

    2024/4/15 20:18:30

最新文章

  1. 添加Redis缓存

    1.缓存查询 在service层Impl文件中&#xff0c;进行查询时优先向Redis中查数据&#xff0c;查到就查到了&#xff0c;没有查到向mysql数据库中查&#xff0c;查到之后不先返回&#xff0c;而是先将数据存到数据库&#xff08;缓存&#xff09;,在再返回数据。 1.1 代码实现(缓…...

    2024/4/20 16:40:54
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. 数据挖掘中的PCA和KMeans:Airbnb房源案例研究

    目录 一、PCA简介 二、数据集概览 三、数据预处理步骤 四、PCA申请 五、KMeans 聚类 六、PCA成分分析 七、逆变换 八、质心分析 九、结论 十、深入探究 10.1 第 1 步&#xff1a;确定 PCA 组件的最佳数量 10.2 第 2 步&#xff1a;使用 9 个组件重做 PCA 10.3 解释 PCA 加载和特…...

    2024/4/19 13:01:38
  4. k8s_入门_kubelet安装

    安装 在大致了解了一些k8s的基本概念之后&#xff0c;我们实际部署一个k8s集群&#xff0c;做进一步的了解 1. 裸机安装 采用三台机器&#xff0c;一台机器为Master&#xff08;控制面板组件&#xff09;两台机器为Node&#xff08;工作节点&#xff09; 机器的准备有两种方式…...

    2024/4/18 18:16:56
  5. 416. 分割等和子集问题(动态规划)

    题目 题解 class Solution:def canPartition(self, nums: List[int]) -> bool:# badcaseif not nums:return True# 不能被2整除if sum(nums) % 2 ! 0:return False# 状态定义&#xff1a;dp[i][j]表示当背包容量为j&#xff0c;用前i个物品是否正好可以将背包填满&#xff…...

    2024/4/19 19:02:10
  6. 【Java】ExcelWriter自适应宽度工具类(支持中文)

    工具类 import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet;/*** Excel工具类** author xiaoming* date 2023/11/17 10:40*/ public class ExcelUti…...

    2024/4/20 15:00:23
  7. Spring cloud负载均衡@LoadBalanced LoadBalancerClient

    LoadBalance vs Ribbon 由于Spring cloud2020之后移除了Ribbon&#xff0c;直接使用Spring Cloud LoadBalancer作为客户端负载均衡组件&#xff0c;我们讨论Spring负载均衡以Spring Cloud2020之后版本为主&#xff0c;学习Spring Cloud LoadBalance&#xff0c;暂不讨论Ribbon…...

    2024/4/19 11:33:34
  8. TSINGSEE青犀AI智能分析+视频监控工业园区周界安全防范方案

    一、背景需求分析 在工业产业园、化工园或生产制造园区中&#xff0c;周界防范意义重大&#xff0c;对园区的安全起到重要的作用。常规的安防方式是采用人员巡查&#xff0c;人力投入成本大而且效率低。周界一旦被破坏或入侵&#xff0c;会影响园区人员和资产安全&#xff0c;…...

    2024/4/19 11:52:08
  9. VB.net WebBrowser网页元素抓取分析方法

    在用WebBrowser编程实现网页操作自动化时&#xff0c;常要分析网页Html&#xff0c;例如网页在加载数据时&#xff0c;常会显示“系统处理中&#xff0c;请稍候..”&#xff0c;我们需要在数据加载完成后才能继续下一步操作&#xff0c;如何抓取这个信息的网页html元素变化&…...

    2024/4/20 9:42:32
  10. 【Objective-C】Objective-C汇总

    方法定义 参考&#xff1a;https://www.yiibai.com/objective_c/objective_c_functions.html Objective-C编程语言中方法定义的一般形式如下 - (return_type) method_name:( argumentType1 )argumentName1 joiningArgument2:( argumentType2 )argumentName2 ... joiningArgu…...

    2024/4/20 7:01:14
  11. 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】

    &#x1f468;‍&#x1f4bb;博客主页&#xff1a;花无缺 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! 本文由 花无缺 原创 收录于专栏 【洛谷算法题】 文章目录 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】&#x1f30f;题目描述&#x1f30f;输入格…...

    2024/4/19 11:52:49
  12. 【ES6.0】- 扩展运算符(...)

    【ES6.0】- 扩展运算符... 文章目录 【ES6.0】- 扩展运算符...一、概述二、拷贝数组对象三、合并操作四、参数传递五、数组去重六、字符串转字符数组七、NodeList转数组八、解构变量九、打印日志十、总结 一、概述 **扩展运算符(...)**允许一个表达式在期望多个参数&#xff0…...

    2024/4/19 18:52:15
  13. 摩根看好的前智能硬件头部品牌双11交易数据极度异常!——是模式创新还是饮鸩止渴?

    文 | 螳螂观察 作者 | 李燃 双11狂欢已落下帷幕&#xff0c;各大品牌纷纷晒出优异的成绩单&#xff0c;摩根士丹利投资的智能硬件头部品牌凯迪仕也不例外。然而有爆料称&#xff0c;在自媒体平台发布霸榜各大榜单喜讯的凯迪仕智能锁&#xff0c;多个平台数据都表现出极度异常…...

    2024/4/19 23:08:02
  14. Go语言常用命令详解(二)

    文章目录 前言常用命令go bug示例参数说明 go doc示例参数说明 go env示例 go fix示例 go fmt示例 go generate示例 总结写在最后 前言 接着上一篇继续介绍Go语言的常用命令 常用命令 以下是一些常用的Go命令&#xff0c;这些命令可以帮助您在Go开发中进行编译、测试、运行和…...

    2024/4/20 0:22:23
  15. 用欧拉路径判断图同构推出reverse合法性:1116T4

    http://cplusoj.com/d/senior/p/SS231116D 假设我们要把 a a a 变成 b b b&#xff0c;我们在 a i a_i ai​ 和 a i 1 a_{i1} ai1​ 之间连边&#xff0c; b b b 同理&#xff0c;则 a a a 能变成 b b b 的充要条件是两图 A , B A,B A,B 同构。 必要性显然&#xff0…...

    2024/4/19 23:04:54
  16. 【NGINX--1】基础知识

    1、在 Debian/Ubuntu 上安装 NGINX 在 Debian 或 Ubuntu 机器上安装 NGINX 开源版。 更新已配置源的软件包信息&#xff0c;并安装一些有助于配置官方 NGINX 软件包仓库的软件包&#xff1a; apt-get update apt install -y curl gnupg2 ca-certificates lsb-release debian-…...

    2024/4/20 1:12:38
  17. Hive默认分割符、存储格式与数据压缩

    目录 1、Hive默认分割符2、Hive存储格式3、Hive数据压缩 1、Hive默认分割符 Hive创建表时指定的行受限&#xff08;ROW FORMAT&#xff09;配置标准HQL为&#xff1a; ... ROW FORMAT DELIMITED FIELDS TERMINATED BY \u0001 COLLECTION ITEMS TERMINATED BY , MAP KEYS TERMI…...

    2024/4/19 3:53:57
  18. 【论文阅读】MAG:一种用于航天器遥测数据中有效异常检测的新方法

    文章目录 摘要1 引言2 问题描述3 拟议框架4 所提出方法的细节A.数据预处理B.变量相关分析C.MAG模型D.异常分数 5 实验A.数据集和性能指标B.实验设置与平台C.结果和比较 6 结论 摘要 异常检测是保证航天器稳定性的关键。在航天器运行过程中&#xff0c;传感器和控制器产生大量周…...

    2024/4/19 19:50:16
  19. --max-old-space-size=8192报错

    vue项目运行时&#xff0c;如果经常运行慢&#xff0c;崩溃停止服务&#xff0c;报如下错误 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 因为在 Node 中&#xff0c;通过JavaScript使用内存时只能使用部分内存&#xff08;64位系统&…...

    2024/4/20 1:43:00
  20. 基于深度学习的恶意软件检测

    恶意软件是指恶意软件犯罪者用来感染个人计算机或整个组织的网络的软件。 它利用目标系统漏洞&#xff0c;例如可以被劫持的合法软件&#xff08;例如浏览器或 Web 应用程序插件&#xff09;中的错误。 恶意软件渗透可能会造成灾难性的后果&#xff0c;包括数据被盗、勒索或网…...

    2024/4/20 13:55:02
  21. JS原型对象prototype

    让我简单的为大家介绍一下原型对象prototype吧&#xff01; 使用原型实现方法共享 1.构造函数通过原型分配的函数是所有对象所 共享的。 2.JavaScript 规定&#xff0c;每一个构造函数都有一个 prototype 属性&#xff0c;指向另一个对象&#xff0c;所以我们也称为原型对象…...

    2024/4/19 23:35:17
  22. C++中只能有一个实例的单例类

    C中只能有一个实例的单例类 前面讨论的 President 类很不错&#xff0c;但存在一个缺陷&#xff1a;无法禁止通过实例化多个对象来创建多名总统&#xff1a; President One, Two, Three; 由于复制构造函数是私有的&#xff0c;其中每个对象都是不可复制的&#xff0c;但您的目…...

    2024/4/19 10:00:05
  23. python django 小程序图书借阅源码

    开发工具&#xff1a; PyCharm&#xff0c;mysql5.7&#xff0c;微信开发者工具 技术说明&#xff1a; python django html 小程序 功能介绍&#xff1a; 用户端&#xff1a; 登录注册&#xff08;含授权登录&#xff09; 首页显示搜索图书&#xff0c;轮播图&#xff0…...

    2024/4/20 6:45:17
  24. 电子学会C/C++编程等级考试2022年03月(一级)真题解析

    C/C++等级考试(1~8级)全部真题・点这里 第1题:双精度浮点数的输入输出 输入一个双精度浮点数,保留8位小数,输出这个浮点数。 时间限制:1000 内存限制:65536输入 只有一行,一个双精度浮点数。输出 一行,保留8位小数的浮点数。样例输入 3.1415926535798932样例输出 3.1…...

    2024/4/20 3:28:04
  25. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  26. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  27. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  28. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  29. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  30. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  31. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  32. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  33. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  34. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  35. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  36. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  37. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  38. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  39. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  40. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  41. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  42. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  43. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  44. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57