use of io.reactivex.annotations.NonNull in project RxJava by ReactiveX.
the class ExecutorScheduler method scheduleDirect.
@NonNull
@Override
public Disposable scheduleDirect(@NonNull Runnable run, final long delay, final TimeUnit unit) {
final Runnable decoratedRun = RxJavaPlugins.onSchedule(run);
if (executor instanceof ScheduledExecutorService) {
try {
Future<?> f = ((ScheduledExecutorService) executor).schedule(decoratedRun, delay, unit);
return Disposables.fromFuture(f);
} catch (RejectedExecutionException ex) {
RxJavaPlugins.onError(ex);
return EmptyDisposable.INSTANCE;
}
}
final DelayedRunnable dr = new DelayedRunnable(decoratedRun);
Disposable delayed = HELPER.scheduleDirect(new DelayedDispose(dr), delay, unit);
dr.timed.replace(delayed);
return dr;
}
use of io.reactivex.annotations.NonNull in project RxJava by ReactiveX.
the class ExecutorScheduler method scheduleDirect.
@NonNull
@Override
public Disposable scheduleDirect(@NonNull Runnable run) {
Runnable decoratedRun = RxJavaPlugins.onSchedule(run);
try {
if (executor instanceof ExecutorService) {
Future<?> f = ((ExecutorService) executor).submit(decoratedRun);
return Disposables.fromFuture(f);
}
BooleanRunnable br = new BooleanRunnable(decoratedRun);
executor.execute(br);
return br;
} catch (RejectedExecutionException ex) {
RxJavaPlugins.onError(ex);
return EmptyDisposable.INSTANCE;
}
}
use of io.reactivex.annotations.NonNull in project RxJava by ReactiveX.
the class Scheduler method schedulePeriodicallyDirect.
/**
* Schedules a periodic execution of the given task with the given initial delay and period.
*
* <p>
* This method is safe to be called from multiple threads but there are no
* ordering guarantees between tasks.
*
* <p>
* The periodic execution is at a fixed rate, that is, the first execution will be after the initial
* delay, the second after initialDelay + period, the third after initialDelay + 2 * period, and so on.
*
* @param run the task to schedule
* @param initialDelay the initial delay amount, non-positive values indicate non-delayed scheduling
* @param period the period at which the task should be re-executed
* @param unit the unit of measure of the delay amount
* @return the Disposable that let's one cancel this particular delayed task.
* @since 2.0
*/
@NonNull
public Disposable schedulePeriodicallyDirect(@NonNull Runnable run, long initialDelay, long period, @NonNull TimeUnit unit) {
final Worker w = createWorker();
final Runnable decoratedRun = RxJavaPlugins.onSchedule(run);
PeriodicDirectTask periodicTask = new PeriodicDirectTask(decoratedRun, w);
Disposable d = w.schedulePeriodically(periodicTask, initialDelay, period, unit);
if (d == EmptyDisposable.INSTANCE) {
return d;
}
return periodicTask;
}
use of io.reactivex.annotations.NonNull in project RxFacebook by YouClap.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
callbackManager = CallbackManager.Factory.create();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
List<String> perm = new ArrayList<>();
perm.add("email");
perm.add("public_profile");
RxFacebookLogin.logInWithReadPermissions(perm).subscribe(new Consumer<LoginResult>() {
@Override
public void accept(@NonNull LoginResult loginResult) throws Exception {
Log.d(LOG_TAG, "accept " + loginResult.getAccessToken());
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
Log.e(LOG_TAG, "error ", throwable);
}
}, new Action() {
@Override
public void run() throws Exception {
Log.e(LOG_TAG, "onCompleted");
}
});
}
});
}
use of io.reactivex.annotations.NonNull in project Varis-Android by dkhmelenko.
the class BuildsDetailsPresenter method startLoadingData.
/**
* Starts loading data
*
* @param intentUrl Intent URL
* @param repoSlug Repository slug
* @param buildId Build ID
*/
public void startLoadingData(String intentUrl, String repoSlug, long buildId) {
mRepoSlug = repoSlug;
mBuildId = buildId;
Single<BuildDetails> buildDetailsSingle;
if (!TextUtils.isEmpty(intentUrl)) {
buildDetailsSingle = mRawClient.singleRequest(intentUrl).doOnSuccess(response -> {
String redirectUrl = intentUrl;
if (response.isRedirect()) {
redirectUrl = response.header("Location", "");
}
parseIntentUrl(redirectUrl);
}).flatMap(new Function<okhttp3.Response, SingleSource<BuildDetails>>() {
@Override
public SingleSource<BuildDetails> apply(@NonNull okhttp3.Response response) throws Exception {
return mTravisRestClient.getApiService().getBuild(mRepoSlug, mBuildId);
}
});
} else {
buildDetailsSingle = mTravisRestClient.getApiService().getBuild(mRepoSlug, mBuildId);
}
Disposable subscription = buildDetailsSingle.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe((buildDetails, throwable) -> {
if (throwable == null) {
handleBuildDetails(buildDetails);
} else {
handleLoadingFailed(throwable);
}
});
mSubscriptions.add(subscription);
getView().showProgress();
}
Aggregations