Created
February 29, 2020 17:32
-
-
Save lawloretienne/ee8fc5a8f375355c5ee58bd2a51c7ade to your computer and use it in GitHub Desktop.
PasswordChangeObservable
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
Subscription passwordSubscription = | |
passwordChangeObservable | |
.doOnNext(new Action1<CharSequence>() { | |
@Override | |
public void call(CharSequence charSequence) { | |
hidePasswordError(); | |
} | |
}) | |
.debounce(400, TimeUnit.MILLISECONDS) | |
.filter(new Func1<CharSequence, Boolean>() { | |
@Override | |
public Boolean call(CharSequence charSequence) { | |
return !TextUtils.isEmpty(charSequence); | |
} | |
}) | |
.observeOn(AndroidSchedulers.mainThread()) // UI Thread | |
.subscribe(new Subscriber<CharSequence>() { | |
@Override | |
public void onCompleted() { | |
} | |
@Override | |
public void onError(Throwable e) { | |
e.printStackTrace(); | |
} | |
@Override | |
public void onNext(CharSequence charSequence) { | |
boolean isPasswordValid = validatePassword(charSequence.toString()); | |
if (!isPasswordValid) { | |
showPasswordError(); | |
} else { | |
hidePasswordError(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment