Java Code Examples for rx.subscriptions.CompositeSubscription

The following are top voted examples for showing how to use rx.subscriptions.CompositeSubscription. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: HeroVideo-master   File: BannerView.java   View source code 6 votes vote down vote up
/**
 * 图片开始轮播
 */
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);
}
 
Example 2
Project: boohee_v5.6   File: OperatorWindowWithStartEndObservable.java   View source code 6 votes vote down vote up
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;
}
 
Example 3
Project: BilibiliClient   File: BannerView.java   View source code 6 votes vote down vote up
/**
 * 图片开始轮播
 */
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);
}
 
Example 4
Project: boohee_v5.6   File: OnSubscribeRefCount.java   View source code 6 votes vote down vote up
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();
            }
        }
    });
}
 
Example 5
Project: Farmacias   File: FindFragment.java   View source code 6 votes vote down vote up
@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);
}
 
Example 6
Project: AppChooser   File: ResolveInfosPresenter.java   View source code 6 votes vote down vote up
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);
}
 
Example 7
Project: boohee_v5.6   File: CachedThreadScheduler.java   View source code 6 votes vote down vote up
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;
}
 
Example 8
Project: Unofficial-Ups   File: LoginActivity.java   View source code 5 votes vote down vote up
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);
            })
    );
}
 
Example 9
Project: boohee_v5.6   File: OnSubscribeRefCount.java   View source code 5 votes vote down vote up
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();
            }
        }
    });
}
 
Example 10
Project: GitHub   File: StoriesFragment.java   View source code 5 votes vote down vote up
@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);
}
 
Example 11
Project: GitHub   File: CommentsActivity.java   View source code 5 votes vote down vote up
@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();
}
 
Example 12
Project: GitHub   File: RxBus.java   View source code 5 votes vote down vote up
/**
 * 保存订阅后的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);
    }
}
 
Example 13
Project: GitHub   File: CityManagerPresenter.java   View source code 5 votes vote down vote up
@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);
}
 
Example 14
Project: GitHub   File: SelectCityPresenter.java   View source code 5 votes vote down vote up
@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);
}
 
Example 15
Project: GitHub   File: HomePagePresenter.java   View source code 5 votes vote down vote up
@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);
}
 
Example 16
Project: MyCleanArchitecture   File: HomePresenter.java   View source code 5 votes vote down vote up
public HomePresenter(@NonNull DataLayer mDataLayer, @NonNull HomeContract.View mHomeView,
                        boolean shouldLoadDataFromRepo) {
    this.mHomeView = mHomeView;
    this.mDataLayer = mDataLayer;
    mIsDataMissing = shouldLoadDataFromRepo;

    mSubscriptions = new CompositeSubscription();
    mHomeView.setPresenter(this);
    Timber.e("初始化完成!");
}
 
Example 17
Project: TWStreaming   File: HomePresenter.java   View source code 5 votes vote down vote up
public HomePresenter(Service service, HomeView view) {
    this.service = service;
    this.view = view;
    this.subscriptions = new CompositeSubscription();

    trackSubject = "ronaldo";
}
 
Example 18
Project: hack-nanjing-2017   File: BaseActivity.java   View source code 5 votes vote down vote up
public void addSubscription(Subscription s) {
    if (this.compositeSubscription == null) {
        this.compositeSubscription = new CompositeSubscription();
    }

    this.compositeSubscription.add(s);
}
 
Example 19
Project: TestChat   File: RxBusManager.java   View source code 5 votes vote down vote up
public void addSubscription(Object object, Subscription subscription) {
        String name = object.getClass().getName();
        if (mSubscriptionMap.get(name) == null) {
                CompositeSubscription compositeSubscription = new CompositeSubscription();
                compositeSubscription.add(subscription);
                mSubscriptionMap.put(name, compositeSubscription);
        } else {
                mSubscriptionMap.get(name).add(subscription);
        }
}
 
Example 20
Project: TestChat   File: RxBus.java   View source code 5 votes vote down vote up
public void addSubscription(Object object, Subscription subscription) {
        String name = object.getClass().getName();
        if (mSubscriptionMap.get(name) == null) {
                CompositeSubscription compositeSubscription = new CompositeSubscription();
                compositeSubscription.add(subscription);
                mSubscriptionMap.put(name, compositeSubscription);
        } else {
                mSubscriptionMap.get(name).add(subscription);
        }
}
 
Example 21
Project: AndroidBasicLibs   File: RxBusImpl.java   View source code 5 votes vote down vote up
@Override
public void register(Object object) {
    if (object == null) {
        throw new NullPointerException("Object to register must not be null.");
    }
    CompositeSubscription compositeSubscription = new CompositeSubscription();
    EventComposite subscriberMethods = EventFind.findAnnotatedSubscriberMethods(object, compositeSubscription);
    mEventCompositeMap.put(object, subscriberMethods);

    if (!STICKY_EVENT_MAP.isEmpty()) {
        subscriberMethods.subscriberSticky(STICKY_EVENT_MAP);
    }
}
 
Example 22
Project: AndroidBasicLibs   File: EventFind.java   View source code 5 votes vote down vote up
private static EventComposite findAnnotatedMethods(Object listenerClass, Set<EventSubscriber> subscriberMethods,
                                                   CompositeSubscription compositeSubscription) {
    for (Method method : listenerClass.getClass().getDeclaredMethods()) {
        if (method.isBridge()) {
            continue;
        }
        if (method.isAnnotationPresent(EventSubscribe.class)) {
            Class<?>[] parameterTypes = method.getParameterTypes();
            if (parameterTypes.length != 1) {
                throw new IllegalArgumentException("Method " + method + " has @Subscribe annotation but requires " + parameterTypes
                        .length + " arguments.  Methods must require a single argument.");
            }

            Class<?> parameterClazz = parameterTypes[0];
            if ((method.getModifiers() & Modifier.PUBLIC) == 0) {
                throw new IllegalArgumentException("Method " + method + " has @EventSubscribe annotation on " + parameterClazz + " " +
                        "but is not 'public'.");
            }

            EventSubscribe annotation = method.getAnnotation(EventSubscribe.class);
            EventThread thread = annotation.thread();

            EventSubscriber subscriberEvent = new EventSubscriber(listenerClass, method, thread);
            if (!subscriberMethods.contains(subscriberEvent)) {
                subscriberMethods.add(subscriberEvent);
                compositeSubscription.add(subscriberEvent.getSubscription());
            }
        }
    }
    return new EventComposite(compositeSubscription, listenerClass, subscriberMethods);
}
 
Example 23
Project: boohee_v5.6   File: OperatorMerge.java   View source code 5 votes vote down vote up
rx.subscriptions.CompositeSubscription getOrCreateComposite() {
    /*
    r4 = this;
    r0 = r4.subscriptions;
    if (r0 != 0) goto L_0x0019;
L_0x0004:
    r2 = 0;
    monitor-enter(r4);
    r0 = r4.subscriptions;	 Catch:{ all -> 0x001a }
    if (r0 != 0) goto L_0x0013;
L_0x000a:
    r1 = new rx.subscriptions.CompositeSubscription;	 Catch:{ all -> 0x001a }
    r1.<init>();	 Catch:{ all -> 0x001a }
    r4.subscriptions = r1;	 Catch:{ all -> 0x001d }
    r2 = 1;
    r0 = r1;
L_0x0013:
    monitor-exit(r4);	 Catch:{ all -> 0x001a }
    if (r2 == 0) goto L_0x0019;
L_0x0016:
    r4.add(r0);
L_0x0019:
    return r0;
L_0x001a:
    r3 = move-exception;
L_0x001b:
    monitor-exit(r4);	 Catch:{ all -> 0x001a }
    throw r3;
L_0x001d:
    r3 = move-exception;
    r0 = r1;
    goto L_0x001b;
    */
    throw new UnsupportedOperationException("Method not decompiled: rx.internal.operators.OperatorMerge.MergeSubscriber.getOrCreateComposite():rx.subscriptions.CompositeSubscription");
}
 
Example 24
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: LoginFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_login,container,false);
    mSubscriptions = new CompositeSubscription();
    initViews(view);
    initSharedPreferences();
    return view;
}
 
Example 25
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: ChangePasswordDialog.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.dialog_change_password,container,false);
    mSubscriptions = new CompositeSubscription();
    getData();
    initViews(view);
    return view;
}
 
Example 26
Project: music-player   File: MusicPlayerPresenter.java   View source code 5 votes vote down vote up
public MusicPlayerPresenter(Context context, AppRepository repository, MusicPlayerContract.View view) {
    mContext = context;
    mView = view;
    mRepository = repository;
    mSubscriptions = new CompositeSubscription();
    mView.setPresenter(this);
}
 
Example 27
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: ResetPasswordDialog.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_reset_password,container,false);
    mSubscriptions = new CompositeSubscription();
    initViews(view);
    return view;
}
 
Example 28
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: RegisterFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_register,container,false);
    mSubscriptions = new CompositeSubscription();
    initViews(view);
    return view;
}
 
Example 29
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: LoginFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_login,container,false);
    mSubscriptions = new CompositeSubscription();
    initViews(view);
    initSharedPreferences();
    return view;
}
 
Example 30
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: ChangePasswordDialog.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.dialog_change_password,container,false);
    mSubscriptions = new CompositeSubscription();
    getData();
    initViews(view);
    return view;
}
 
Example 31
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: ProfileActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    mSubscriptions = new CompositeSubscription();

    mTvName = (TextView) findViewById(R.id.tv_name);
    mTvEmail = (TextView) findViewById(R.id.tv_email);
    mTvDate = (TextView) findViewById(R.id.tv_date);

    initSharedPreferences();
    loadProfile();
}
 
Example 32
Project: hack-nanjing-2017   File: BaseActivity.java   View source code 5 votes vote down vote up
public CompositeSubscription getCompositeSubscription() {
    if (this.compositeSubscription == null) {
        this.compositeSubscription = new CompositeSubscription();
    }

    return this.compositeSubscription;
}
 
Example 33
Project: boohee_v5.6   File: NewThreadWorker.java   View source code 5 votes vote down vote up
public ScheduledAction scheduleActual(Action0 action, long delayTime, TimeUnit unit, CompositeSubscription parent) {
    Future f;
    ScheduledAction run = new ScheduledAction(this.schedulersHook.onSchedule(action), parent);
    parent.add(run);
    if (delayTime <= 0) {
        f = this.executor.submit(run);
    } else {
        f = this.executor.schedule(run, delayTime, unit);
    }
    run.add(f);
    return run;
}
 
Example 34
Project: RLibrary   File: RxFingerPrinter.java   View source code 5 votes vote down vote up
/**
 * 保存订阅后的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);
    }
}
 
Example 35
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: ChangePasswordDialog.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.dialog_change_password,container,false);
    mSubscriptions = new CompositeSubscription();
    getData();
    initViews(view);
    return view;
}
 
Example 36
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: ProfileActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);
    mSubscriptions = new CompositeSubscription();
    initViews();
    initSharedPreferences();
    loadProfile();
}
 
Example 37
Project: disclosure-android-app   File: AppDetailPresenter.java   View source code 5 votes vote down vote up
public void onCreate(DetailView view, App app) {
  this.view = ensureNotNull(view);
  this.app = ensureNotNull(app);
  this.subscriptions = new CompositeSubscription();

  fetchAppUpdates();
  fetchLibraries();
  fetchAnalysisUpdates();
}
 
Example 38
Project: disclosure-android-app   File: LibraryListPresenter.java   View source code 5 votes vote down vote up
public void onCreate(LibraryListView view, Library.Type type) {
  this.view = ensureNotNull(view, "must provide view for presenter");
  this.type = ensureNotNull(type, "must provide type of libraries to load");
  this.subscriptions = new CompositeSubscription();

  fetchFilterPreference();
  loadLibraries();
}
 
Example 39
Project: disclosure-android-app   File: LibraryDetailPresenter.java   View source code 5 votes vote down vote up
public void onCreate(LibraryDetailView view, Library library) {
  this.view = view;
  this.library = library;
  this.subscriptions = new CompositeSubscription();

  initUi();
  loadApps();
}
 
Example 40
Project: espresso-sample-for-droidkaigi2017   File: QiitaItemsFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MainApplication app = (MainApplication) getContext().getApplicationContext();
    qiitaItemsSubject = app.getQiitaItemsSubject();
    subscriptions = new CompositeSubscription();
}