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