當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。