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內部線程的銷燬。