The invention relates to a method for generating a segment progress bar. The steps are: setting the total width of the outer frame frame frame of the progress bar, setting the total time of the task, repeating the following processing until the current task time has reached the total time of the task: acquiring the current task time, taking the time as the starting time, starting to execute the task, and taking the current task time as the starting time. Task time as a parameter is passed into the piecewise progress bar generating function to generate this piecewise progress bar, to determine whether the current task time has reached the total time of the task, if it is, the end of the piecewise progress bar generation. The invention does not need the assistance of a timer when generating a progress bar, and generates an animation of the width change of the progress bar within the total time range. The time of the task and the time of the progress bar are the same. The progress bar can calculate the generation, pause and termination of the progress bar according to the information of the start, pause and termination of the task, and there is no timer. The design makes the algorithm less consumption, low complexity, good accuracy, easy to debug and use.
【技术实现步骤摘要】
一种分段进度条的生成方法
本专利技术涉及进度条算法
,具体说是一种分段进度条的生成方法。
技术介绍
如果追溯Progressbar「进度条」的原型,通常被认为起源于HenryGantt所提出的「甘特图」。用图形方式来表示某种项目的活动顺序和持续时间是甘特图的核心思想。进度条即计算机在处理任务时,实时的,以图片等形式显示处理任务的速度,完成度,剩余未完成任务量的大小,和可能需要处理时间,一般以长方形条状显示。通常进度条下限取值为0%,上限取值为100%,现在在等待的界面上给用户显示一个进度条以呈现需要等待的时间已经成为一种习惯,它的作用只有一个,那就是让用户知道某任务并没有失去响应,并告知其完成的时间。作为对常规进度条的优化,提出了分段式进度条。一种分段式进度条是指实现分段显示不同颜色。在0%到100%的区间内,至少有两种不同颜色表示进度的变化,呈现分段效果。另一种分段式进度条是指多节点进度条,其中包括三个以上节点以及相邻节点之间的连线,为凸显个性,或线段颜色和节点图标都是可以自定义的。通常分段式进度条都需要定时器配合以实现进度条效果,即进度条的快慢与时间有关。例如:设定进度条的外框,代表总的任务时长,设定进度条的内框,代表当前进度比例,初始化内框宽度值为0,然后调用绘制函数show()生成进度条,启动一定时器timer(),根据定时器timer()的计时,每间隔一定时间就重复调用绘制函数show(),每次调用绘制函数show()时内框宽度增加一定数值,当内框宽度达到上限则停止定时器计时。这种宽度动画的呈现依赖于定时器,对系统资源有消耗,有进一步优化的 ...
【技术保护点】
1.一种分段进度条的生成方法,其特征在于,包括如下步骤:设置进度条的外框Frame的总宽度,设置任务的总时长,重复以下处理,直到当前任务时间已达到任务的总时长:获取当前任务时间,以该时间为开始时间,开始执行任务,将当前任务时间作为参数传入分段进度条生成函数startWithBeginTime()中,生成本次分段进度条,判断当前任务时间是否已达到任务的总时长,如果达到,结束分段进度条的生成。
【技术特征摘要】
1.一种分段进度条的生成方法,其特征在于,包括如下步骤:设置进度条的外框Frame的总宽度,设置任务的总时长,重复以下处理,直到当前任务时间已达到任务的总时长:获取当前任务时间,以该时间为开始时间,开始执行任务,将当前任务时间作为参数传入分段进度条生成函数startWithBeginTime()中,生成本次分段进度条,判断当前任务时间是否已达到任务的总时长,如果达到,结束分段进度条的生成。2.如权利要求1所述的分段进度条的生成方法,其特征在于:所述任务包括以下任意之一:音频播放,视频播放,音频录制,视频录制,文件传输,数据处理。3.如权利要求1所述的分段进度条的生成方法,其特征在于:所述任务开始时,将当前任务时间作为参数传入分段进度条生成函数startWithBeginTime()中,生成本次分段进度条,所述任务暂停时,停止执行分段进度条生成函数startWithBeginTime(),所述任务结束时,停止执行分段进度条生成函数startWithBeginTime()。4.如权利要求1所述的分段进度条的生成方法,其特征在于:每次执行分段进度条生成函数startWithBeg...
【专利技术属性】
技术研发人员:郭艳杰,
申请(专利权)人:北京酷我科技有限公司,
类型:发明
国别省市:北京,11
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。