android queue用法,GitHub - rygz146/TQueue: Android 可以任意切换线程的任务队列, TQueue
TQueue
一個Android開發庫, 可以任意切換線程的鏈式調用任務隊列, 可添加定時, 延時任務, 統一異常處理(Ceased中斷),但不影響整個任務鏈的運行.
具體用法如下:
TQueue.queue("TQueue").on(new Doable() {
@Override
public void doing(TQueue queue, Bundle args) {
//on操作可以開啟一個及時異步任務
//當執行完成該任務后會自動執行下一個任務
//如果出現異常,在會調go操作中的Ceased(中斷)的doing方法
}
}).rest(1000)//在此休息片刻
.onUI(new Doable() {
@Override
public void doing(TQueue queue, Bundle args) {
//onUI操作可以開啟一個在主線程中執行的任務
}
}).onUIDelayed(long delayedTime, new Doable() {
@Override
public void doing(TQueue queue, Bundle args) {
//delayedTime: 延時時間
//開啟一個在ui線程中的延時任務
//延時任務和定時任務的調度依賴Hander處理
}
}).onDelayed(long delayedTime, new Doable() {
@Override
public void doing(TQueue queue, Bundle args) {
//開啟一個工作線程的延時任務
}
}).onUIAtTime(long atTime, new Doable() {
@Override
public void doing(TQueue queue, final Bundle args) {
//開啟一個UI線程的定時任務
}
}).onAtTime(long atTime, new Doable() {
@Override
public void doing(TQueue queue, final Bundle args) {
//開啟一個工作線程的定時任務
}
}).go(new Ceased() {
@Override
public void doing(Throwable error, Bundle args) {
//上面任務中出現的異常都在此處理
/**說明:
* 1.整個TQueue只有一個Ceased;
* 2.所有的Ceased都會發送到在主線程處理;
* 3.每個任務在執行中的Exception都會在此接口處理;
* 4.對Ceased處理完后會直接進行下一個任務,異常拋出不影響整個隊列任務的進行.
*/
}
});
MIT License
The MIT License (MIT)
Copyright (c) 2016 Sungcheol Kim, https://github.com/rygz146/TQueue
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
總結
以上是生活随笔為你收集整理的android queue用法,GitHub - rygz146/TQueue: Android 可以任意切换线程的任务队列, TQueue的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 闻泰科技:已布局第三代化合物半导体,暂无
- 下一篇: html语言右对齐,在HTML中右对齐块