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


Java Subscriptions.create方法代码示例

本文整理汇总了Java中rx.subscriptions.Subscriptions.create方法的典型用法代码示例。如果您正苦于以下问题:Java Subscriptions.create方法的具体用法?Java Subscriptions.create怎么用?Java Subscriptions.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rx.subscriptions.Subscriptions的用法示例。


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

示例1: enqueue

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
private Subscription enqueue(Action0 action, long execTime) {
    if (this.innerSubscription.isUnsubscribed()) {
        return Subscriptions.unsubscribed();
    }
    final TimedAction timedAction = new TimedAction(action, Long.valueOf(execTime), this.counter.incrementAndGet());
    this.queue.add(timedAction);
    if (this.wip.getAndIncrement() != 0) {
        return Subscriptions.create(new Action0() {
            public void call() {
                InnerCurrentThreadScheduler.this.queue.remove(timedAction);
            }
        });
    }
    do {
        TimedAction polled = (TimedAction) this.queue.poll();
        if (polled != null) {
            polled.action.call();
        }
    } while (this.wip.decrementAndGet() > 0);
    return Subscriptions.unsubscribed();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:TrampolineScheduler.java

示例2: disconnect

import rx.subscriptions.Subscriptions; //导入方法依赖的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();
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:OnSubscribeRefCount.java

示例3: call

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super Intent> subscriber)
{
    final BroadcastReceiver broadcastReceiver = new BroadcastReceiver()
    {
        @Override
        public void onReceive(Context context, Intent intent)
        {
            subscriber.onNext(intent);
        }
    };

    final Subscription subscription = Subscriptions.create(new Action0()
    {
        @Override
        public void call()
        {
            mContext.unregisterReceiver(broadcastReceiver);
        }
    });

    subscriber.add(subscription);
    mContext.registerReceiver(broadcastReceiver, mIntentFilter, mBroadcastPermission, mSchedulerHandler);
}
 
开发者ID:andrefio,项目名称:Rx.ContentObservable,代码行数:25,代码来源:OnSubscribeBroadcastRegister.java

示例4: call

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super Intent> subscriber)
{
    final LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(mContext);
    final BroadcastReceiver broadcastReceiver = new BroadcastReceiver()
    {
        @Override
        public void onReceive(Context context, Intent intent)
        {
            subscriber.onNext(intent);
        }
    };

    final Subscription subscription = Subscriptions.create(new Action0()
    {
        @Override
        public void call()
        {
            localBroadcastManager.unregisterReceiver(broadcastReceiver);
        }
    });

    subscriber.add(subscription);
    localBroadcastManager.registerReceiver(broadcastReceiver, mIntentFilter);
}
 
开发者ID:andrefio,项目名称:Rx.ContentObservable,代码行数:26,代码来源:OnSubscribeLocalBroadcastRegister.java

示例5: call

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super Intent> subscriber) {
    final BroadcastReceiver broadCastReceiver=new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            subscriber.onNext(intent);
        }
    };
    final Subscription subscription= Subscriptions.create(new Action0() {
        @Override
        public void call() {
            context.unregisterReceiver(broadCastReceiver);

        }
    });
    subscriber.add(subscription);
    context.registerReceiver(broadCastReceiver, intentFilter, permission, schedulerHandler);
}
 
开发者ID:iamprashant,项目名称:rx-network-listener,代码行数:19,代码来源:RxNetworkReceiver.java

示例6: unsubscribeInUiThread

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
private Subscription unsubscribeInUiThread(final Action0 unsubscribe) {
    return Subscriptions.create(new Action0() {

        @Override public void call() {
            if (Looper.getMainLooper() == Looper.myLooper()) {
                unsubscribe.call();
            } else {
                final Scheduler.Worker inner = AndroidSchedulers.mainThread().createWorker();
                inner.schedule(new Action0() {
                    @Override public void call() {
                        unsubscribe.call();
                        inner.unsubscribe();
                    }
                });
            }
        }
    });
}
 
开发者ID:laanayabdrzak,项目名称:RxConnectivityState,代码行数:19,代码来源:RxConnectivityState.java

示例7: call

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override public void call(final Subscriber<? super Intent> subscriber) {
  final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
    @Override public void onReceive(Context context, Intent intent) {
      if (!subscriber.isUnsubscribed()) {
        subscriber.onNext(intent);
      }
    }
  };

  final Subscription subscription = Subscriptions.create(new Action0() {
    @Override public void call() {
      context.unregisterReceiver(broadcastReceiver);
    }
  });

  subscriber.add(subscription);
  context.registerReceiver(broadcastReceiver, intentFilter, broadcastPermission,
      schedulerHandler);
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:20,代码来源:BroadcastRegisterOnSubscribe.java

示例8: call

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super Intent> subscriber) {
    final BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            subscriber.onNext(intent);
        }
    };

    final Subscription subscription = Subscriptions.create(new Action0() {
        @Override
        public void call() {
            context.unregisterReceiver(receiver);
        }
    });
    subscriber.add(subscription);

    context.registerReceiver(receiver, intent);
}
 
开发者ID:hello,项目名称:android-buruberi,代码行数:20,代码来源:Rx.java

示例9: unsubscribeInUiThread

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
private Subscription unsubscribeInUiThread(final Action0 unsubscribe) {
    return Subscriptions.create(new Action0() {

        @Override
        public void call() {
            if (Looper.getMainLooper() == Looper.myLooper()) {
                unsubscribe.call();
            } else {
                final Scheduler.Worker inner = AndroidSchedulers.mainThread().createWorker();
                inner.schedule(new Action0() {
                    @Override
                    public void call() {
                        unsubscribe.call();
                        inner.unsubscribe();
                    }
                });
            }
        }
    });
}
 
开发者ID:Piasy,项目名称:HandyWidgets,代码行数:21,代码来源:CenterTitleSideButtonBar.java

示例10: call

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super Intent> subscriber) {
    final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            subscriber.onNext(intent);
        }
    };

    final Subscription subscription = Subscriptions.create(new Action0() {
        @Override
        public void call() {
            context.unregisterReceiver(broadcastReceiver);
        }
    });

    subscriber.add(subscription);
    context.registerReceiver(broadcastReceiver, intentFilter, broadcastPermission, schedulerHandler);

}
 
开发者ID:Laimiux,项目名称:rxnetwork-android,代码行数:21,代码来源:OnSubscribeBroadcastRegister.java

示例11: unsubscribeInUiThread

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
private static Subscription unsubscribeInUiThread(final Action0 unsubscribe) {
    return Subscriptions.create(new Action0() {
        @Override public void call() {
            if (Looper.getMainLooper() == Looper.myLooper()) {
                unsubscribe.call();
            } else {
                final Scheduler.Worker inner = AndroidSchedulers.mainThread().createWorker();
                inner.schedule(new Action0() {
                    @Override public void call() {
                        unsubscribe.call();
                        inner.unsubscribe();
                    }
                });
            }
        }
    });
}
 
开发者ID:hanks-zyh,项目名称:RxSerach,代码行数:18,代码来源:BroadcastObservable.java

示例12: performTestUsingWithObservableFactoryError

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
private void performTestUsingWithObservableFactoryError(boolean disposeEagerly) {
    final Action0 unsubscribe = mock(Action0.class);
    Supplier<Subscription> resourceFactory = new Supplier<Subscription>() {
        @Override
        public Subscription call() {
            return Subscriptions.create(unsubscribe);
        }
    };

    Function<Subscription, Observable<Integer>> observableFactory = new Function<Subscription, Observable<Integer>>() {
        @Override
        public Observable<Integer> call(Subscription subscription) {
            throw new TestException();
        }
    };

    try {
        Observable.using(resourceFactory, observableFactory, disposeSubscription).toBlocking()
                .last();
        fail("Should throw a TestException when the observableFactory throws it");
    } catch (TestException e) {
        // Make sure that unsubscribe is called so that users can close
        // the resource if some error happens.
        verify(unsubscribe, times(1)).call();
    }
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:27,代码来源:OnSubscribeUsingTest.java

示例13: unsubscribeOnMainThread

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
public static Subscription unsubscribeOnMainThread(final Action0 unsubscribe) {
    return Subscriptions.create(new Action0() {
        @Override
        public void call() {
            if (Looper.getMainLooper() == Looper.myLooper()) {
                unsubscribe.call();
            } else {
                Handler handler = new Handler(Looper.getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        unsubscribe.call();
                    }
                });
            }
        }
    });
}
 
开发者ID:yatatsu,项目名称:PowerWebView,代码行数:19,代码来源:MainThreadSubscription.java

示例14: schedule

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public <T> Subscription schedule(T state, final Func2<? super Scheduler, ? super T, ? extends Subscription> action, final CronExpression cronExpression, final Calendar calendar)
{
    final AtomicBoolean complete = new AtomicBoolean();
    Date initialfireTime = findNextExecutionTime(new Date(now()), cronExpression, calendar);
    RecursiveAction<T> recursiveAction = new RecursiveAction<T>(complete, action, cronExpression, calendar, initialfireTime);
    final Subscription sub;
    if (initialfireTime == null)
    {
        sub = Subscriptions.empty();
    }
    else
    {
        sub = schedule(state, recursiveAction, initialfireTime);
    }
    return Subscriptions.create(new Action0()
    {
        @Override
        public void call()
        {
            complete.set(true);
            sub.unsubscribe();
        }
    });
}
 
开发者ID:svarcheg,项目名称:rx-cron-scheduler,代码行数:26,代码来源:RxCronForwardingScheduler.java

示例15: onSubscribe

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription onSubscribe(final Observer<? super Long> observer)
{
    final Subscription wrapped = scheduler.schedule(new Action0()
    {
        @Override
        public void call()
        {
            observer.onNext(currentValue);
            currentValue++;
        }
    }, cronExpression, calendar);

    return Subscriptions.create(new Action0()
    {
        @Override
        public void call()
        {
            wrapped.unsubscribe();
        }
    });
}
 
开发者ID:svarcheg,项目名称:rx-cron-scheduler,代码行数:23,代码来源:OperationCron.java


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