本文整理汇总了Java中io.realm.Realm.Transaction方法的典型用法代码示例。如果您正苦于以下问题:Java Realm.Transaction方法的具体用法?Java Realm.Transaction怎么用?Java Realm.Transaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.realm.Realm
的用法示例。
在下文中一共展示了Realm.Transaction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runTransactionSync
import io.realm.Realm; //导入方法依赖的package包/类
public final void runTransactionSync(final Realm.Transaction transaction) {
doWithRealm(new RealmBlock() {
@Override
public void doWithRealm(Realm realm) {
realm.executeTransaction(transaction);
}
});
}
示例2: writeAsync
import io.realm.Realm; //导入方法依赖的package包/类
/**
* Writes asynchronously on a single-threaded execution pool.
*
* @param transaction the Realm transaction
*/
public final void writeAsync(final Realm.Transaction transaction) {
writeScheduler.execute(new Runnable() {
@Override
public void run() {
runTransactionSync(transaction);
}
});
}
示例3: doWrite
import io.realm.Realm; //导入方法依赖的package包/类
private void doWrite(Realm.Transaction transaction) {
Single.create((SingleOnSubscribe<Void>) singleSubscriber -> {
try(Realm r = Realm.getDefaultInstance()) {
r.executeTransaction(transaction);
}
}).subscribeOn(writeScheduler.getScheduler()).subscribe();
}
示例4: executeInTransaction
import io.realm.Realm; //导入方法依赖的package包/类
protected void executeInTransaction(Realm.Transaction callable) {
Realm realm = null;
try {
realm = Realm.getDefaultInstance();
realm.executeTransaction(callable);
} finally {
if (realm != null) {
realm.close();
}
}
}