use of io.realm.internal.Capabilities in project realm-java by realm.
the class RealmCache method doCreateRealmOrGetFromCacheAsync.
private synchronized <T extends BaseRealm> RealmAsyncTask doCreateRealmOrGetFromCacheAsync(RealmConfiguration configuration, BaseRealm.InstanceCallback<T> callback, Class<T> realmClass) {
Capabilities capabilities = new AndroidCapabilities();
capabilities.checkCanDeliverNotification(ASYNC_NOT_ALLOWED_MSG);
// noinspection ConstantConditions
if (callback == null) {
throw new IllegalArgumentException(ASYNC_CALLBACK_NULL_MSG);
}
// If there is no Realm file it means that we need to sync the initial remote data in the worker thread.
if (configuration.isSyncConfiguration() && !configuration.realmExists()) {
pendingRealmFileCreation.add(configuration.getPath());
}
// Always create a Realm instance in the background thread even when there are instances existing on current
// thread. This to ensure that onSuccess will always be called in the following event loop but not current one.
CreateRealmRunnable<T> createRealmRunnable = new CreateRealmRunnable<T>(new AndroidRealmNotifier(null, capabilities), configuration, callback, realmClass);
Future<?> future = BaseRealm.asyncTaskExecutor.submitTransaction(createRealmRunnable);
createRealmRunnable.setFuture(future);
// For Realms using Async Open on the server, we need to create the session right away
// in order to interact with it in a imperative way, e.g. by attaching download progress
// listeners
ObjectServerFacade.getSyncFacadeIfPossible().createNativeSyncSession(configuration);
return new RealmAsyncTaskImpl(future, BaseRealm.asyncTaskExecutor);
}
Aggregations