Created
May 2, 2015 13:46
-
-
Save rghwang/bc707d879c637c8d7233 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Func1<OnTextChangeEvent, Boolean> isNotEmpty = t -> t.text().length() != 0; | |
rx.Observable.combineLatest( | |
WidgetObservable.text(mNameTextView).map(isNotEmpty), | |
WidgetObservable.text(mCompanyTextView).map(isNotEmpty), | |
WidgetObservable.text(mTitleTextView).map(isNotEmpty), | |
(a, b, c) -> a && b && c | |
).subscribe(result -> { | |
Button btn = ((SignUpActivity) getActivity()).mDoneBtn; | |
if (result) { | |
btn.getBackground().setColorFilter(getResources().getColor(R.color.accent), PorterDuff.Mode.MULTIPLY); | |
} else { | |
btn.getBackground().clearColorFilter(); | |
} | |
btn.setEnabled(result); | |
} | |
); | |
Observable.combineLatest( | |
WidgetObservable.text(mNameTextView).map(isNotEmpty), | |
Observable.create(new Observable.OnSubscribe<Boolean>() { | |
@Override | |
public void call(final Subscriber<? super Boolean> subscriber) { | |
mNameTextView.setOnFocusChangeListener((v, hasFocus) -> { | |
if (subscriber.isUnsubscribed()) return; | |
subscriber.onNext(hasFocus); | |
}); | |
} | |
}), | |
(a, b) -> a && b ? View.VISIBLE : View.INVISIBLE | |
).subscribe( | |
mNameClearBtn::setVisibility | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment