crash nullable getValue fix

This commit is contained in:
Gavriil Sitnikov 2017-04-17 21:05:20 +03:00
parent 0e06e1a9ac
commit d20dd6daa4
1 changed files with 4 additions and 4 deletions

View File

@ -60,7 +60,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
* Call it on parent's onStart method. * Call it on parent's onStart method.
*/ */
public void onStart() { public void onStart() {
if (!isStartedSubject.getValue()) { if (isStartedSubject.hasValue() && !isStartedSubject.getValue()) {
isStartedSubject.onNext(true); isStartedSubject.onNext(true);
} }
} }
@ -71,7 +71,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
* In that case onResume will be called after onSaveInstanceState so lifecycle object is becoming started. * In that case onResume will be called after onSaveInstanceState so lifecycle object is becoming started.
*/ */
public void onResume() { public void onResume() {
if (!isStartedSubject.getValue()) { if (isStartedSubject.hasValue() && !isStartedSubject.getValue()) {
isStartedSubject.onNext(true); isStartedSubject.onNext(true);
} }
} }
@ -80,7 +80,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
* Call it on parent's onSaveInstanceState method. * Call it on parent's onSaveInstanceState method.
*/ */
public void onSaveInstanceState() { public void onSaveInstanceState() {
if (isStartedSubject.getValue()) { if (isStartedSubject.hasValue() && isStartedSubject.getValue()) {
isStartedSubject.onNext(false); isStartedSubject.onNext(false);
} }
} }
@ -89,7 +89,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
* Call it on parent's onStop method. * Call it on parent's onStop method.
*/ */
public void onStop() { public void onStop() {
if (isStartedSubject.getValue()) { if (isStartedSubject.hasValue() && isStartedSubject.getValue()) {
isStartedSubject.onNext(false); isStartedSubject.onNext(false);
} }
} }