Skip to content

Commit

Permalink
RxJava 2 修正.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhuo.xd committed Nov 10, 2017
1 parent 0627db2 commit 6d840a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import java.util.concurrent.TimeUnit;

import io.reactivex.Flowable;
import io.reactivex.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

Expand Down Expand Up @@ -59,7 +59,7 @@ protected final int onStart(Intent intent, int flags, int startId) {
}

//使用定时 Observable,避免 Android 定制系统 JobScheduler / AlarmManager 唤醒间隔不稳定的情况
sDisposable = Flowable
sDisposable = Observable
.interval(DaemonEnv.getWakeUpInterval(), TimeUnit.MILLISECONDS)
.subscribe(new Consumer<Long>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public Boolean shouldStopService(Intent intent, int flags, int startId) {
@Override
public void startWork(Intent intent, int flags, int startId) {
System.out.println("检查磁盘中是否有上次销毁时保存的数据");
sDisposable = Flowable
sDisposable = Observable
.interval(3, TimeUnit.SECONDS)
//取消任务时取消定时唤醒
.doOnCancel(() -> {
.doOnDispose(() -> {
System.out.println("保存数据到磁盘。");
cancelJobAlarmSub();
})
Expand Down

0 comments on commit 6d840a2

Please sign in to comment.