use of io.reactivex.disposables.CompositeDisposable in project Shuttle by timusus.
the class CustomCheckbox method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
subscriptions = new CompositeDisposable();
// noinspection ConstantConditions
subscriptions.add(Observable.combineLatest(ViewUtil.getObservableForResId(getContext(), backgroundResId, Aesthetic.get(getContext()).colorAccent()), Aesthetic.get(getContext()).isDark(), ColorIsDarkState.creator()).compose(Rx.<ColorIsDarkState>distinctToMainThread()).subscribe(colorIsDarkState -> invalidateColors(colorIsDarkState), onErrorLogAndRethrow()));
ViewTextColorAction.create(this).accept(Color.BLACK);
}
use of io.reactivex.disposables.CompositeDisposable in project Shuttle by timusus.
the class Aesthetic method resume.
/**
* Should be called in onResume() of each Activity.
*/
public void resume(@NonNull final AppCompatActivity activity) {
if (instance == null) {
return;
}
instance.context = activity;
if (instance.subs != null) {
instance.subs.clear();
}
instance.subs = new CompositeDisposable();
instance.subs.add(instance.colorPrimary().compose(Rx.<Integer>distinctToMainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(@io.reactivex.annotations.NonNull Integer color) {
Util.setTaskDescriptionColor(activity, color);
}
}, onErrorLogAndRethrow()));
instance.subs.add(instance.activityTheme().compose(Rx.<Integer>distinctToMainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(@io.reactivex.annotations.NonNull Integer themeId) {
if (getLastActivityTheme(activity) == themeId) {
return;
}
instance.lastActivityThemes.put(activity.getClass().getName(), themeId);
activity.recreate();
}
}, onErrorLogAndRethrow()));
instance.subs.add(Observable.combineLatest(instance.colorStatusBar(), instance.lightStatusBarMode(), new BiFunction<Integer, Integer, Pair<Integer, Integer>>() {
@Override
public Pair<Integer, Integer> apply(Integer integer, Integer integer2) {
return Pair.create(integer, integer2);
}
}).compose(Rx.<Pair<Integer, Integer>>distinctToMainThread()).subscribe(new Consumer<Pair<Integer, Integer>>() {
@Override
public void accept(@io.reactivex.annotations.NonNull Pair<Integer, Integer> result) {
instance.invalidateStatusBar(activity);
}
}, onErrorLogAndRethrow()));
instance.subs.add(instance.colorNavigationBar().compose(Rx.<Integer>distinctToMainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(@io.reactivex.annotations.NonNull Integer color) {
setNavBarColorCompat(activity, color);
}
}, onErrorLogAndRethrow()));
instance.subs.add(instance.colorWindowBackground().compose(Rx.<Integer>distinctToMainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(@io.reactivex.annotations.NonNull Integer color) {
activity.getWindow().setBackgroundDrawable(new ColorDrawable(color));
}
}, onErrorLogAndRethrow()));
if (MaterialDialogsUtil.shouldSupport()) {
instance.subs.add(MaterialDialogsUtil.observe(instance));
}
}
use of io.reactivex.disposables.CompositeDisposable in project Shuttle by timusus.
the class AestheticEditText method onAttachedToWindow.
@SuppressWarnings("ConstantConditions")
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
subscriptions = new CompositeDisposable();
subscriptions.add(Observable.combineLatest(ViewUtil.getObservableForResId(getContext(), backgroundResId, Aesthetic.get(getContext()).colorAccent()), Aesthetic.get(getContext()).isDark(), ColorIsDarkState.creator()).compose(Rx.<ColorIsDarkState>distinctToMainThread()).subscribe(new Consumer<ColorIsDarkState>() {
@Override
public void accept(@NonNull ColorIsDarkState colorIsDarkState) {
invalidateColors(colorIsDarkState);
}
}, onErrorLogAndRethrow()));
subscriptions.add(ViewUtil.getObservableForResId(getContext(), textColorResId, Aesthetic.get(getContext()).textColorPrimary()).compose(Rx.<Integer>distinctToMainThread()).subscribe(ViewTextColorAction.create(this), onErrorLogAndRethrow()));
subscriptions.add(ViewUtil.getObservableForResId(getContext(), textColorHintResId, Aesthetic.get(getContext()).textColorSecondary()).compose(Rx.<Integer>distinctToMainThread()).subscribe(ViewHintTextColorAction.create(this), onErrorLogAndRethrow()));
}
use of io.reactivex.disposables.CompositeDisposable in project Shuttle by timusus.
the class AestheticTextInputLayout method onAttachedToWindow.
@SuppressWarnings("ConstantConditions")
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
subs = new CompositeDisposable();
subs.add(Aesthetic.get(getContext()).textColorSecondary().compose(Rx.<Integer>distinctToMainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(@NonNull Integer color) {
TextInputLayoutUtil.setHint(AestheticTextInputLayout.this, adjustAlpha(color, 0.7f));
}
}, onErrorLogAndRethrow()));
subs.add(ViewUtil.getObservableForResId(getContext(), backgroundResId, Aesthetic.get(getContext()).colorAccent()).compose(Rx.<Integer>distinctToMainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(@NonNull Integer color) {
invalidateColors(color);
}
}, onErrorLogAndRethrow()));
}
use of io.reactivex.disposables.CompositeDisposable in project Shuttle by timusus.
the class AestheticRadioButton method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
subscriptions = new CompositeDisposable();
// noinspection ConstantConditions
subscriptions.add(Observable.combineLatest(ViewUtil.getObservableForResId(getContext(), backgroundResId, Aesthetic.get(getContext()).colorAccent()), Aesthetic.get(getContext()).isDark(), ColorIsDarkState.creator()).compose(Rx.<ColorIsDarkState>distinctToMainThread()).subscribe(new Consumer<ColorIsDarkState>() {
@Override
public void accept(@NonNull ColorIsDarkState colorIsDarkState) {
invalidateColors(colorIsDarkState);
}
}, onErrorLogAndRethrow()));
subscriptions.add(Aesthetic.get(getContext()).textColorPrimary().compose(Rx.<Integer>distinctToMainThread()).subscribe(ViewTextColorAction.create(this)));
}
Aggregations