Skip to content
Carlyle-Lee edited this page Jul 31, 2020 · 21 revisions

Release Note

English
中文

Quick Access:

dependencies {
    implementation 'com.iqiyi.taskmanager:taskmanager:1.3.7'
}

简单任务提交

        TM.postAsync(Runnable); // To run on background thread
        TM.postAsyncDelay(Runnable, int);
        TM.postSerial(Runnable  , String groupName);// Runnable of same group will run in FIFO order.
        TM.postUI(Runnable); // To run on UI thread.
        TM.postUIDelay(Runnable, int delay);// 

//declair a new task to run on background thread.
 new Task(){

            @Override
            public void doTask() {

            }
        }.postAsync();

流式任务与数据转换(dev: 1.4.0)

流式调用用途: 可以在方法调用返回流式调用对象,从而替代callback 的设计。

 LinkedList<LinkedList<String[]>> linl = new LinkedList<>();
TM.forEach(linl)
                .preCall(value -> Log.d(TAG," L1 "+value))
                .preCall(value -> Log.d(TAG, "L1-1 " + value))
                .afterCall(value -> Log.d(TAG, "ATF L1-1 " + value))
                // 数据转换
                .shiftT(ShiftFactory::create)
                .preCall(value -> Log.d(TAG," L2 "+value))
                .preCall(value -> Log.d(TAG," L2-2 "+value))
                // 数据转换
                .shiftT(ShiftFactory::create)
                .preCall(value -> Log.d(TAG," L3 "+value))
                // 任务执行
                .call(value -> Log.e(TAG," L3 called "+value));
TM.just(1)
                .preCall(value -> Log.d(TAG, "preL1 : just " + value))
                .shiftT(value -> ShiftFactory.create((value +1)+" int to String "))
                .preCall(value -> Log.d(TAG, "preL2 "+ value))
                .preCall(value -> Log.d(TAG,"preL3 " + value))
                .afterCall(value -> Log.d(TAG,"aft L2 "+value))
                .afterCall(value -> Log.d(TAG,"aft L3 " + value))
                .afterCall(value -> Log.d(TAG,"aft L4 " + value))
                .callAsync(value -> Log.e(TAG, "called " + value));

Demo

请参参考Demo 中的相关test 代码。例如 DependantTest、NeedSyncTest 等等。
Please refer to test files in demo for examples such as "DependantTest.java", "NeedSyncTest .java" , etc...

img img img img

API

Clone this wiki locally