Java 类rx.subscriptions.CompositeSubscription 实例源码

项目:HeroVideo-master    文件:BannerView.java   
/**
 * 图片开始轮播
 */
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);
}
项目:boohee_v5.6    文件:OperatorWindowWithStartEndObservable.java   
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;
}
项目:BilibiliClient    文件:BannerView.java   
/**
 * 图片开始轮播
 */
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);
}
项目:boohee_v5.6    文件:OnSubscribeRefCount.java   
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();
            }
        }
    });
}
项目:Farmacias    文件:FindFragment.java   
@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);
}
项目:AppChooser    文件:ResolveInfosPresenter.java   
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);
}
项目:boohee_v5.6    文件:CachedThreadScheduler.java   
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;
}
项目:Unofficial-Ups    文件:LoginActivity.java   
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);
            })
    );
}
项目:boohee_v5.6    文件:OnSubscribeRefCount.java   
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();
            }
        }
    });
}
项目:GitHub    文件:StoriesFragment.java   
@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);
}
项目:GitHub    文件:CommentsActivity.java   
@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();
}
项目:GitHub    文件:RxBus.java   
/**
 * 保存订阅后的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);
    }
}
项目:GitHub    文件:CityManagerPresenter.java   
@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);
}
项目:GitHub    文件:SelectCityPresenter.java   
@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);
}
项目:GitHub    文件:HomePagePresenter.java   
@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);
}
项目:MyCleanArchitecture    文件:HomePresenter.java   
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("初始化完成!");
}
项目:TWStreaming    文件:HomePresenter.java   
public HomePresenter(Service service, HomeView view) {
    this.service = service;
    this.view = view;
    this.subscriptions = new CompositeSubscription();

    trackSubject = "ronaldo";
}
项目:hack-nanjing-2017    文件:BaseActivity.java   
public void addSubscription(Subscription s) {
    if (this.compositeSubscription == null) {
        this.compositeSubscription = new CompositeSubscription();
    }

    this.compositeSubscription.add(s);
}
项目:TestChat    文件:RxBusManager.java   
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);
        }
}
项目:TestChat    文件:RxBus.java   
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);
        }
}
项目:AndroidBasicLibs    文件:RxBusImpl.java   
@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);
    }
}
项目:AndroidBasicLibs    文件:EventFind.java   
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);
}
项目:boohee_v5.6    文件:OperatorMerge.java   
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");
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:LoginFragment.java   
@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;
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:ChangePasswordDialog.java   
@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;
}
项目:music-player    文件:MusicPlayerPresenter.java   
public MusicPlayerPresenter(Context context, AppRepository repository, MusicPlayerContract.View view) {
    mContext = context;
    mView = view;
    mRepository = repository;
    mSubscriptions = new CompositeSubscription();
    mView.setPresenter(this);
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:ResetPasswordDialog.java   
@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;
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:RegisterFragment.java   
@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;
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:LoginFragment.java   
@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;
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:ChangePasswordDialog.java   
@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;
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:ProfileActivity.java   
@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();
}
项目:hack-nanjing-2017    文件:BaseActivity.java   
public CompositeSubscription getCompositeSubscription() {
    if (this.compositeSubscription == null) {
        this.compositeSubscription = new CompositeSubscription();
    }

    return this.compositeSubscription;
}
项目:boohee_v5.6    文件:NewThreadWorker.java   
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;
}
项目:RLibrary    文件:RxFingerPrinter.java   
/**
 * 保存订阅后的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);
    }
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:ChangePasswordDialog.java   
@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;
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:ProfileActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);
    mSubscriptions = new CompositeSubscription();
    initViews();
    initSharedPreferences();
    loadProfile();
}
项目:disclosure-android-app    文件:AppDetailPresenter.java   
public void onCreate(DetailView view, App app) {
  this.view = ensureNotNull(view);
  this.app = ensureNotNull(app);
  this.subscriptions = new CompositeSubscription();

  fetchAppUpdates();
  fetchLibraries();
  fetchAnalysisUpdates();
}
项目:disclosure-android-app    文件:LibraryListPresenter.java   
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();
}
项目:disclosure-android-app    文件:LibraryDetailPresenter.java   
public void onCreate(LibraryDetailView view, Library library) {
  this.view = view;
  this.library = library;
  this.subscriptions = new CompositeSubscription();

  initUi();
  loadApps();
}
项目:espresso-sample-for-droidkaigi2017    文件:QiitaItemsFragment.java   
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MainApplication app = (MainApplication) getContext().getApplicationContext();
    qiitaItemsSubject = app.getQiitaItemsSubject();
    subscriptions = new CompositeSubscription();
}