本文整理汇总了Java中rx.subscriptions.CompositeSubscription类的典型用法代码示例。如果您正苦于以下问题:Java CompositeSubscription类的具体用法?Java CompositeSubscription怎么用?Java CompositeSubscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompositeSubscription类属于rx.subscriptions包,在下文中一共展示了CompositeSubscription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startScroll
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
/**
* 图片开始轮播
*/
private void startScroll()
{
compositeSubscription = new CompositeSubscription();
isStopScroll = false;
Subscription subscription = Observable.timer(delayTime, TimeUnit.SECONDS)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(aLong -> {
if (isStopScroll)
return;
isStopScroll = true;
viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
});
compositeSubscription.add(subscription);
}
示例2: call
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
public Subscriber<? super T> call(Subscriber<? super Observable<T>> child) {
CompositeSubscription csub = new CompositeSubscription();
child.add(csub);
final SourceSubscriber sub = new SourceSubscriber(child, csub);
Subscriber<U> open = new Subscriber<U>() {
public void onStart() {
request(Long.MAX_VALUE);
}
public void onNext(U t) {
sub.beginWindow(t);
}
public void onError(Throwable e) {
sub.onError(e);
}
public void onCompleted() {
sub.onCompleted();
}
};
csub.add(sub);
csub.add(open);
this.windowOpenings.unsafeSubscribe(open);
return sub;
}
示例3: startScroll
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
/**
* 图片开始轮播
*/
private void startScroll() {
compositeSubscription = new CompositeSubscription();
isStopScroll = false;
Subscription subscription = Observable.timer(delayTime, TimeUnit.SECONDS)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(aLong -> {
if (isStopScroll) {
return;
}
isStopScroll = true;
viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
});
compositeSubscription.add(subscription);
}
示例4: disconnect
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
private Subscription disconnect(final CompositeSubscription current) {
return Subscriptions.create(new Action0() {
public void call() {
OnSubscribeRefCount.this.lock.lock();
try {
if (OnSubscribeRefCount.this.baseSubscription == current && OnSubscribeRefCount.this.subscriptionCount.decrementAndGet() == 0) {
OnSubscribeRefCount.this.baseSubscription.unsubscribe();
OnSubscribeRefCount.this.baseSubscription = new CompositeSubscription();
}
OnSubscribeRefCount.this.lock.unlock();
} catch (Throwable th) {
OnSubscribeRefCount.this.lock.unlock();
}
}
});
}
示例5: onCreate
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.logD(LOG_TAG, "onCreate");
mSharedPreferences = new PreferencesManagerImp(getActivity().getApplicationContext());
mLocation = mSharedPreferences.getLocation();
if (savedInstanceState != null) {
mRotation = true;
}
LoaderProvider loaderProvider = new LoaderProvider(getContext());
LoaderManager loaderManager = getLoaderManager();
Geocoder geocoder = new Geocoder(getActivity());
// loaderManager.enableDebugLogging(true);
mPresenter = new FindPresenter(mLocation, loaderManager, loaderProvider, geocoder);
setHasOptionsMenu(true);
mRecentSearchSuggestions = new SearchRecentSuggestions(getContext(),
RecentSuggestionsProvider.AUTHORITY, RecentSuggestionsProvider.MODE);
mCompositeSubscription = new CompositeSubscription();
mActivityCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinator);
mSnackCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinatorSnackContainer);
}
示例6: ResolveInfosPresenter
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
public ResolveInfosPresenter(@NonNull V view,
@NonNull BaseSchedulerProvider schedulerProvider,
@NonNull ActionConfig actionConfig,
@NonNull ResolveInfosRepository resolveInfosRepository) {
if (view == null) {
throw new NullPointerException("view == null");
}
if (schedulerProvider == null) {
throw new NullPointerException("schedulerProvider == null");
}
if (actionConfig == null) {
throw new NullPointerException("actionConfig == null");
}
if (resolveInfosRepository == null) {
throw new NullPointerException("resolveInfosRepository == null");
}
mView = view;
mSubscriptions = new CompositeSubscription();
mSchedulerProvider = schedulerProvider;
mActionConfig = actionConfig;
mResolveInfosRepository = resolveInfosRepository;
mView.setPresenter(this);
}
示例7: CachedWorkerPool
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
CachedWorkerPool(long keepAliveTime, TimeUnit unit) {
this.keepAliveTime = unit != null ? unit.toNanos(keepAliveTime) : 0;
this.expiringWorkerQueue = new ConcurrentLinkedQueue();
this.allWorkers = new CompositeSubscription();
ScheduledExecutorService evictor = null;
Future<?> task = null;
if (unit != null) {
evictor = Executors.newScheduledThreadPool(1, CachedThreadScheduler.EVICTOR_THREAD_FACTORY);
NewThreadWorker.tryEnableCancelPolicy(evictor);
task = evictor.scheduleWithFixedDelay(new Runnable() {
public void run() {
CachedWorkerPool.this.evictExpiredWorkers();
}
}, this.keepAliveTime, this.keepAliveTime, TimeUnit.NANOSECONDS);
}
this.evictorService = evictor;
this.evictorTask = task;
}
示例8: bind
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
private void bind(){
mSubscription = new CompositeSubscription();
mSubscription.add(mViewModel.verifyState()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(verified -> { // Token is provided
if(verified)
redirectToHome();
else
displayWarning(true);
})
);
}
示例9: doSubscribe
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
void doSubscribe(final Subscriber<? super T> subscriber, final CompositeSubscription currentBase) {
subscriber.add(disconnect(currentBase));
this.source.unsafeSubscribe(new Subscriber<T>(subscriber) {
public void onError(Throwable e) {
cleanup();
subscriber.onError(e);
}
public void onNext(T t) {
subscriber.onNext(t);
}
public void onCompleted() {
cleanup();
subscriber.onCompleted();
}
void cleanup() {
OnSubscribeRefCount.this.lock.lock();
try {
if (OnSubscribeRefCount.this.baseSubscription == currentBase) {
OnSubscribeRefCount.this.baseSubscription.unsubscribe();
OnSubscribeRefCount.this.baseSubscription = new CompositeSubscription();
OnSubscribeRefCount.this.subscriptionCount.set(0);
}
OnSubscribeRefCount.this.lock.unlock();
} catch (Throwable th) {
OnSubscribeRefCount.this.lock.unlock();
}
}
});
}
示例10: onCreate
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSubscriptions = new CompositeSubscription();
mStories = new ArrayList<>();
mDataManager = HackerNewsApplication.get(getActivity()).getComponent().dataManager();
Bundle bundle = getArguments();
if (bundle != null) mUser = bundle.getString(ARG_USER, null);
mPostAdapter = new PostAdapter(getActivity(), mUser != null);
}
示例11: onCreate
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comments);
ButterKnife.bind(this);
mPost = getIntent().getParcelableExtra(EXTRA_POST);
if (mPost == null) throw new IllegalArgumentException("CommentsActivity requires a Post object!");
mDataManager = HackerNewsApplication.get(this).getComponent().dataManager();
mSubscriptions = new CompositeSubscription();
mComments = new ArrayList<>();
setupToolbar();
setupRecyclerView();
loadStoriesIfNetworkConnected();
}
示例12: addSubscription
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
/**
* 保存订阅后的subscription
* @param o
* @param subscription
*/
public void addSubscription(Object o, Subscription subscription) {
if (mSubscriptionMap == null) {
mSubscriptionMap = new HashMap<>();
}
String key = o.getClass().getName();
if (mSubscriptionMap.get(key) != null) {
mSubscriptionMap.get(key).add(subscription);
} else {
CompositeSubscription compositeSubscription = new CompositeSubscription();
compositeSubscription.add(subscription);
mSubscriptionMap.put(key, compositeSubscription);
}
}
示例13: CityManagerPresenter
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
@Inject
CityManagerPresenter(Context context, CityManagerContract.View view) {
this.view = view;
this.subscriptions = new CompositeSubscription();
view.setPresenter(this);
DaggerPresenterComponent.builder()
.applicationModule(new ApplicationModule(context))
.build().inject(this);
}
示例14: SelectCityPresenter
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
@Inject
SelectCityPresenter(Context context, SelectCityContract.View view) {
this.cityListView = view;
this.subscriptions = new CompositeSubscription();
cityListView.setPresenter(this);
DaggerPresenterComponent.builder()
.applicationModule(new ApplicationModule(context))
.build().inject(this);
}
示例15: HomePagePresenter
import rx.subscriptions.CompositeSubscription; //导入依赖的package包/类
@Inject
HomePagePresenter(Context context, HomePageContract.View view) {
this.context = context;
this.weatherView = view;
this.subscriptions = new CompositeSubscription();
weatherView.setPresenter(this);
DaggerPresenterComponent.builder()
.applicationModule(new ApplicationModule(context))
.build().inject(this);
}