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