-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] App crash when Adding notification timer with empty name
- Loading branch information
Showing
2 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
base/src/main/java/m/co/rh/id/a_flash_deck/base/rx/SerialBehaviorSubject.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package m.co.rh.id.a_flash_deck.base.rx; | ||
|
||
import java.io.IOException; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.io.Serializable; | ||
|
||
import io.reactivex.rxjava3.subjects.BehaviorSubject; | ||
|
||
public class SerialBehaviorSubject<E extends Serializable> implements Serializable { | ||
private transient BehaviorSubject<E> mSubject; | ||
|
||
public SerialBehaviorSubject() { | ||
mSubject = BehaviorSubject.create(); | ||
} | ||
|
||
public SerialBehaviorSubject(E element) { | ||
mSubject = BehaviorSubject.createDefault(element); | ||
} | ||
|
||
public BehaviorSubject<E> getSubject() { | ||
return mSubject; | ||
} | ||
|
||
public E getValue() { | ||
return mSubject.getValue(); | ||
} | ||
|
||
public void onNext(E element) { | ||
mSubject.onNext(element); | ||
} | ||
|
||
private void writeObject(ObjectOutputStream out) throws IOException { | ||
out.writeObject(mSubject.getValue()); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { | ||
E element = (E) in.readObject(); | ||
if (element == null) { | ||
mSubject = BehaviorSubject.create(); | ||
} else { | ||
mSubject = BehaviorSubject.createDefault(element); | ||
} | ||
} | ||
} |
This file contains 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