use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method dynamicRealmResults_emittedOnSubscribe.
@Test
@UiThreadTest
public void dynamicRealmResults_emittedOnSubscribe() {
final DynamicRealm dynamicRealm = DynamicRealm.getInstance(realm.getConfiguration());
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
final RealmResults<DynamicRealmObject> results = dynamicRealm.where(AllTypes.CLASS_NAME).findAll();
subscription = results.asObservable().subscribe(new Action1<RealmResults<DynamicRealmObject>>() {
@Override
public void call(RealmResults<DynamicRealmObject> rxResults) {
assertTrue(rxResults == results);
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
dynamicRealm.close();
subscription.unsubscribe();
}
use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method realmResults_emittedOnSubscribe.
@Test
@UiThreadTest
public void realmResults_emittedOnSubscribe() {
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
final RealmResults<AllTypes> results = realm.where(AllTypes.class).findAll();
subscription = results.asObservable().subscribe(new Action1<RealmResults<AllTypes>>() {
@Override
public void call(RealmResults<AllTypes> rxResults) {
assertTrue(rxResults == results);
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.unsubscribe();
}
use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method findFirst_emittedOnSubscribe.
@Test
@UiThreadTest
public void findFirst_emittedOnSubscribe() {
realm.beginTransaction();
realm.createObject(AllTypes.class).setColumnLong(42);
realm.commitTransaction();
final AtomicBoolean subscribedNotified = new AtomicBoolean(false);
subscription = realm.where(AllTypes.class).equalTo(AllTypes.FIELD_LONG, 42).findFirst().<AllTypes>asObservable().subscribe(new Action1<AllTypes>() {
@Override
public void call(AllTypes rxObject) {
subscribedNotified.set(true);
}
});
assertTrue(subscribedNotified.get());
subscription.unsubscribe();
}
use of rx.functions.Action1 in project realm-java by realm.
the class RxJavaTests method findFirstAsync_emittedOnDelete.
@Test
@RunTestInLooperThread
public void findFirstAsync_emittedOnDelete() {
final AtomicInteger subscriberCalled = new AtomicInteger(0);
final Realm realm = looperThread.realm;
realm.beginTransaction();
final AllTypes obj = realm.createObject(AllTypes.class);
realm.commitTransaction();
subscription = realm.where(AllTypes.class).findFirstAsync().<AllTypes>asObservable().subscribe(new Action1<AllTypes>() {
@Override
public void call(final AllTypes rxObject) {
switch(subscriberCalled.incrementAndGet()) {
case 1:
assertFalse(rxObject.isLoaded());
break;
case 2:
assertTrue(rxObject.isLoaded());
assertTrue(rxObject.isValid());
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.delete(AllTypes.class);
}
});
break;
case 3:
assertTrue(rxObject.isLoaded());
assertFalse(rxObject.isValid());
looperThread.testComplete();
break;
default:
fail();
}
}
});
}
use of rx.functions.Action1 in project SongkickInterview by pakoito.
the class SongkickDetailsActivity method navigateToUrl.
@Override
public Action1<String> navigateToUrl() {
return new Action1<String>() {
@Override
public void call(String url) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
}
};
}
Aggregations