Skip to content

Commit

Permalink
Add sorting in getone and fix null value
Browse files Browse the repository at this point in the history
  • Loading branch information
tspoke committed Mar 30, 2017
1 parent d3880c1 commit e575273
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ public final Observable<T> getOne(Filter filter, SortingMode sortingMode) {

RealmQuery<T> query = realm.where(clazz);
query = filterToQuery(filter, query);
T item = query.findFirst();
RealmResults<T> items = query.findAllSorted(sortingMode.key, convertToSort(sortingMode.sort));
T item = items.first();

T copy = null;
if(item != null) {
realm.copyFromRealm(item);
copy = realm.copyFromRealm(item);
}
realm.close();

return Observable.just(copy);
}

Expand Down

0 comments on commit e575273

Please sign in to comment.