rx.subscriptions.CompositeSubscription Java Examples

The following examples show how to use rx.subscriptions.CompositeSubscription. 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 File: LikedVideosFragment.java    From Loop with 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 #2
Source File: OrderDetailFragment.java    From Pharmacy-Android with GNU General Public License v3.0 6 votes vote down vote up
@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 #3
Source File: RxGpsPresenter.java    From RxGpsService with 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 #4
Source File: AddStoreDialog.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@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 #5
Source File: SystemNotificationShower.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: SettingsFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@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 #7
Source File: BannerView.java    From HeroVideo-master with 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 #8
Source File: BannerView.java    From HeroVideo-master with 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 #9
Source File: WatchLaterVideosFragment.java    From Loop with 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 #10
Source File: AboutPresenter.java    From ESeal with Apache License 2.0 5 votes vote down vote up
public AboutPresenter(Context context,
                      AboutContract.View view,
                      BaseSchedulerProvider schedulerProvider) {
    mContext = context;
    mView = view;
    mSchedulerProvider = schedulerProvider;

    mSubscriptions = new CompositeSubscription();
    mView.setPresenter(this);
}
 
Example #11
Source File: CommonPresenter.java    From FileManager with Apache License 2.0 5 votes vote down vote up
public CommonPresenter(Context context, String path) {
    this.mContext = context;
    this.mPath = path;
    mCompositeSubscription = new CompositeSubscription();

    mCompositeSubscription.add(RxBus.getDefault()
            .IoToUiObservable(CleanChoiceEvent.class)
            .subscribe(event -> {
                mView.setLongClick(false);
                mView.clearSelect();
            }, Throwable::printStackTrace));

    mCompositeSubscription.add(RxBus.getDefault()
            .IoToUiObservable(RefreshEvent.class)
            .subscribe(event -> {
                mView.refreshAdapter();
            }, Throwable::printStackTrace));

    mCompositeSubscription.add(RxBus.getDefault()
            .IoToUiObservable(AllChoiceEvent.class)
            .map(event -> "/" + event.getPath())
            .subscribe(dirPath -> {
                //如果全选了,就取消。否则全选
                if (dirPath.equals(this.mPath)) {
                    mView.allChoiceClick();
                }
            }, Throwable::printStackTrace));

    mCompositeSubscription.add(RxBus.getDefault()
            .IoToUiObservable(SnackBarEvent.class)
            .subscribe(snackBarEvent -> {
                mView.showSnackBar(snackBarEvent.getContent());
            }));
}
 
Example #12
Source File: TimePickerPresenter.java    From ESeal with Apache License 2.0 5 votes vote down vote up
public TimePickerPresenter(Context context, TimePickerContract.View view, SchedulerProvider schedulerProvider) {
    mContext = context;
    mView = view;
    mSchedulerProvider = schedulerProvider;

    mCompositeSubscription = new CompositeSubscription();
    mView.setPresenter(this);
}
 
Example #13
Source File: LogsDialog.java    From u2020 with Apache License 2.0 5 votes vote down vote up
@Override protected void onStart() {
  super.onStart();

  adapter.setLogs(lumberYard.bufferedLogs());

  subscriptions = new CompositeSubscription();
  subscriptions.add(lumberYard.logs() //
      .observeOn(AndroidSchedulers.mainThread()) //
      .subscribe(adapter));
}
 
Example #14
Source File: ws_Main3Activity.java    From styT with 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 #15
Source File: MainActivity.java    From Hews with MIT License 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    // init mCompositeSubscription here due to onCreate() will not be called
    // when theme changed (call reCreate())
    mCompositeSubscription = new CompositeSubscription();
    mDataManager = new DataManager();
    if (SharedPrefsManager.getIsOpenLinkInApp(prefs, this)
        && ChromeCustomTabsHelper.getPackageNameToUse(this) != null
        && mChromeCustomTabsHelper == null) {
        mChromeCustomTabsHelper = new ChromeCustomTabsHelper();
        mChromeCustomTabsHelper.bindCustomTabsService(this);
    }
}
 
Example #16
Source File: SearchPresenter.java    From UGank with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void subscribe() {
    mSubscriptions = new CompositeSubscription();
    mView.setToolbarBackgroundColor(ThemeManage.INSTANCE.getColorPrimary());
    mView.setEditTextCursorColor(Color.WHITE);
    mView.hideEditClear();
}
 
Example #17
Source File: ProfileActivity.java    From android-login-registration-authentication-client with MIT License 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 #18
Source File: BaseActivity.java    From MyHearts with 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 #19
Source File: WeatherActivity.java    From rex-weather with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
                         final Bundle savedInstanceState) {
    mCompositeSubscription = new CompositeSubscription();

    final View rootView = inflater.inflate(R.layout.fragment_weather, container, false);
    mLocationNameTextView = (TextView) rootView.findViewById(R.id.location_name);
    mCurrentTemperatureTextView = (TextView) rootView
            .findViewById(R.id.current_temperature);

    // Set up list view for weather forecasts.
    mForecastListView = (ListView) rootView.findViewById(R.id.weather_forecast_list);
    final WeatherForecastListAdapter adapter = new WeatherForecastListAdapter(
            new ArrayList<WeatherForecast>(), getActivity());
    mForecastListView.setAdapter(adapter);

    mAttributionTextView = (TextView) rootView.findViewById(R.id.attribution);
    mAttributionTextView.setVisibility(View.INVISIBLE);

    // Set up swipe refresh layout.
    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView
            .findViewById(R.id.swipe_refresh_container);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.brand_main,
            android.R.color.black,
            R.color.brand_main,
            android.R.color.black);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            updateWeather();
        }
    });

    updateWeather();
    return rootView;
}
 
Example #20
Source File: ScanNfcDevicePresenter.java    From ESeal with Apache License 2.0 5 votes vote down vote up
public ScanNfcDevicePresenter(Context context,
                              ScanNfcDeviceContract.View view,
                              BaseSchedulerProvider schedulerProvider) {
    mContext = context;
    mView = view;
    mSchedulerProvider = schedulerProvider;

    mSubscriptions = new CompositeSubscription();
    mView.setPresenter(this);
}
 
Example #21
Source File: LoginPresenter.java    From ESeal with 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);
}
 
Example #22
Source File: EmojiRainLayout.java    From EmojiRain with 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 #23
Source File: RxBusManager.java    From TestChat with 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 #24
Source File: ClaimPromotionDialogPresenter.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: NotificationsCleaner.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
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 #26
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@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
Source File: DonateDialogFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@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 #28
Source File: BaseActivity.java    From Gank-Veaer with 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 #29
Source File: DeepLinkManager.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
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 #30
Source File: SettingActivity.java    From FileManager with Apache License 2.0 5 votes vote down vote up
@Override
public void initUiAndListener() {
    getFragmentManager().beginTransaction().replace(R.id.content, new SettingFragment()).commit();

    AnimationUtil.showCircularReveal(mContentView, 0, 0, 2, 1500);

    mCompositeSubscription = new CompositeSubscription();
    mCompositeSubscription.add(RxBus.getDefault()
            .IoToUiObservable(ChangeDefaultDirEvent.class)
            .map(ChangeDefaultDirEvent::getType)
            .subscribe(type -> {
                new FolderChooserDialog.Builder(this)
                        .tag(type)
                        .chooseButton(R.string.md_choose_label)  // changes label of the choose button
                        .initialPath(Settings.getDefaultDir())  // changes initial path, defaults to external storage directory
                        .cancelButton(R.string.cancel)
                        .goUpLabel("Up") // custom go up label, default label is "..."
                        .show();
            }, Throwable::printStackTrace));

    mCompositeSubscription.add(RxBus.getDefault()
            .IoToUiObservable(ChangeThemeEvent.class)
            .subscribe(event -> {
                reload();
            }, Throwable::printStackTrace));

    mCompositeSubscription.add(RxBus.getDefault()
            .IoToUiObservable(LanguageEvent.class)
            .subscribe(event -> {
                reload();
            }, Throwable::printStackTrace));

}