当前位置: 首页>>代码示例>>Java>>正文


Java Action0类代码示例

本文整理汇总了Java中rx.functions.Action0的典型用法代码示例。如果您正苦于以下问题:Java Action0类的具体用法?Java Action0怎么用?Java Action0使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Action0类属于rx.functions包,在下文中一共展示了Action0类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import rx.functions.Action0; //导入依赖的package包/类
void init() {
    this.child.add(Subscriptions.create(new Action0() {
        public void call() {
            if (InexactSubscriber.this.noWindow) {
                InexactSubscriber.this.unsubscribe();
            }
        }
    }));
    this.child.setProducer(new Producer() {
        public void request(long n) {
            if (n > 0) {
                long u = n * ((long) OperatorWindowWithSize.this.size);
                if (!((u >>> 31) == 0 || u / n == ((long) OperatorWindowWithSize.this.size))) {
                    u = Long.MAX_VALUE;
                }
                InexactSubscriber.this.requestMore(u);
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:OperatorWindowWithSize.java

示例2: call

import rx.functions.Action0; //导入依赖的package包/类
public void call(Subscriber<? super T> subscriber) {
    subscriber.add(Subscriptions.create(new Action0() {
        public void call() {
            ToObservableFuture.this.that.cancel(true);
        }
    }));
    try {
        if (!subscriber.isUnsubscribed()) {
            subscriber.onNext(this.unit == null ? this.that.get() : this.that.get(this.time, this.unit));
            subscriber.onCompleted();
        }
    } catch (Throwable e) {
        if (!subscriber.isUnsubscribed()) {
            Exceptions.throwOrReport(e, subscriber);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:OnSubscribeToObservableFuture.java

示例3: applySchedulers

import rx.functions.Action0; //导入依赖的package包/类
public static <T> Observable.Transformer<T, T> applySchedulers(final BaseView view) {
    return new Observable.Transformer<T, T>() {
        @Override
        public Observable<T> call(Observable<T> observable) {
            return observable.subscribeOn(Schedulers.io())
                    .doOnSubscribe(new Action0() {
                        @Override
                        public void call() {//显示进度条
                            view.showLoading();
                        }
                    })
                    .subscribeOn(AndroidSchedulers.mainThread())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doAfterTerminate(new Action0() {
                        @Override
                        public void call() {
                            view.hideLoading();//隐藏进度条
                        }
                    }).compose(RxUtils.<T>bindToLifecycle(view));
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RxUtils.java

示例4: call

import rx.functions.Action0; //导入依赖的package包/类
@Override
public void call(final Subscriber<? super T> subscriber) {
    result.setResultCallback(new ResultCallback<T>() {
        @Override
        public void onResult(T t) {
            subscriber.onNext(t);
            complete = true;
            subscriber.onCompleted();
        }
    });
    subscriber.add(Subscriptions.create(new Action0() {
        @Override
        public void call() {
            if (!complete) {
                result.cancel();
            }
        }
    }));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:PendingResultObservable.java

示例5: call

import rx.functions.Action0; //导入依赖的package包/类
public void call(final Subscriber<? super Long> child) {
    final Worker worker = this.scheduler.createWorker();
    child.add(worker);
    worker.schedulePeriodically(new Action0() {
        long counter;

        public void call() {
            try {
                Subscriber subscriber = child;
                long j = this.counter;
                this.counter = 1 + j;
                subscriber.onNext(Long.valueOf(j));
            } catch (Throwable e) {
                worker.unsubscribe();
            } finally {
                Exceptions.throwOrReport(e, child);
            }
        }
    }, this.initialDelay, this.period, this.unit);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:OnSubscribeTimerPeriodically.java

示例6: TracingActionSubscriber

import rx.functions.Action0; //导入依赖的package包/类
public TracingActionSubscriber(Action1<? super T> onNext, Action1<Throwable> onError,
    Action0 onCompleted, String operationName, Tracer tracer) {
  super(operationName, tracer);

  if (onNext == null) {
    throw new IllegalArgumentException("onNext can not be null");
  }
  if (onError == null) {
    throw new IllegalArgumentException("onError can not be null");
  }
  if (onCompleted == null) {
    throw new IllegalArgumentException("onComplete can not be null");
  }

  this.onNext = onNext;
  this.onError = onError;
  this.onCompleted = onCompleted;
}
 
开发者ID:opentracing-contrib,项目名称:java-rxjava,代码行数:19,代码来源:TracingActionSubscriber.java

示例7: create

import rx.functions.Action0; //导入依赖的package包/类
public static final <T> Observer<T> create(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onComplete) {
    if (onNext == null) {
        throw new IllegalArgumentException("onNext can not be null");
    } else if (onError == null) {
        throw new IllegalArgumentException("onError can not be null");
    } else if (onComplete != null) {
        return new Observer<T>() {
            public final void onCompleted() {
                onComplete.call();
            }

            public final void onError(Throwable e) {
                onError.call(e);
            }

            public final void onNext(T args) {
                onNext.call(args);
            }
        };
    } else {
        throw new IllegalArgumentException("onComplete can not be null");
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:Observers.java

示例8: runCode

import rx.functions.Action0; //导入依赖的package包/类
public void runCode() {

//        DoOnTerminate会在Observable结束前触发回调,无论是正常还是异常终止;
        Observable.range(0,4).doOnTerminate(new Action0() {
            @Override
            public void call() {
                println("------>doOnTerminate()");
            }
        }).subscribe(new Observer<Integer>() {
            @Override
            public void onCompleted() {
                println("------>onCompleted()");
            }

            @Override
            public void onError(Throwable e) {
                println("------>onError()" + e);
            }

            @Override
            public void onNext(Integer integer) {
                println("------->onNext()");
            }
        });
        
    }
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:27,代码来源:Fragment_DoOnTerminate.java

示例9: runCode

import rx.functions.Action0; //导入依赖的package包/类
public void runCode() {

//        doOnUnSubscribe则会在Subscriber进行反订阅的时候触发回调。
//        当一个Observable通过OnError或者OnCompleted结束的时候,会反订阅所有的Subscriber。

        Observable observable = Observable.just(1, 2).doOnUnsubscribe(new Action0() {
            @Override
            public void call() {
                println("I'm be unSubscribed!");
            }
        });
        Subscription subscribe1 = observable.subscribe();
        Subscription subscribe2 = observable.subscribe();
        subscribe1.unsubscribe();
        subscribe2.unsubscribe();

    }
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:18,代码来源:Fragment_DoOnUnSubscribe.java

示例10: requestTopMovie

import rx.functions.Action0; //导入依赖的package包/类
@Override
public Subscription requestTopMovie(int start, final RequestCallBack callBack) {
    return RetrofitHttpClient.getMovieTop250(start)
            .doOnSubscribe(new Action0() {
                @Override
                public void call() {
                    callBack.beforeRequest();
                }
            }).subscribe(new Observer<List<MovieItemBean>>() {
                @Override
                public void onCompleted() {
                    callBack.requestComplete();
                }

                @Override
                public void onError(Throwable e) {
                    Logger.e(e.getLocalizedMessage());
                    callBack.requestError(e.getLocalizedMessage() + "\n" + e);
                }

                @Override
                public void onNext(List<MovieItemBean> data) {
                    callBack.requestSuccess(data);
                }
            });
}
 
开发者ID:lai233333,项目名称:MyDemo,代码行数:27,代码来源:MovieModel.java

示例11: schedule

import rx.functions.Action0; //导入依赖的package包/类
public Subscription schedule(Action0 action) {
    if (isUnsubscribed()) {
        return Subscriptions.unsubscribed();
    }
    Subscription ea = new ScheduledAction(action, this.tasks);
    this.tasks.add(ea);
    this.queue.offer(ea);
    if (this.wip.getAndIncrement() != 0) {
        return ea;
    }
    try {
        this.executor.execute(this);
        return ea;
    } catch (RejectedExecutionException t) {
        this.tasks.remove(ea);
        this.wip.decrementAndGet();
        RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
        throw t;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:ExecutorScheduler.java

示例12: requestMovieReviews

import rx.functions.Action0; //导入依赖的package包/类
@Override
public Subscription requestMovieReviews(String id, int start, final RequestCallBack callBack) {
    return RetrofitHttpClient.getMovieReviews(id,start)
            .doOnSubscribe(new Action0() {
                @Override
                public void call() {
                    callBack.beforeRequest();
                }
            }).subscribe(new Observer<MovieReviewBean>() {
                @Override
                public void onCompleted() {
                    callBack.requestComplete();
                }

                @Override
                public void onError(Throwable e) {
                    Logger.e(e.getLocalizedMessage());
                    callBack.requestError(e.getLocalizedMessage() + "\n" + e);
                }

                @Override
                public void onNext(MovieReviewBean data) {
                    callBack.requestSuccess(data);
                }
            });
}
 
开发者ID:lai233333,项目名称:MyDemo,代码行数:27,代码来源:MovieModel.java

示例13: asyncTask

import rx.functions.Action0; //导入依赖的package包/类
/**
 * Start an async task which can do things beforehand, in background and callback when the job is done on the main thread, and handle the exception with the given action.
 *
 * @param preExecute     action to do beforehand.
 * @param doInBackground action to do in the background.
 * @param doOnFinish     action to do when the job is done.(this is called on main thread)
 * @param onError        action to do when exceptions are thrown.
 * @return the subscription of the task.
 */
public static Subscription asyncTask(final Action0 preExecute, @NonNull final Action0 doInBackground, final Action0 doOnFinish, Action1<Throwable> onError) {
    return Observable.just("Hey nerd! This is an async task.")
            .subscribeOn(Schedulers.io())
            .doOnSubscribe(new Action0() {
                @Override
                public void call() {
                    if (preExecute != null) preExecute.call();
                }
            })
            .observeOn(Schedulers.io())
            .doOnNext(Actions.toAction1(doInBackground))
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<String>() {
                @Override
                public void call(String s) {
                    if (doOnFinish != null) doOnFinish.call();
                }
            }, onError == null ? RxActions.onError() : onError);
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:29,代码来源:RxTask.java

示例14: canUpdateZoneWithExplicitETag

import rx.functions.Action0; //导入依赖的package包/类
@Test
public void canUpdateZoneWithExplicitETag() throws Exception {
    final Region region = Region.US_EAST;
    final String topLevelDomain = "www.contoso" + generateRandomResourceName("z", 10) + ".com";

    final DnsZone dnsZone = zoneManager.zones().define(topLevelDomain)
            .withNewResourceGroup(RG_NAME, region)
            .withETagCheck()
            .create();
    Assert.assertNotNull(dnsZone.eTag());
    Action0 action = new Action0() {
        @Override
        public void call() {
            dnsZone.update()
                    .withETagCheck(dnsZone.eTag() + "-foo")
                    .apply();
        }
    };
    ensureETagExceptionIsThrown(action);
    dnsZone.update()
            .withETagCheck(dnsZone.eTag())
            .apply();
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:24,代码来源:DnsZoneRecordSetETagTests.java

示例15: asyncMap

import rx.functions.Action0; //导入依赖的package包/类
/**
 * Start an async task which can do things beforehand, map things in background and callback when the mapping job is done on the main thread, and handle the exception with the given action.
 *
 * @param preExecute action to do beforehand.
 * @param mapper     action to do the mapping job.
 * @param doOnFinish action to do when the job is done.(this is called on main thread)
 * @param onError    action to do when exceptions are thrown.
 * @return the subscription of the whole mapping job.
 */
public static <T> Subscription asyncMap(final Action0 preExecute, @NonNull final Func1<String, T> mapper, final Action1<T> doOnFinish, Action1<Throwable> onError) {
    return Observable.just("Hey nerd! This is an async map.")
            .subscribeOn(Schedulers.io())
            .observeOn(Schedulers.io())
            .doOnSubscribe(new Action0() {
                @Override
                public void call() {
                    if (preExecute != null) preExecute.call();
                }
            })
            .map(mapper)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<T>() {
                @Override
                public void call(T t) {
                    if (doOnFinish != null) doOnFinish.call(t);
                }
            }, onError == null ? RxActions.onError() : onError);
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:29,代码来源:RxTask.java


注:本文中的rx.functions.Action0类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。