use of io.reactivex.functions.Action in project MVPArms by JessYanCoding.
the class GlideImageLoaderStrategy method clear.
@Override
public void clear(@Nullable final Context ctx, @Nullable ImageConfigImpl config) {
Preconditions.checkNotNull(ctx, "Context is required");
Preconditions.checkNotNull(config, "ImageConfigImpl is required");
if (config.getImageView() != null) {
GlideArms.get(ctx).getRequestManagerRetriever().get(ctx).clear(config.getImageView());
}
if (config.getImageViews() != null && config.getImageViews().length > 0) {
// 取消在执行的任务并且释放资源
for (ImageView imageView : config.getImageViews()) {
GlideArms.get(ctx).getRequestManagerRetriever().get(ctx).clear(imageView);
}
}
if (config.isClearDiskCache()) {
// 清除本地缓存
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
Glide.get(ctx).clearDiskCache();
}
}).subscribeOn(Schedulers.io()).subscribe();
}
if (config.isClearMemory()) {
// 清除内存缓存
Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
Glide.get(ctx).clearMemory();
}
}).subscribeOn(AndroidSchedulers.mainThread()).subscribe();
}
}
use of io.reactivex.functions.Action in project Conductor by bluelinelabs.
the class AutodisposeController method onAttach.
@Override
protected void onAttach(@NonNull View view) {
super.onAttach(view);
Log.i(TAG, "onAttach() called");
(((ActionBarProvider) getActivity()).getSupportActionBar()).setTitle("Autodispose Demo");
Observable.interval(1, TimeUnit.SECONDS).doOnDispose(new Action() {
@Override
public void run() {
Log.i(TAG, "Disposing from onAttach()");
}
}).to(new ObservableScoper<Long>(scopeProvider)).subscribe(new Consumer<Long>() {
@Override
public void accept(Long num) {
Log.i(TAG, "Started in onAttach(), running until onDetach(): " + num);
}
});
}
use of io.reactivex.functions.Action in project NewPipe by TeamNewPipe.
the class ChannelFragment method updateSubscription.
private void updateSubscription(final ChannelInfo info) {
if (DEBUG)
Log.d(TAG, "updateSubscription() called with: info = [" + info + "]");
final Action onComplete = new Action() {
@Override
public void run() throws Exception {
if (DEBUG)
Log.d(TAG, "Updated subscription: " + info.getUrl());
}
};
final Consumer<Throwable> onError = new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
onUnrecoverableError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(info.getServiceId()), "Updating Subscription for " + info.getUrl(), R.string.subscription_update_failed);
}
};
disposables.add(subscriptionService.updateChannelInfo(info).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(onComplete, onError));
}
use of io.reactivex.functions.Action in project requery by requery.
the class ReactiveTest method testQueryEmpty.
@Test
public void testQueryEmpty() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
data.select(Person.class).get().observable().subscribe(new Consumer<Person>() {
@Override
public void accept(Person person) throws Exception {
Assert.fail();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Assert.fail();
}
}, new Action() {
@Override
public void run() throws Exception {
latch.countDown();
}
});
if (!latch.await(1, TimeUnit.SECONDS)) {
Assert.fail();
}
}
use of io.reactivex.functions.Action in project Android-ReactiveLocation by mcharmas.
the class BaseObservableOnSubscribe method subscribe.
@Override
public void subscribe(ObservableEmitter<T> emitter) throws Exception {
final GoogleApiClient apiClient = createApiClient(emitter);
try {
apiClient.connect();
} catch (Throwable ex) {
if (!emitter.isDisposed()) {
emitter.onError(ex);
}
}
emitter.setDisposable(Disposables.fromAction(new Action() {
@Override
public void run() throws Exception {
onDisposed(apiClient);
apiClient.disconnect();
}
}));
}
Aggregations