1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//RxJava
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation 'io.reactivex.rxjava3:rxjava:3.0.7'
 
Disposable backgroundTask;
 
backgroundTask = Observable.fromCallable(() -> {
    //background process
    
    return httpList;
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<ArrayList<String>>() {
    @Override
    public void accept(ArrayList<String> strings) throws Throwable {
 
        backgroundTask.dispose();
    }
});
cs

+ Recent posts