net / com.drake.net.time / Interval
Interval¶
class Interval :Serializable
轮循器
操作
- 开启: 只有在闲置状态下才可以开始
- 停止
- 暂停
- 继续
- 重置: 重置不会导致轮循器停止
- 开关: 开启|暂停切换
- 生命周期
回调: 允许多次订阅同一个轮循器
- 每个事件
- 停止或者结束
Parameters¶
end - 结束值
period - 事件间隔
unit - 事件单位
initialDelay - 第一次事件的间隔时间
start - 开始值, 当start]比end值大, 且end不等于-1时, 即为倒计时
Constructors¶
| Name | Summary |
|---|---|
| <init> | Interval(period:Long, unit:TimeUnit, initialDelay:Long= 0)轮循器 Interval(end:Long, period:Long, unit:TimeUnit, start:Long= 0, initialDelay:Long= 0) |
Properties¶
| Name | Summary |
|---|---|
| count | 轮循器的计数var count:Long |
| end | 结束值var end:Long |
| state | 轮循器当前状态var state:IntervalStatus |
Functions¶
| Name | Summary |
|---|---|
| finish | 轮循器完成fun finish(block: (Long) ->Unit):Interval |
| life | 绑定生命周期, 在指定生命周期发生时取消轮循器fun life(lifecycleOwner: LifecycleOwner, lifeEvent: Event = Lifecycle.Event.ON_STOP):Interval |
| pause | 暂停fun pause():Unit |
| reset | 重置fun reset():Unit |
| resume | 继续fun resume():Unit |
| start | 开始fun start():Unit |
| stop | 停止fun stop():Unit |
| subscribe | 订阅轮循器fun subscribe(block: (Long) ->Unit):Interval |
| switch | 开关fun switch():Unit |