time to countdown_反应物消耗速率
to Time 消耗 速率 countdown
2023-06-13 09:13:30 时间
前段时间使用CountDownTimer做了一个团购活动的倒计时功能,前期使用的时候没法先什么问题(测试不到位),最近同事发现了一个问题,页面频繁刷新的时候出现秒数显示速率变快的bug。
现象:页面频繁刷新的时候出现秒数显示速率变快。
原因初步分析:刷新时创建了多个CountDownTimer实例,并且多个实例同时在运行。
验证:检查代码发现new CountDownTimer()创建实例是在一个下拉刷新的方法中进行的,每次刷新都会调用这个方法创建一个定时器实例,并且在创建实例之前并没有预先判断实例是否已经创建。
解决:在创建实例之前先判断一下实例是否已经创建,如果已经创建,取消原有实例,并且将原来的CountDownTimer置空。
if(countDownTimer!=null){
countDownTimer.cancel();
countDownTimer=null;
}
countDownTimer=new CountDownTimer(diff,1000) {
@Override
public void onTick(long l) {
mholder.tv_countdown_seconds.setText(StringUtil.valueOf(--sec));
if(sec<0){
sec=59;
mholder.tv_countdown_seconds.setText(StringUtil.valueOf(sec));
mholder.tv_countdown_min.setText(StringUtil.valueOf(--mins));
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/193637.html原文链接:https://javaforall.cn
相关文章
- From Docker to Kubernetes(一)- Image And Container
- MySQL运行SQL文件时(全面,改成time):check the manual that corresponds to your MySQL server version for the righ
- Whoops, GitLab is taking too much time to respond.问题解决
- 解决Unable to connect to Redis server: 192.168.110.1/192.168.110.1:6379[通俗易懂]
- 【翻译】WPF 中附加行为的介绍 Introduction to Attached Behaviors in WPF
- Python librosa.frames_to_time()和librosa.samples_like()的用法
- 【错误记录】Visual Studio 中编译 NDK 报错 ( no matching function for call to ‘cacheflush‘ cacheflush(); )
- vue3报错 ERROR Failed to compile with 1 errorYou may use special comments to disab
- ORA-23420: interval must evaluate to a time in the future ORACLE 报错 故障修复 远程处理
- ORA-24048: cannot create QUEUE_TABLE, user does not have access to AQ object types ORACLE 报错 故障修复 远程处理
- ORA-24851: failed to connect to shared subsystem ORACLE 报错 故障修复 远程处理
- ORA-27049: unable to seek to and read the last block ORACLE 报错 故障修复 远程处理
- ORA-39322: Cannot use transportable tablespace with TIMESTAMP WITH TIME ZONE columns and different time zone version. ORACLE 报错 故障修复 远程处理
- ORA-42304: base table and the Editioning view must belong to the same schema ORACLE 报错 故障修复 远程处理
- ORA-55625: Cannot grant Flashback Archive privilege to a role ORACLE 报错 故障修复 远程处理
- ORA-55710: Unable to alter system parameter GLOBAL_TXN_PROCESSES at this time ORACLE 报错 故障修复 远程处理
- ORA-56939: failed to unload the secondary time zone data file ORACLE 报错 故障修复 远程处理
- ORA-01650: unable to extend rollback segment string by string in tablespace string ORACLE 报错 故障修复 远程处理
- ORA-07205: slgtd: time error, unable to obtain time. ORACLE 报错 故障修复 远程处理
- ORA-09319: slgtd: unable to obtain the current date and time ORACLE 报错 故障修复 远程处理
- ORA-14604: During CREATE TABLE time it is illegal to specify SUBPARTITIONS or STORE IN once a SUBPARTITION TEMPLATE has been specified ORACLE 报错 故障修复 远程处理
- ORA-16259: Switchover to logical standby requires a log archive destination ORACLE 报错 故障修复 远程处理
- ORA-16438: Switchover to primary cannot be executed at this time ORACLE 报错 故障修复 远程处理
- ORA-16439: Standby not ready to receive redo at this time ORACLE 报错 故障修复 远程处理
- ORA-16771: failover to a physical standby database failed ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-013831; Symbol: ER_IB_MSG_TRYING_TO_OPEN_FILE_FOR_LONG_TIME; SQLSTATE: HY000 报错 故障修复 远程处理
- php-fpm开启报错-ERROR: An another FPM instance seems to already listen on /tmp/php-cgi.sock详解编程语言
- ECC TO HANA FAGLB03 search-help on Account Number field doesn’t working or not returning the selected value to the Account Number field.详解编程语言
- doesOracle:The Time to Act is Now!(oraclewhen)
- Unlocking the Power of InMemory Data Storage: A Comprehensive Guide to Think Redis(thinkredis)
- Ultimate Guide to Oracle Time Configuration for Efficient and Reliable Performance(oracle时间设置)
- How to Use MySQL SEQ to Create Custom Sequences for Your Database(mysqlseq)
- MySQL中Time格式解析(mysql中time格式)
- MySQL不支持TIME类型,需使用DATETIME代替(mysql不支持time)
- php中time()与$_SERVER[REQUEST_TIME]用法区别