Java Code Examples for rx.subscriptions.CompositeSubscription

The following examples show how to use rx.subscriptions.CompositeSubscription. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: HeroVideo-master   Source File: BannerView.java    License: Apache License 2.0 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
Source Project: Loop   Source File: WatchLaterVideosFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AccessToken token = LoopPrefs.getAccessToken(getActivity());
    vimeoService = ServiceGenerator.createService(
            VimeoService.class,
            VimeoService.BASE_URL,
            new AuthorizedNetworkInterceptor(token));

    setHasOptionsMenu(true);

    font = FontCache.getTypeface("Ubuntu-Medium.ttf", getContext());
    compositeSubscription = new CompositeSubscription();

    castContext = CastContext.getSharedInstance(getContext());
}
 
Example 3
Source Project: HeroVideo-master   Source File: BannerView.java    License: Apache License 2.0 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
@Override public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  ((BaseActivity) getContext()).getActivityComponent()
      .inject(this);
  final AptoideApplication application =
      (AptoideApplication) getContext().getApplicationContext();
  trackAnalytics = true;
  accountManager =
      ((AptoideApplication) getContext().getApplicationContext()).getAccountManager();
  fileManager = ((AptoideApplication) getContext().getApplicationContext()).getFileManager();
  subscriptions = new CompositeSubscription();
  fragmentNavigator = ((ActivityResultNavigator) getActivity()).getFragmentNavigator();
  authenticationPersistence = application.getAuthenticationPersistence();
  notificationSyncScheduler =
      ((AptoideApplication) getContext().getApplicationContext()).getNotificationSyncScheduler();
  NavigationTracker navigationTracker =
      ((AptoideApplication) getContext().getApplicationContext()).getNavigationTracker();
  navigationTracker.registerScreen(ScreenTagHistory.Builder.build(this.getClass()
      .getSimpleName()));
  adultContentAnalytics = application.getAdultContentAnalytics();
  settingsManager =
      ((AptoideApplication) getContext().getApplicationContext()).getSettingsManager();
  setAdultContentContent();
  setupFileMaxCacheDialog();
}
 
Example 5
public SystemNotificationShower(Context context, NotificationManager notificationManager,
    NotificationIdsMapper notificationIdsMapper, NotificationCenter notificationCenter,
    NotificationAnalytics notificationAnalytics, CrashReport crashReport,
    NotificationProvider notificationProvider,
    NotificationApplicationView notificationApplicationView, CompositeSubscription subscriptions,
    NavigationTracker navigationTracker, NewFeatureManager newFeatureManager,
    ThemeAnalytics themeAnalytics) {
  this.context = context;
  this.notificationManager = notificationManager;
  this.notificationIdsMapper = notificationIdsMapper;
  this.notificationCenter = notificationCenter;
  this.notificationAnalytics = notificationAnalytics;
  this.crashReport = crashReport;
  this.notificationProvider = notificationProvider;
  this.subscriptions = subscriptions;
  view = notificationApplicationView;
  this.navigationTracker = navigationTracker;
  this.newFeatureManager = newFeatureManager;
  this.themeAnalytics = themeAnalytics;
}
 
Example 6
@Override public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getFragmentComponent(savedInstanceState).inject(this);

  subscriptions = new CompositeSubscription();

  tokenInvalidator =
      ((AptoideApplication) getContext().getApplicationContext()).getTokenInvalidator();
  converterFactory = WebService.getDefaultConverter();
  accountManager =
      ((AptoideApplication) getContext().getApplicationContext()).getAccountManager();
  httpClient = ((AptoideApplication) getContext().getApplicationContext()).getDefaultClient();
  baseBodyBodyInterceptor =
      ((AptoideApplication) getContext().getApplicationContext()).getAccountSettingsBodyInterceptorPoolV7();

  if (savedInstanceState != null) {
    storeName = savedInstanceState.getString(BundleArgs.STORE_NAME.name());
  }
  final AptoideApplication application =
      (AptoideApplication) getContext().getApplicationContext();
  analyticsManager = application.getAnalyticsManager();
  navigationTracker = application.getNavigationTracker();
  storeAnalytics = new StoreAnalytics(analyticsManager, navigationTracker);

  searchSuggestionManager = application.getSearchSuggestionManager();
}
 
Example 7
Source Project: RxGpsService   Source File: RxGpsPresenter.java    License: Apache License 2.0 6 votes vote down vote up
RxGpsPresenter(GpsConfig gpsConfig) {
  this.gpsConfig = gpsConfig;
  this.meaningfulUpdatesLocation = new MeaningfulUpdatesLocation();
  this.recordTime = new RecordTime();
  this.getTripDistance = new GetTripDistance();
  this.getTripSpeed = new GetTripSpeed();
  this.getTripSpeedAverage = new GetTripSpeedAverage();
  this.getTripSpeedMax = new GetTripSpeedMax();
  this.getTripSpeedMin = new GetTripSpeedMin();
  this.utilities = new Utilities();
  this.subscriptions = new CompositeSubscription();
  this.latLongs = new ArrayList<>();
  this.latLongsDetailed = new ArrayList<>();
  this.distanceAccumulated = 0;
  this.nextStageDistanceGoal = gpsConfig.getStageDistance();
  this.isMeaningfulWaypoint = false;
  this.stageDistanceReached = false;
  this.lastMeaningfulLocation = new Location("lastMeaningfulLocation");
  this.lastLocation = new Location("lastLocation");
  this.permissionState = PERMISSIONS_STATE.WAITING;
}
 
Example 8
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        compositeSubscription = new CompositeSubscription();

        mAnalytics = FirebaseAnalytics.getInstance(getContext());

        if (getArguments().containsKey(ORDER_PATH)) {
            // Load the dummy content specified by the fragment
            // arguments. In a real-world scenario, use a Loader
            // to load content from a content provider.
            mOrderPath = getArguments().getString(ORDER_PATH);

/*            Activity activity = this.getActivity();
            CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
            if (appBarLayout != null) {
                appBarLayout.setTitle(mItem.content);
            }*/
        } else if (getArguments().containsKey(ORDER_ID)) {
            mOrderId = getArguments().getString(ORDER_ID);
        }
    }
 
Example 9
Source Project: Loop   Source File: LikedVideosFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getArguments() != null) {
        query = getArguments().getString("query");
    }

    AccessToken token = LoopPrefs.getAccessToken(getActivity());
    vimeoService = ServiceGenerator.createService(
            VimeoService.class,
            VimeoService.BASE_URL,
            new AuthorizedNetworkInterceptor(token));

    setHasOptionsMenu(true);

    font = FontCache.getTypeface("Ubuntu-Medium.ttf", getContext());

    compositeSubscription = new CompositeSubscription();

    castContext = CastContext.getSharedInstance(getContext());
}
 
Example 10
Source Project: styT   Source File: ws_Main3Activity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 解决Subscription内存泄露问题
 *
 * @param s
 */
protected void addSubscription(Subscription s) {
    if (this.mCompositeSubscription == null) {
        this.mCompositeSubscription = new CompositeSubscription();
    }
    this.mCompositeSubscription.add(s);
}
 
Example 11
Source Project: TestChat   Source File: RxBusManager.java    License: Apache License 2.0 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 12
Source Project: letv   Source File: BaseApplication.java    License: Apache License 2.0 5 votes vote down vote up
public void onCreate() {
    super.onCreate();
    instance = this;
    this.mHasNavigationBar = UIsUtils.hasNavigationBar(this);
    this.mNavigationBarLandscapeWidth = UIsUtils.getNavigationBarLandscapeWidth(this);
    CDE_PARAMS = "port=6990&app_id=3000&ostype=android&channel_default_multi=0&log_type=4&log_file=" + CDELOG1 + "&channel_default_multi=1&channel_max_count=2&dcache_enabled=1&dcache_capacity=80&show_letv_cks=1&app_version=" + LetvUtils.getClientVersionName();
    this.mSubscription = new CompositeSubscription();
    PackageHelper.loadAllStaticClass();
    initIntentTask();
}
 
Example 13
Source Project: Defrag   Source File: Presenter.java    License: Apache License 2.0 5 votes vote down vote up
public final void takeView(@NonNull T view) {
	if (this.view != null) {
		throw new IllegalStateException(
				"Presenter already has the view or the DropView isn't called");
	}

	this.view = view;
	viewSubscriptions = new CompositeSubscription();
	onTakeView();
}
 
Example 14
@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 15
Source Project: RXBus   Source File: RXSubscriptionManager.java    License: Apache License 2.0 5 votes vote down vote up
private void doUnsubscribe(Object boundObject)
{
    CompositeSubscription subscriptions = mSubscriptions.get(boundObject.getClass());
    if (subscriptions != null)
    {
        subscriptions.unsubscribe();
        mSubscriptions.remove(boundObject.getClass());
    }
}
 
Example 16
Source Project: Loop   Source File: WatchNowFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (getArguments() != null) {
//            mQuery = getArguments().getString("query");
        }

        setHasOptionsMenu(true);

        font = FontCache.getTypeface("Ubuntu-Medium.ttf", getContext());
        compositeSubscription = new CompositeSubscription();
    }
 
Example 17
@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 18
/**
 * @param sessionPersistence
 * @param sendInterval max time(in milliseconds) interval between event sends
 * @param debugLogger
 */
public AptoideBiAnalytics(EventsPersistence persistence, SessionPersistence sessionPersistence,
    AptoideBiEventService service, CompositeSubscription subscriptions, Scheduler timerScheduler,
    long initialDelay, long sendInterval, CrashLogger crashReport, AnalyticsLogger debugLogger) {
  this.persistence = persistence;
  this.sessionPersistence = sessionPersistence;
  this.service = service;
  this.subscriptions = subscriptions;
  this.timerScheduler = timerScheduler;
  this.sendInterval = sendInterval;
  this.initialDelay = initialDelay;
  this.crashReport = crashReport;
  this.debugLogger = debugLogger;
}
 
Example 19
Source Project: akarnokd-misc   Source File: PerfAsyncConsumer.java    License: Apache License 2.0 5 votes vote down vote up
public PerfAsyncConsumer(Blackhole bh, IAsyncEnumerator<?> source) {
    this.bh = bh;
    this.source = source;
    this.queue = new SpscUnboundedArrayQueue<>(16);
    this.csub = new CompositeSubscription();
    this.cdl = new CountDownLatch(1);
}
 
Example 20
@NonNull @Override protected SystemNotificationShower getSystemNotificationShower() {
  if (systemNotificationShower == null) {
    systemNotificationShower = new SystemNotificationShower(this,
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE),
        new NotificationIdsMapper(), getNotificationCenter(), getNotificationAnalytics(),
        CrashReport.getInstance(), getNotificationProvider(), this, new CompositeSubscription(),
        getNavigationTracker(), getNewFeatureManager(), getThemeAnalytics());
  }
  return systemNotificationShower;
}
 
Example 21
@FragmentScope @Provides ClaimPromotionDialogPresenter providesClaimPromotionDialogPresenter(
    ClaimPromotionsManager claimPromotionsManager, PromotionsAnalytics promotionsAnalytics,
    ClaimPromotionsNavigator navigator) {
  return new ClaimPromotionDialogPresenter((ClaimPromotionDialogView) fragment,
      new CompositeSubscription(), AndroidSchedulers.mainThread(), claimPromotionsManager,
      promotionsAnalytics, navigator);
}
 
Example 22
/**
 * Needed for reflective {@link Class#newInstance()}.
 */
public Displayable() {
  subscriptions = new CompositeSubscription();
  Configs config = getConfig();
  fixedPerLineCount = config.isFixedPerLineCount();
  defaultPerLineCount = config.getDefaultPerLineCount();
}
 
Example 23
public DeepLinkManager(StoreUtilsProxy storeUtilsProxy, FragmentNavigator fragmentNavigator,
    BottomNavigationNavigator bottomNavigationNavigator, SearchNavigator searchNavigator,
    DeepLinkView deepLinkView, SharedPreferences sharedPreferences,
    RoomStoreRepository storeRepository, NotificationAnalytics notificationAnalytics,
    NavigationTracker navigationTracker, SearchAnalytics searchAnalytics,
    AppShortcutsAnalytics appShortcutsAnalytics, AptoideAccountManager accountManager,
    DeepLinkAnalytics deepLinkAnalytics, StoreAnalytics storeAnalytics,
    AdsRepository adsRepository, AppNavigator appNavigator, InstallManager installManager,
    NewFeature newFeature, ThemeManager themeManager, ThemeAnalytics themeAnalytics) {
  this.storeUtilsProxy = storeUtilsProxy;
  this.fragmentNavigator = fragmentNavigator;
  this.bottomNavigationNavigator = bottomNavigationNavigator;
  this.searchNavigator = searchNavigator;
  this.deepLinkView = deepLinkView;
  this.sharedPreferences = sharedPreferences;
  this.storeRepository = storeRepository;
  this.navigationTracker = navigationTracker;
  this.notificationAnalytics = notificationAnalytics;
  this.searchAnalytics = searchAnalytics;
  this.appShortcutsAnalytics = appShortcutsAnalytics;
  this.accountManager = accountManager;
  this.deepLinkAnalytics = deepLinkAnalytics;
  this.storeAnalytics = storeAnalytics;
  this.adsRepository = adsRepository;
  this.appNavigator = appNavigator;
  this.installManager = installManager;
  this.newFeature = newFeature;
  this.themeManager = themeManager;
  this.themeAnalytics = themeAnalytics;
  this.subscriptions = new CompositeSubscription();
}
 
Example 24
Source Project: Gank-Veaer   Source File: BaseActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void addSubscription(Subscription s) {
    if (this.mCompositeSubscription == null) {
        this.mCompositeSubscription = new CompositeSubscription();
    }

    this.mCompositeSubscription.add(s);
}
 
Example 25
@Override public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  ((MainActivity) getContext()).getActivityComponent()
      .inject(this);
  packageName = getArguments().getString(PACKAGE_NAME);
  presenter = new DonateDialogPresenter(this, walletService, new CompositeSubscription(),
      AndroidSchedulers.mainThread(), appNavigator, donationsAnalytics);
  textUpdate = true;
  sliderUpdate = true;
  handleValueInputFiltering();
}
 
Example 26
@Singleton @Provides @Named("aptoide") AptoideBiEventLogger providesAptoideBILogger(
    EventsPersistence persistence, AptoideBiEventService service,
    @Named("default") SharedPreferences preferences, AnalyticsLogger debugLogger) {
  return new AptoideBiEventLogger(
      new AptoideBiAnalytics(persistence, new SharedPreferencesSessionPersistence(preferences),
          service, new CompositeSubscription(), Schedulers.computation(),
          BuildConfig.ANALYTICS_EVENTS_INITIAL_DELAY_IN_MILLIS,
          BuildConfig.ANALYTICS_EVENTS_TIME_INTERVAL_IN_MILLIS, CrashReport.getInstance(),
          debugLogger), BuildConfig.ANALYTICS_SESSION_INTERVAL_IN_MILLIS);
}
 
Example 27
public NotificationsCleaner(RoomNotificationPersistence roomNotificationPersistence,
    Calendar calendar, AptoideAccountManager accountManager,
    NotificationProvider notificationProvider, CrashReport crashReport) {
  this.roomNotificationPersistence = roomNotificationPersistence;
  this.calendar = calendar;
  this.accountManager = accountManager;
  this.notificationProvider = notificationProvider;
  this.crashReport = crashReport;
  subscriptions = new CompositeSubscription();
}
 
Example 28
public ClaimPromotionDialogPresenter(ClaimPromotionDialogView view,
    CompositeSubscription subscriptions, Scheduler viewScheduler,
    ClaimPromotionsManager claimPromotionsManager, PromotionsAnalytics promotionsAnalytics,
    ClaimPromotionsNavigator navigator) {
  this.view = view;
  this.subscriptions = subscriptions;
  this.viewScheduler = viewScheduler;
  this.claimPromotionsManager = claimPromotionsManager;
  this.promotionsAnalytics = promotionsAnalytics;
  this.navigator = navigator;
  this.shouldSendIntent = true;
}
 
Example 29
Source Project: EmojiRain   Source File: EmojiRainLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.EmojiRainLayout);

    mSubscriptions = new CompositeSubscription();
    mEmojis = new ArrayList<>();
    mEmojiPer = ta.getInteger(R.styleable.EmojiRainLayout_per, DEFAULT_PER);
    mDuration = ta.getInteger(R.styleable.EmojiRainLayout_duration, DEFAULT_DURATION);
    mDropAverageDuration = ta.getInteger(R.styleable.EmojiRainLayout_dropDuration,
            DEFAULT_DROP_DURATION);
    mDropFrequency = ta.getInteger(R.styleable.EmojiRainLayout_dropFrequency,
            DEFAULT_DROP_FREQUENCY);

    ta.recycle();
}
 
Example 30
Source Project: ESeal   Source File: LoginPresenter.java    License: Apache License 2.0 5 votes vote down vote up
public LoginPresenter(boolean save,
                      Context context,
                      LoginContract.View view,
                      BaseSchedulerProvider schedulerProvider) {
    mSave = save;
    mContext = context;
    mView = view;
    mSchedulerProvider = schedulerProvider;

    mSubscriptions = new CompositeSubscription();
    mView.setPresenter(this);
}