Commit 2bff1ec8 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Bump Realm version to 4.2.0, remove RxJavaInterop library

parent 0d0e4556
...@@ -120,7 +120,6 @@ dependencies { ...@@ -120,7 +120,6 @@ dependencies {
compile rxbindingDependencies.rxBinding compile rxbindingDependencies.rxBinding
compile rxbindingDependencies.rxBindingSupport compile rxbindingDependencies.rxBindingSupport
compile rxbindingDependencies.rxBindingAppcompact compile rxbindingDependencies.rxBindingAppcompact
compile "com.github.akarnokd:rxjava2-interop:0.11.0"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion" compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion"
compile "com.google.firebase:firebase-core:$playLibVersion" compile "com.google.firebase:firebase-core:$playLibVersion"
compile "com.google.firebase:firebase-crash:$playLibVersion" compile "com.google.firebase:firebase-crash:$playLibVersion"
...@@ -145,7 +144,7 @@ dependencies { ...@@ -145,7 +144,7 @@ dependencies {
testCompile "org.jetbrains.kotlin:kotlin-test:$rootProject.ext.kotlinVersion" testCompile "org.jetbrains.kotlin:kotlin-test:$rootProject.ext.kotlinVersion"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$rootProject.ext.kotlinVersion" testCompile "org.jetbrains.kotlin:kotlin-test-junit:$rootProject.ext.kotlinVersion"
testCompile "org.jetbrains.kotlin:kotlin-reflect:$rootProject.ext.kotlinVersion" testCompile "org.jetbrains.kotlin:kotlin-reflect:$rootProject.ext.kotlinVersion"
testCompile "com.nhaarman:mockito-kotlin:1.1.0" testCompile "com.nhaarman:mockito-kotlin:1.5.0"
testCompile 'org.amshove.kluent:kluent:1.14' testCompile 'org.amshove.kluent:kluent:1.14'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
...@@ -17,7 +17,7 @@ buildscript { ...@@ -17,7 +17,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.60" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.60"
classpath 'io.realm:realm-gradle-plugin:2.3.2' classpath 'io.realm:realm-gradle-plugin:4.2.0'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1' classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'com.google.gms:google-services:3.0.0' classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.github.triplet.gradle:play-publisher:1.1.5' classpath 'com.github.triplet.gradle:play-publisher:1.1.5'
......
...@@ -16,8 +16,6 @@ public class RealmStore { ...@@ -16,8 +16,6 @@ public class RealmStore {
.modules(new RocketChatLibraryModule()) .modules(new RocketChatLibraryModule())
.migration(new Migration()) .migration(new Migration())
.schemaVersion(6) .schemaVersion(6)
// Just in case
.deleteRealmIfMigrationNeeded()
.build(); .build();
} }
...@@ -49,7 +47,6 @@ public class RealmStore { ...@@ -49,7 +47,6 @@ public class RealmStore {
sStore.put(name, new RealmConfiguration.Builder() sStore.put(name, new RealmConfiguration.Builder()
.name(name + ".realm") .name(name + ".realm")
.modules(new RocketChatServerModule()) .modules(new RocketChatServerModule())
.deleteRealmIfMigrationNeeded()
.build()); .build());
} }
return new RealmHelper(sStore.get(name)); return new RealmHelper(sStore.get(name));
......
...@@ -12,7 +12,6 @@ import chat.rocket.core.models.LoginServiceConfiguration; ...@@ -12,7 +12,6 @@ import chat.rocket.core.models.LoginServiceConfiguration;
import chat.rocket.core.repositories.LoginServiceConfigurationRepository; import chat.rocket.core.repositories.LoginServiceConfigurationRepository;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmMeteorLoginServiceConfiguration; import chat.rocket.persistence.realm.models.ddp.RealmMeteorLoginServiceConfiguration;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -36,10 +35,10 @@ public class RealmLoginServiceConfigurationRepository extends RealmRepository ...@@ -36,10 +35,10 @@ public class RealmLoginServiceConfigurationRepository extends RealmRepository
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmMeteorLoginServiceConfiguration.class) return pair.first.where(RealmMeteorLoginServiceConfiguration.class)
.equalTo(RealmMeteorLoginServiceConfiguration.SERVICE, serviceName) .equalTo(RealmMeteorLoginServiceConfiguration.SERVICE, serviceName)
.findAll() .findAll()
.<RealmResults<RealmMeteorLoginServiceConfiguration>>asObservable()); .<RealmResults<RealmMeteorLoginServiceConfiguration>>asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
...@@ -58,9 +57,9 @@ public class RealmLoginServiceConfigurationRepository extends RealmRepository ...@@ -58,9 +57,9 @@ public class RealmLoginServiceConfigurationRepository extends RealmRepository
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmMeteorLoginServiceConfiguration.class) return pair.first.where(RealmMeteorLoginServiceConfiguration.class)
.findAll() .findAll()
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -17,7 +17,6 @@ import chat.rocket.persistence.realm.RealmHelper; ...@@ -17,7 +17,6 @@ import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmMessage; import chat.rocket.persistence.realm.models.ddp.RealmMessage;
import chat.rocket.persistence.realm.models.ddp.RealmUser; import chat.rocket.persistence.realm.models.ddp.RealmUser;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -42,10 +41,10 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe ...@@ -42,10 +41,10 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmMessage.class) return pair.first.where(RealmMessage.class)
.equalTo(RealmMessage.ID, messageId) .equalTo(RealmMessage.ID, messageId)
.findAll() .findAll()
.<RealmResults<RealmMessage>>asObservable()); .<RealmResults<RealmMessage>>asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
...@@ -112,10 +111,10 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe ...@@ -112,10 +111,10 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
realm.beginTransaction(); realm.beginTransaction();
return RxJavaInterop.toV2Flowable(realm.where(RealmMessage.class) return realm.where(RealmMessage.class)
.equalTo(RealmMessage.ID, message.getId()) .equalTo(RealmMessage.ID, message.getId())
.findAll() .findAll()
.<RealmResults<RealmMessage>>asObservable()) .<RealmResults<RealmMessage>>asFlowable()
.filter(realmObject -> realmObject.isLoaded() && realmObject.isValid()) .filter(realmObject -> realmObject.isLoaded() && realmObject.isValid())
.firstElement() .firstElement()
.toSingle() .toSingle()
...@@ -140,13 +139,13 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe ...@@ -140,13 +139,13 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmMessage.class) return pair.first.where(RealmMessage.class)
.notEqualTo(RealmMessage.SYNC_STATE, SyncState.DELETE_NOT_SYNCED) .notEqualTo(RealmMessage.SYNC_STATE, SyncState.DELETE_NOT_SYNCED)
.notEqualTo(RealmMessage.SYNC_STATE, SyncState.DELETING) .notEqualTo(RealmMessage.SYNC_STATE, SyncState.DELETING)
.equalTo(RealmMessage.ROOM_ID, room.getRoomId()) .equalTo(RealmMessage.ROOM_ID, room.getRoomId())
.isNotNull(RealmMessage.USER) .isNotNull(RealmMessage.USER)
.findAllSorted(RealmMessage.TIMESTAMP, Sort.DESCENDING) .findAllSorted(RealmMessage.TIMESTAMP, Sort.DESCENDING)
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
...@@ -165,12 +164,12 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe ...@@ -165,12 +164,12 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmMessage.class) return pair.first.where(RealmMessage.class)
.equalTo(RealmMessage.ROOM_ID, room.getId()) .equalTo(RealmMessage.ROOM_ID, room.getId())
.greaterThanOrEqualTo(RealmMessage.TIMESTAMP, room.getLastSeen()) .greaterThanOrEqualTo(RealmMessage.TIMESTAMP, room.getLastSeen())
.notEqualTo(RealmMessage.USER_ID, user.getId()) .notEqualTo(RealmMessage.USER_ID, user.getId())
.findAll() .findAll()
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -9,7 +9,6 @@ import chat.rocket.core.models.Permission; ...@@ -9,7 +9,6 @@ import chat.rocket.core.models.Permission;
import chat.rocket.core.repositories.PermissionRepository; import chat.rocket.core.repositories.PermissionRepository;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmPermission; import chat.rocket.persistence.realm.models.ddp.RealmPermission;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -31,10 +30,10 @@ public class RealmPermissionRepository extends RealmRepository implements Permis ...@@ -31,10 +30,10 @@ public class RealmPermissionRepository extends RealmRepository implements Permis
if (pair.first == null) { if (pair.first == null) {
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmPermission.class) return pair.first.where(RealmPermission.class)
.equalTo(RealmPermission.Columns.ID, id) .equalTo(RealmPermission.Columns.ID, id)
.findAll() .findAll()
.<RealmResults<RealmPermission>>asObservable()); .<RealmResults<RealmPermission>>asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -9,7 +9,6 @@ import chat.rocket.core.models.PublicSetting; ...@@ -9,7 +9,6 @@ import chat.rocket.core.models.PublicSetting;
import chat.rocket.core.repositories.PublicSettingRepository; import chat.rocket.core.repositories.PublicSettingRepository;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmPublicSetting; import chat.rocket.persistence.realm.models.ddp.RealmPublicSetting;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -32,10 +31,10 @@ public class RealmPublicSettingRepository extends RealmRepository ...@@ -32,10 +31,10 @@ public class RealmPublicSettingRepository extends RealmRepository
if (pair.first == null) { if (pair.first == null) {
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmPublicSetting.class) return pair.first.where(RealmPublicSetting.class)
.equalTo(RealmPublicSetting.ID, id) .equalTo(RealmPublicSetting.ID, id)
.findAll() .findAll()
.<RealmResults<RealmPublicSetting>>asObservable()); .<RealmResults<RealmPublicSetting>>asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -16,7 +16,6 @@ import chat.rocket.persistence.realm.RealmHelper; ...@@ -16,7 +16,6 @@ import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmRoom; import chat.rocket.persistence.realm.models.ddp.RealmRoom;
import chat.rocket.persistence.realm.models.internal.LoadMessageProcedure; import chat.rocket.persistence.realm.models.internal.LoadMessageProcedure;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -42,9 +41,9 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito ...@@ -42,9 +41,9 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmRoom.class) return pair.first.where(RealmRoom.class)
.findAll() .findAll()
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
...@@ -71,7 +70,7 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito ...@@ -71,7 +70,7 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
return Flowable.just(Optional.<RealmRoom>absent()); return Flowable.just(Optional.<RealmRoom>absent());
} }
return RxJavaInterop.toV2Flowable(realmRoom.<RealmRoom>asObservable()) return realmRoom.<RealmRoom>asFlowable()
.filter( .filter(
roomSubscription -> roomSubscription.isLoaded() roomSubscription -> roomSubscription.isLoaded()
&& roomSubscription.isValid()) && roomSubscription.isValid())
...@@ -106,7 +105,7 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito ...@@ -106,7 +105,7 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
return Flowable.just(Optional.<LoadMessageProcedure>absent()); return Flowable.just(Optional.<LoadMessageProcedure>absent());
} }
return RxJavaInterop.toV2Flowable(messageProcedure.<LoadMessageProcedure>asObservable()) return messageProcedure.<LoadMessageProcedure>asFlowable()
.filter(loadMessageProcedure -> loadMessageProcedure.isLoaded() .filter(loadMessageProcedure -> loadMessageProcedure.isLoaded()
&& loadMessageProcedure.isValid()) && loadMessageProcedure.isValid())
.map(Optional::of); .map(Optional::of);
...@@ -157,7 +156,7 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito ...@@ -157,7 +156,7 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
if (pair.first == null) { if (pair.first == null) {
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmRoom.class) return pair.first.where(RealmRoom.class)
.like(RealmRoom.NAME, "*" + name + "*", Case.INSENSITIVE) .like(RealmRoom.NAME, "*" + name + "*", Case.INSENSITIVE)
.beginGroup() .beginGroup()
.equalTo(RealmRoom.TYPE, RealmRoom.TYPE_CHANNEL) .equalTo(RealmRoom.TYPE, RealmRoom.TYPE_CHANNEL)
...@@ -166,7 +165,7 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito ...@@ -166,7 +165,7 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
.endGroup() .endGroup()
.findAllSorted(RealmRoom.NAME, .findAllSorted(RealmRoom.NAME,
direction.equals(SortDirection.ASC) ? Sort.ASCENDING : Sort.DESCENDING) direction.equals(SortDirection.ASC) ? Sort.ASCENDING : Sort.DESCENDING)
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
...@@ -184,14 +183,14 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito ...@@ -184,14 +183,14 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
if (pair.first == null) { if (pair.first == null) {
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmRoom.class) return pair.first.where(RealmRoom.class)
.beginGroup() .beginGroup()
.equalTo(RealmRoom.TYPE, RealmRoom.TYPE_CHANNEL) .equalTo(RealmRoom.TYPE, RealmRoom.TYPE_CHANNEL)
.or() .or()
.equalTo(RealmRoom.TYPE, RealmRoom.TYPE_PRIVATE) .equalTo(RealmRoom.TYPE, RealmRoom.TYPE_PRIVATE)
.endGroup() .endGroup()
.findAllSorted(RealmRoom.LAST_SEEN, Sort.ASCENDING) .findAllSorted(RealmRoom.LAST_SEEN, Sort.ASCENDING)
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -12,7 +12,6 @@ import chat.rocket.core.repositories.RoomRoleRepository; ...@@ -12,7 +12,6 @@ import chat.rocket.core.repositories.RoomRoleRepository;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmRoomRole; import chat.rocket.persistence.realm.models.ddp.RealmRoomRole;
import chat.rocket.persistence.realm.models.ddp.RealmUser; import chat.rocket.persistence.realm.models.ddp.RealmUser;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -34,11 +33,11 @@ public class RealmRoomRoleRepository extends RealmRepository implements RoomRole ...@@ -34,11 +33,11 @@ public class RealmRoomRoleRepository extends RealmRepository implements RoomRole
if (pair.first == null) { if (pair.first == null) {
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmRoomRole.class) return pair.first.where(RealmRoomRole.class)
.equalTo(RealmRoomRole.Columns.ROOM_ID, room.getId()) .equalTo(RealmRoomRole.Columns.ROOM_ID, room.getId())
.equalTo(RealmRoomRole.Columns.USER + "." + RealmUser.ID, user.getId()) .equalTo(RealmRoomRole.Columns.USER + "." + RealmUser.ID, user.getId())
.findAll() .findAll()
.<RealmResults<RealmRoomRole>>asObservable()); .<RealmResults<RealmRoomRole>>asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -8,7 +8,6 @@ import com.hadisatrio.optional.Optional; ...@@ -8,7 +8,6 @@ import com.hadisatrio.optional.Optional;
import chat.rocket.core.models.ServerInfo; import chat.rocket.core.models.ServerInfo;
import chat.rocket.core.repositories.ServerInfoRepository; import chat.rocket.core.repositories.ServerInfoRepository;
import chat.rocket.persistence.realm.models.RealmBasedServerInfo; import chat.rocket.persistence.realm.models.RealmBasedServerInfo;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -27,7 +26,7 @@ public class RealmServerInfoRepository extends RealmRepository implements Server ...@@ -27,7 +26,7 @@ public class RealmServerInfoRepository extends RealmRepository implements Server
return Flowable.just(Optional.<RealmBasedServerInfo>absent()); return Flowable.just(Optional.<RealmBasedServerInfo>absent());
} }
return RxJavaInterop.toV2Flowable(info.<RealmBasedServerInfo>asObservable()) return info.<RealmBasedServerInfo>asFlowable()
.filter(it -> it.isLoaded() && it.isValid()) .filter(it -> it.isLoaded() && it.isValid())
.map(Optional::of); .map(Optional::of);
}, },
......
...@@ -10,7 +10,6 @@ import chat.rocket.core.repositories.SessionRepository; ...@@ -10,7 +10,6 @@ import chat.rocket.core.repositories.SessionRepository;
import chat.rocket.persistence.realm.RealmHelper; import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.internal.RealmSession; import chat.rocket.persistence.realm.models.internal.RealmSession;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -33,10 +32,10 @@ public class RealmSessionRepository extends RealmRepository implements SessionRe ...@@ -33,10 +32,10 @@ public class RealmSessionRepository extends RealmRepository implements SessionRe
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmSession.class) return pair.first.where(RealmSession.class)
.equalTo(RealmSession.ID, id) .equalTo(RealmSession.ID, id)
.findAll() .findAll()
.<RealmSession>asObservable().first()); .<RealmSession>asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -6,7 +6,6 @@ import chat.rocket.core.repositories.SpotlightRepository ...@@ -6,7 +6,6 @@ import chat.rocket.core.repositories.SpotlightRepository
import chat.rocket.persistence.realm.RealmStore import chat.rocket.persistence.realm.RealmStore
import chat.rocket.persistence.realm.models.ddp.RealmSpotlight import chat.rocket.persistence.realm.models.ddp.RealmSpotlight
import chat.rocket.persistence.realm.models.ddp.RealmSpotlight.Columns import chat.rocket.persistence.realm.models.ddp.RealmSpotlight.Columns
import hu.akarnokd.rxjava.interop.RxJavaInterop
import io.reactivex.Flowable import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.realm.Realm import io.realm.Realm
...@@ -24,9 +23,9 @@ class RealmSpotlightRepository(private val hostname: String) : RealmRepository() ...@@ -24,9 +23,9 @@ class RealmSpotlightRepository(private val hostname: String) : RealmRepository()
return@using Flowable.empty() return@using Flowable.empty()
} }
return@using RxJavaInterop.toV2Flowable(pair.first.where(RealmSpotlight::class.java) return@using pair.first.where(RealmSpotlight::class.java)
.findAllSorted(Columns.TYPE, Sort.DESCENDING) .findAllSorted(Columns.TYPE, Sort.DESCENDING)
.asObservable()) .asFlowable()
}) { pair -> close(pair.first, pair.second) } }) { pair -> close(pair.first, pair.second) }
.unsubscribeOn(AndroidSchedulers.from(Looper.myLooper()!!)) .unsubscribeOn(AndroidSchedulers.from(Looper.myLooper()!!))
.filter { realmSpotlightResults -> realmSpotlightResults.isLoaded && realmSpotlightResults.isValid } .filter { realmSpotlightResults -> realmSpotlightResults.isLoaded && realmSpotlightResults.isValid }
......
...@@ -12,7 +12,6 @@ import chat.rocket.core.repositories.SpotlightRoomRepository; ...@@ -12,7 +12,6 @@ import chat.rocket.core.repositories.SpotlightRoomRepository;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmRoom; import chat.rocket.persistence.realm.models.ddp.RealmRoom;
import chat.rocket.persistence.realm.models.ddp.RealmSpotlightRoom; import chat.rocket.persistence.realm.models.ddp.RealmSpotlightRoom;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.realm.Case; import io.realm.Case;
...@@ -35,7 +34,7 @@ public class RealmSpotlightRoomRepository extends RealmRepository implements Spo ...@@ -35,7 +34,7 @@ public class RealmSpotlightRoomRepository extends RealmRepository implements Spo
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmSpotlightRoom.class) return pair.first.where(RealmSpotlightRoom.class)
.like(RealmSpotlightRoom.Columns.NAME, "*" + name + "*", Case.INSENSITIVE) .like(RealmSpotlightRoom.Columns.NAME, "*" + name + "*", Case.INSENSITIVE)
.beginGroup() .beginGroup()
.equalTo(RealmSpotlightRoom.Columns.TYPE, RealmRoom.TYPE_CHANNEL) .equalTo(RealmSpotlightRoom.Columns.TYPE, RealmRoom.TYPE_CHANNEL)
...@@ -43,7 +42,7 @@ public class RealmSpotlightRoomRepository extends RealmRepository implements Spo ...@@ -43,7 +42,7 @@ public class RealmSpotlightRoomRepository extends RealmRepository implements Spo
.equalTo(RealmSpotlightRoom.Columns.TYPE, RealmRoom.TYPE_PRIVATE) .equalTo(RealmSpotlightRoom.Columns.TYPE, RealmRoom.TYPE_PRIVATE)
.endGroup() .endGroup()
.findAllSorted(RealmSpotlightRoom.Columns.NAME, direction.equals(SortDirection.ASC) ? Sort.ASCENDING : Sort.DESCENDING) .findAllSorted(RealmSpotlightRoom.Columns.NAME, direction.equals(SortDirection.ASC) ? Sort.ASCENDING : Sort.DESCENDING)
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -11,7 +11,6 @@ import chat.rocket.core.models.SpotlightUser; ...@@ -11,7 +11,6 @@ import chat.rocket.core.models.SpotlightUser;
import chat.rocket.core.repositories.SpotlightUserRepository; import chat.rocket.core.repositories.SpotlightUserRepository;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmSpotlightUser; import chat.rocket.persistence.realm.models.ddp.RealmSpotlightUser;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.realm.Case; import io.realm.Case;
...@@ -34,7 +33,7 @@ public class RealmSpotlightUserRepository extends RealmRepository implements Spo ...@@ -34,7 +33,7 @@ public class RealmSpotlightUserRepository extends RealmRepository implements Spo
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmSpotlightUser.class) return pair.first.where(RealmSpotlightUser.class)
.beginGroup() .beginGroup()
.like(RealmSpotlightUser.Columns.USERNAME, "*" + name + "*", Case.INSENSITIVE) .like(RealmSpotlightUser.Columns.USERNAME, "*" + name + "*", Case.INSENSITIVE)
.isNull(RealmSpotlightUser.Columns.NAME) .isNull(RealmSpotlightUser.Columns.NAME)
...@@ -46,7 +45,7 @@ public class RealmSpotlightUserRepository extends RealmRepository implements Spo ...@@ -46,7 +45,7 @@ public class RealmSpotlightUserRepository extends RealmRepository implements Spo
.endGroup() .endGroup()
.findAllSorted(RealmSpotlightUser.Columns.USERNAME, .findAllSorted(RealmSpotlightUser.Columns.USERNAME,
direction.equals(SortDirection.ASC) ? Sort.ASCENDING : Sort.DESCENDING) direction.equals(SortDirection.ASC) ? Sort.ASCENDING : Sort.DESCENDING)
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second) pair -> close(pair.first, pair.second)
) )
......
...@@ -12,7 +12,6 @@ import chat.rocket.core.models.User; ...@@ -12,7 +12,6 @@ import chat.rocket.core.models.User;
import chat.rocket.core.repositories.UserRepository; import chat.rocket.core.repositories.UserRepository;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.models.ddp.RealmUser; import chat.rocket.persistence.realm.models.ddp.RealmUser;
import hu.akarnokd.rxjava.interop.RxJavaInterop;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.realm.Case; import io.realm.Case;
...@@ -36,9 +35,9 @@ public class RealmUserRepository extends RealmRepository implements UserReposito ...@@ -36,9 +35,9 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmUser.class) return pair.first.where(RealmUser.class)
.findAll() .findAll()
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second)) pair -> close(pair.first, pair.second))
.unsubscribeOn(AndroidSchedulers.from(Looper.myLooper())) .unsubscribeOn(AndroidSchedulers.from(Looper.myLooper()))
...@@ -70,10 +69,10 @@ public class RealmUserRepository extends RealmRepository implements UserReposito ...@@ -70,10 +69,10 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmUser.class) return pair.first.where(RealmUser.class)
.isNotEmpty(RealmUser.EMAILS) .isNotEmpty(RealmUser.EMAILS)
.findAll() .findAll()
.<RealmResults<RealmUser>>asObservable()); .<RealmResults<RealmUser>>asFlowable();
}, },
pair -> close(pair.first, pair.second)); pair -> close(pair.first, pair.second));
} }
...@@ -112,7 +111,7 @@ public class RealmUserRepository extends RealmRepository implements UserReposito ...@@ -112,7 +111,7 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
return Flowable.just(Optional.absent()); return Flowable.just(Optional.absent());
} }
return RxJavaInterop.toV2Flowable(realmUser.<RealmUser>asObservable()) return realmUser.<RealmUser>asFlowable()
.filter(user -> user.isLoaded() && user.isValid()) .filter(user -> user.isLoaded() && user.isValid())
.map(Optional::of); .map(Optional::of);
} }
...@@ -135,10 +134,10 @@ public class RealmUserRepository extends RealmRepository implements UserReposito ...@@ -135,10 +134,10 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
return Flowable.empty(); return Flowable.empty();
} }
return RxJavaInterop.toV2Flowable(pair.first.where(RealmUser.class) return pair.first.where(RealmUser.class)
.like(RealmUser.USERNAME, "*" + name + "*", Case.INSENSITIVE) .like(RealmUser.USERNAME, "*" + name + "*", Case.INSENSITIVE)
.findAllSorted(RealmUser.USERNAME, Sort.DESCENDING) .findAllSorted(RealmUser.USERNAME, Sort.DESCENDING)
.asObservable()); .asFlowable();
}, },
pair -> close(pair.first, pair.second)); pair -> close(pair.first, pair.second));
} }
......
...@@ -5,9 +5,8 @@ apply plugin: 'java' ...@@ -5,9 +5,8 @@ apply plugin: 'java'
dependencies { dependencies {
compile extraDependencies.rxJava compile extraDependencies.rxJava
compile extraDependencies.optional compile extraDependencies.optional
compile "com.github.akarnokd:rxjava2-interop:0.11.0"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion" compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion"
compile 'com.google.code.findbugs:jsr305:3.0.1' compile 'com.google.code.findbugs:jsr305:3.0.2'
compileOnly 'com.google.auto.value:auto-value:1.3' compileOnly 'com.google.auto.value:auto-value:1.3'
kapt 'com.google.auto.value:auto-value:1.3' kapt 'com.google.auto.value:auto-value:1.3'
kapt 'com.gabrielittner.auto.value:auto-value-with:1.0.0' kapt 'com.gabrielittner.auto.value:auto-value-with:1.0.0'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment