java类rx.subscriptions.CompositeSubscription的实例源码

BannerView.java 文件源码 项目:HeroVideo-master 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 图片开始轮播
 */
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);
}
OperatorWindowWithStartEndObservable.java 文件源码 项目:boohee_v5.6 阅读 25 收藏 0 点赞 0 评论 0
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;
}
BannerView.java 文件源码 项目:BilibiliClient 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 图片开始轮播
 */
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);
}
OnSubscribeRefCount.java 文件源码 项目:boohee_v5.6 阅读 28 收藏 0 点赞 0 评论 0
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();
            }
        }
    });
}
FindFragment.java 文件源码 项目:Farmacias 阅读 30 收藏 0 点赞 0 评论 0
@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);
}
ResolveInfosPresenter.java 文件源码 项目:AppChooser 阅读 20 收藏 0 点赞 0 评论 0
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);
}
CachedThreadScheduler.java 文件源码 项目:boohee_v5.6 阅读 21 收藏 0 点赞 0 评论 0
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;
}
LoginActivity.java 文件源码 项目:Unofficial-Ups 阅读 26 收藏 0 点赞 0 评论 0
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);
            })
    );
}
OnSubscribeRefCount.java 文件源码 项目:boohee_v5.6 阅读 23 收藏 0 点赞 0 评论 0
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();
            }
        }
    });
}
StoriesFragment.java 文件源码 项目:GitHub 阅读 20 收藏 0 点赞 0 评论 0
@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);
}
CommentsActivity.java 文件源码 项目:GitHub 阅读 29 收藏 0 点赞 0 评论 0
@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();
}
RxBus.java 文件源码 项目:GitHub 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 保存订阅后的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);
    }
}
CityManagerPresenter.java 文件源码 项目:GitHub 阅读 25 收藏 0 点赞 0 评论 0
@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);
}
SelectCityPresenter.java 文件源码 项目:GitHub 阅读 27 收藏 0 点赞 0 评论 0
@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);
}
HomePagePresenter.java 文件源码 项目:GitHub 阅读 25 收藏 0 点赞 0 评论 0
@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);
}
HomePresenter.java 文件源码 项目:MyCleanArchitecture 阅读 23 收藏 0 点赞 0 评论 0
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("初始化完成!");
}
HomePresenter.java 文件源码 项目:TWStreaming 阅读 24 收藏 0 点赞 0 评论 0
public HomePresenter(Service service, HomeView view) {
    this.service = service;
    this.view = view;
    this.subscriptions = new CompositeSubscription();

    trackSubject = "ronaldo";
}
BaseActivity.java 文件源码 项目:hack-nanjing-2017 阅读 22 收藏 0 点赞 0 评论 0
public void addSubscription(Subscription s) {
    if (this.compositeSubscription == null) {
        this.compositeSubscription = new CompositeSubscription();
    }

    this.compositeSubscription.add(s);
}
RxBusManager.java 文件源码 项目:TestChat 阅读 21 收藏 0 点赞 0 评论 0
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);
        }
}
RxBus.java 文件源码 项目:TestChat 阅读 25 收藏 0 点赞 0 评论 0
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);
        }
}
RxBusImpl.java 文件源码 项目:AndroidBasicLibs 阅读 22 收藏 0 点赞 0 评论 0
@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);
    }
}
EventFind.java 文件源码 项目:AndroidBasicLibs 阅读 22 收藏 0 点赞 0 评论 0
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);
}
OperatorMerge.java 文件源码 项目:boohee_v5.6 阅读 20 收藏 0 点赞 0 评论 0
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");
}
LoginFragment.java 文件源码 项目:Sistema-de-Comercializacion-Negocios-Jhordan 阅读 28 收藏 0 点赞 0 评论 0
@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;
}
ChangePasswordDialog.java 文件源码 项目:Sistema-de-Comercializacion-Negocios-Jhordan 阅读 20 收藏 0 点赞 0 评论 0
@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;
}
MusicPlayerPresenter.java 文件源码 项目:music-player 阅读 20 收藏 0 点赞 0 评论 0
public MusicPlayerPresenter(Context context, AppRepository repository, MusicPlayerContract.View view) {
    mContext = context;
    mView = view;
    mRepository = repository;
    mSubscriptions = new CompositeSubscription();
    mView.setPresenter(this);
}
ResetPasswordDialog.java 文件源码 项目:Sistema-de-Comercializacion-Negocios-Jhordan 阅读 20 收藏 0 点赞 0 评论 0
@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;
}
RegisterFragment.java 文件源码 项目:Sistema-de-Comercializacion-Negocios-Jhordan 阅读 21 收藏 0 点赞 0 评论 0
@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;
}
LoginFragment.java 文件源码 项目:Sistema-de-Comercializacion-Negocios-Jhordan 阅读 22 收藏 0 点赞 0 评论 0
@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;
}
ChangePasswordDialog.java 文件源码 项目:Sistema-de-Comercializacion-Negocios-Jhordan 阅读 28 收藏 0 点赞 0 评论 0
@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;
}


问题


面经


文章

微信
公众号

扫码关注公众号