Java 类android.databinding.ObservableLong 实例源码

项目:Cinder    文件:CinderLongUnitTest.java   
@Test
public void takeTakesCorrectTimes() throws Exception {
    long long1 = 123;
    long long2 = 32;
    ObservableLong observed = new ObservableLong(long1);
    ObservableLong observing = Cinder.computeLong(()->
                    observed.get()
            , observed).take(2).immediate();
    assertTrue(observing.get() == long1);

    observed.set(long2);
    assertTrue(observing.get() == long2);

    observed.set(long1);
    assertTrue(observing.get() == long2);
}
项目:Cinder    文件:CinderLongUnitTest.java   
@Test
public void skipSkipsCorrectTimes() throws Exception {
    long long1 = 123;
    long long2 = 32;
    ObservableLong observed = new ObservableLong();
    ObservableLong observing = Cinder.computeLong(()->
                    observed.get()
            , observed).skip(1);

    observed.set(long1);
    assertTrue(observing.get() == 0);

    observed.set(long2);
    assertTrue(observing.get() == long2);

    observed.set(long1);
    assertTrue(observing.get() == long1);
}
项目:RxDataBinding    文件:ObservableLongObservable.java   
Listener(final ObservableLong observableLong, final Observer<? super Long> observer) {
  this.observableLong = observableLong;
  this.onPropertyChangedCallback =
      new android.databinding.Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(android.databinding.Observable observable,
            int ignoredPropertyId) {
          if (!isDisposed()) {
            ObservableLong observableLong = (ObservableLong) observable;
            observer.onNext(observableLong.get());
          }
        }
      };
}
项目:Cinder    文件:CinderUnitTest.java   
@Test
public void computesLong() throws Exception {
    long long1 = 432;
    long long2 = 123415;
    ObservableLong obsLong = new ObservableLong(long1);
    ObservableLong computedLong = Cinder.computeLong(()->obsLong.get(), obsLong).immediate();
    assertEquals(computedLong.get(), long1);

    obsLong.set(long2);
    assertEquals(computedLong.get(), long2);
}
项目:Cinder    文件:CinderLongUnitTest.java   
@Test
public void onceTakesOnce() throws Exception {
    long long1 = 123;
    long long2 = 43;
    ObservableLong observed = new ObservableLong(long1);
    ObservableLong observing = Cinder.computeLong(()->
            observed.get(), observed).once().immediate();
    assertTrue(observing.get() == long1);

    observed.set(long2);
    assertTrue(observing.get() == long1);
}
项目:Cinder    文件:CinderLongUnitTest.java   
@Test
public void filterFilters() throws Exception {
    long long1 = 123;
    long long2 = 32;
    ObservableLong observed = new ObservableLong();
    ObservableLong observing = Cinder.computeLong(()->
                    observed.get()
            , observed).filter(()->observed.get() == long1);

    observed.set(long2);
    assertTrue(observing.get() == 0);

    observed.set(long1);
    assertTrue(observing.get() == long1);
}
项目:Cinder    文件:CinderLongUnitTest.java   
@Test
public void takeWhileTakesWhileTrue() throws Exception {
    long long1 = 123;
    long long2 = 32;
    ObservableLong observed = new ObservableLong();
    ObservableLong observing = Cinder.computeLong(()->
                    observed.get()
            , observed).takeWhile(()->observed.get() == long1);

    observed.set(long1);
    assertTrue(observing.get() == long1);

    observed.set(long2);
    assertTrue(observing.get() == long1);
}
项目:Cinder    文件:CinderLongUnitTest.java   
@Test
public void skipWhileSkipsWhileTrue() throws Exception {
    long long1 = 123;
    long long2 = 32;
    ObservableLong observed = new ObservableLong();
    ObservableLong observing = Cinder.computeLong(()->
                    observed.get()
            , observed).skipWhile(()->observed.get() == long1);

    observed.set(long1);
    assertTrue(observing.get() == 0);

    observed.set(long2);
    assertTrue(observing.get() == long2);
}
项目:Cinder    文件:CinderLongUnitTest.java   
@Test
public void withDefaultAssignsDefault() throws Exception {
    long long1 = 12;
    ObservableLong observing = Cinder.computeLong(()->0
    ).withDefault(long1);

    assertTrue(observing.get() == long1);
}
项目:Cinder    文件:CinderLongUnitTest.java   
@Test
public void stopStops() throws Exception {
    long long1 = 123;
    long long2 = 43;
    ObservableLong observed = new ObservableLong(long1);
    CinderLong observing = Cinder.computeLong(()->
            observed.get(), observed).immediate();
    assertTrue(observing.get() == long1);

    observing.stop();

    observed.set(long2);
    assertTrue(observing.get() == long1);
}
项目:Cinder    文件:RxCinderUnitTest.java   
@Test
public void convertsObservableLongToRx() throws Exception {
    ObservableLong observableLong = new ObservableLong();
    Observable<Long> rxLong = RxCinder.convert(observableLong);

    final String TEST_KEY = "TEST_KEY";
    final ArrayMap<String, Long> testMap = new ArrayMap<>();
    rxLong.subscribe((c)->{
        testMap.put(TEST_KEY, c);});

    final long TEST_LONG = 23;
    observableLong.set(TEST_LONG);
    assertTrue(testMap.get(TEST_KEY).equals(TEST_LONG));
}
项目:Cinder    文件:RxCinderUnitTest.java   
@Test
public void convertsRxLongToObservable() throws Exception {
    long TEST_LONG = 234;
    Observable<Long> rxLong = Observable.just(TEST_LONG);
    ObservableLong observableLong = RxCinder.convertLong(rxLong);
    assertTrue(observableLong.get() == TEST_LONG);
}
项目:RxDataBinding    文件:ObservableLongObservable.java   
ObservableLongObservable(ObservableLong observableLong) {
  this.observableLong = observableLong;
}
项目:Cinder    文件:RxCinder.java   
public static Observable<Long> convert(ObservableLong observableLong){
    return Observable.create((e)->
        Cinder.observe(()->e.onNext(observableLong.get()), observableLong)
    );
}
项目:Cinder    文件:RxCinder.java   
public static ObservableLong convertLong(Observable<Long> observable){
    ObservableLong observableLong = new ObservableLong();
    observable.subscribe((l)->observableLong.set(l));
    return observableLong;
}
项目:PainlessMusicPlayer    文件:NowPlayingActivityModel.java   
@NonNull
public ObservableLong getElapsedTime() {
    return mElapsedTime;
}
项目:RxDataBinding    文件:RxObservableLong.java   
/**
 * Create an observable of property change events on {@code observableLong}.
 * <p>
 * <em>Warning:</em> The created observable keeps a strong reference to {@code observableLong}.
 * Unsubscribe to free this reference.
 */
@CheckResult @NonNull //
public static Observable<Long> propertyChanges(@NonNull ObservableLong observableLong) {
  checkNotNull(observableLong, "observableLong == null");
  return new ObservableLongObservable(observableLong);
}