本文整理匯總了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();
}
}
}