private void subscribeToChanges() { RxSharedPreferences prefs = RxSharedPreferences.create(PreferenceManager.getDefaultSharedPreferences(mAppContext)); Preference<Integer> lastPage = prefs.getInteger(Constants.PREF_LAST_PAGE); Observable.merge( mBookmarkModel.tagsObservable(), mBookmarkModel.bookmarksObservable(), lastPage.asObservable()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( new Action1<Object>() { @Override public void call(Object o) { if (mFragment != null) { requestData(false); } else { mCachedData = null; } } }); }
@Provides @Singleton @AnimationSpeed Preference<Integer> provideAnimationSpeed(RxSharedPreferences preferences) { return preferences.getInteger("debug_animation_speed", DEFAULT_ANIMATION_SPEED); }
@Provides @Singleton @NetworkFailurePercent Preference<Integer> provideNetworkFailurePercent(RxSharedPreferences preferences) { return preferences.getInteger("debug_network_failure_percent", 3); }
@Provides @Singleton @NetworkVariancePercent Preference<Integer> provideNetworkVariancePercent(RxSharedPreferences preferences) { return preferences.getInteger("debug_network_variance_percent", 40); }