RSTimer
RSTimer for the implementation of TimerTask, in the course of the implementation can pause, continue, accelerate, slow down, restart and other operations.
1、构建RSTimer
setTitle()
设置RSTimer的名称
setTimerType()
设置RSTimer的类型,根据TimerType进行对应,LIST_TIMER对应于List,ARRAY_TIMER对应于集合,COUNT_TIMER对应于计数。
setOrder()
设置执行的顺序,Order.INCREMENT代表递增,Order.DECREMENT代表递减。
setStartIndex(),setEndIndex()
设置开始、结束下标。开始下标默认为零,如果是递减或不是从零开始执行需要设置。
setOperation()
设置操作的回调
setResponseListener()
设置返回信息监听接口
createTimer()
用于创建具体的RSTimer对象
2、Operation
mTimer.start(1000)
开始执行任务,参数为执行任务的间隔时间,单位ms
pause()、keepOn()、accelerate()、decelerate()、rePlay()、cancel()分别为暂停、继续、加速、减速、重新开始、取消
3、回调处理
在operation()进行回调的处理,index为当前执行的次数,isFinished表示是否执行完成。
注意:在执行完成需要调用operationComplete()方法,用于对RSTimer内部线程的销毁。