@@ -123,12 +123,7 @@ public User getUserSync() {
123
123
124
124
public void clearUserData () {
125
125
Realm realm = Realm .getDefaultInstance ();
126
- realm .executeTransaction (new Realm .Transaction () {
127
- @ Override
128
- public void execute (Realm realm ) {
129
- realm .delete (User .class );
130
- }
131
- });
126
+ realm .executeTransaction (realm1 -> realm1 .delete (User .class ));
132
127
realm .close ();
133
128
}
134
129
@@ -555,14 +550,15 @@ public RealmResults<SessionType> getSessionTypesSync() {
555
550
556
551
/**
557
552
* Saves Event Dates Synchronously
558
- * TODO : Use threaded asynchronous transaction using separate Realm instance
559
553
* @param eventDates List of dates of entire event span (inclusive)
560
554
*/
561
555
private void saveEventDatesInRealm (List <EventDates > eventDates ) {
562
- realm .beginTransaction ();
563
- realm .delete (EventDates .class );
564
- realm .insert (eventDates );
565
- realm .commitTransaction ();
556
+ Realm realm = Realm .getDefaultInstance ();
557
+ realm .executeTransaction (transaction -> {
558
+ transaction .delete (EventDates .class );
559
+ transaction .insertOrUpdate (eventDates );
560
+ });
561
+ realm .close ();
566
562
}
567
563
568
564
public Completable saveEventDates (List <EventDates > eventDates ) {
@@ -637,7 +633,7 @@ public static <K extends RealmObject> LiveRealmDataObject<K> asLiveDataForObject
637
633
* Convert RealmResults to FilterableRealmLiveData
638
634
*/
639
635
public static <K extends RealmObject > FilterableRealmLiveData <K > asFilterableLiveData (RealmResults <K > data ) {
640
- return new FilterableRealmLiveData <K >(data );
636
+ return new FilterableRealmLiveData <>(data );
641
637
}
642
638
643
639
/**
0 commit comments