Java Code Examples for io.reactivex.Observable#takeUntil()

The following examples show how to use io.reactivex.Observable#takeUntil() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BriteDatabaseTest.java    From sqlbrite with Apache License 2.0 6 votes vote down vote up
@Before public void setUp() throws IOException {
  Configuration configuration = Configuration.builder(InstrumentationRegistry.getContext())
      .callback(testDb)
      .name(dbFolder.newFile().getPath())
      .build();

  Factory factory = new FrameworkSQLiteOpenHelperFactory();
  SupportSQLiteOpenHelper helper = factory.create(configuration);
  real = helper.getWritableDatabase();

  SqlBrite.Logger logger = new SqlBrite.Logger() {
    @Override public void log(String message) {
      logs.add(message);
    }
  };
  ObservableTransformer<Query, Query> queryTransformer =
      new ObservableTransformer<Query, Query>() {
        @Override public ObservableSource<Query> apply(Observable<Query> upstream) {
          return upstream.takeUntil(killSwitch);
        }
      };
  db = new BriteDatabase(helper, logger, scheduler, queryTransformer);
}
 
Example 2
Source File: BriteContentResolverTest.java    From sqlbrite with Apache License 2.0 6 votes vote down vote up
@Override protected void setUp() throws Exception {
  super.setUp();
  contentResolver = getMockContentResolver();

  SqlBrite.Logger logger = new SqlBrite.Logger() {
    @Override public void log(String message) {
      logs.add(message);
    }
  };
  ObservableTransformer<Query, Query> queryTransformer =
      new ObservableTransformer<Query, Query>() {
        @Override public ObservableSource<Query> apply(Observable<Query> upstream) {
          return upstream.takeUntil(killSwitch);
        }
      };
  db = new BriteContentResolver(contentResolver, logger, scheduler, queryTransformer);

  getProvider().init(getContext().getContentResolver());
}
 
Example 3
Source File: RxAutoCleanDelegate.java    From BaseProject with MIT License 5 votes vote down vote up
/**
 * 绑定一个 Activity、Fragment 的生命周期,自动释放资源
 * <br/>
 * 例如:网络请求时绑定{@link ActivityEvent#STOP} 或 {@link FragmentEvent#STOP},
 * onStop()时会自动取消网络请求.
 *
 * @param event 事件类型
 * @see ActivityEvent
 * @see FragmentEvent
 */
@Override
public <Type> ObservableTransformer<Type, Type> bindEvent(final int event) {
    final Observable<Integer> observable = mBehaviorSubject.filter(new Predicate<Integer>() {
        @Override public boolean test(Integer integer) throws Exception {
            return integer == event;
        }
    }).take(1);
    return new ObservableTransformer<Type, Type>() {
        @Override public ObservableSource<Type> apply(Observable<Type> upstream) {
            return upstream.takeUntil(observable);
        }
    };
}
 
Example 4
Source File: RxAutoCleanDelegate.java    From BaseProject with MIT License 5 votes vote down vote up
/**
 * 绑定一个 Activity、Fragment 的生命周期,自动释放资源
 * <br/>
 * 例如:网络请求时绑定{@link ActivityEvent#STOP} 或 {@link FragmentEvent#STOP},
 * onStop()时会自动取消网络请求.
 *
 * @param event 事件类型
 * @see ActivityEvent
 * @see FragmentEvent
 */
@Override
public <Type> ObservableTransformer<Type, Type> bindEvent(final int event) {
    final Observable<Integer> observable = mBehaviorSubject.filter(new Predicate<Integer>() {
        @Override public boolean test(Integer integer) throws Exception {
            return integer == event;
        }
    }).take(1);
    return new ObservableTransformer<Type, Type>() {
        @Override public ObservableSource<Type> apply(Observable<Type> upstream) {
            return upstream.takeUntil(observable);
        }
    };
}
 
Example 5
Source File: LifecycleTransformer.java    From Tangram-Android with MIT License 4 votes vote down vote up
@Override
public ObservableSource<T> apply(Observable<T> upstream) {
    return upstream.takeUntil(mObservable);
}
 
Example 6
Source File: LifecycleTransformer.java    From Tangram-Android with MIT License 4 votes vote down vote up
@Override
public ObservableSource<T> apply(Observable<T> upstream) {
    return upstream.takeUntil(mObservable);
}
 
Example 7
Source File: LifecycleTransformer.java    From Tangram-Android with MIT License 4 votes vote down vote up
@Override
public ObservableSource<T> apply(Observable<T> upstream) {
    return upstream.takeUntil(mObservable);
}
 
Example 8
Source File: RxLifecycleTransformer.java    From pandroid with Apache License 2.0 4 votes vote down vote up
@Override
public ObservableSource<T> apply(Observable<T> upstream) {
    return upstream.takeUntil(mObservable);
}
 
Example 9
Source File: LifecycleTransformer.java    From recyclerview-binder with Apache License 2.0 4 votes vote down vote up
@Override
public ObservableSource<T> apply(Observable<T> upstream) {
    return upstream.takeUntil(observable);
}