• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TimeInterval类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中rx.schedulers.TimeInterval的典型用法代码示例。如果您正苦于以下问题:Java TimeInterval类的具体用法?Java TimeInterval怎么用?Java TimeInterval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TimeInterval类属于rx.schedulers包,在下文中一共展示了TimeInterval类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: call

import rx.schedulers.TimeInterval; //导入依赖的package包/类
public Subscriber<? super T> call(final Subscriber<? super TimeInterval<T>> subscriber) {
    return new Subscriber<T>(subscriber) {
        private long lastTimestamp = OperatorTimeInterval.this.scheduler.now();

        public void onNext(T args) {
            long nowTimestamp = OperatorTimeInterval.this.scheduler.now();
            subscriber.onNext(new TimeInterval(nowTimestamp - this.lastTimestamp, args));
            this.lastTimestamp = nowTimestamp;
        }

        public void onCompleted() {
            subscriber.onCompleted();
        }

        public void onError(Throwable e) {
            subscriber.onError(e);
        }
    };
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:OperatorTimeInterval.java


示例2: startTimer

import rx.schedulers.TimeInterval; //导入依赖的package包/类
private void startTimer() {
    updateDisplayTime();
    videoTimerSubscription = Observable.interval(1, TimeUnit.SECONDS).timeInterval()
            .compose(DatabaseUtils.<TimeInterval<Long>>applySchedulers())
            .subscribe(new Action1<TimeInterval<Long>>() {
                @Override
                public void call(TimeInterval<Long> longTimeInterval) {
                    updateDisplayTime();
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    Log.e(LOG_TAG, "Timer error", throwable);
                }
            });
}
 
开发者ID:MimiReader,项目名称:mimi-reader,代码行数:17,代码来源:GalleryWebmFragment.java


示例3: call

import rx.schedulers.TimeInterval; //导入依赖的package包/类
@Override
public Subscriber<? super T> call(final Subscriber<? super TimeInterval<T>> subscriber) {
    return new Subscriber<T>(subscriber) {

        // The beginning time is the time when the observer subscribes.
        private long lastTimestamp = scheduler.now();


        @Override
        public void onNext(T args) {
            long nowTimestamp = scheduler.now();
            subscriber.onNext(new TimeInterval<T>(nowTimestamp - lastTimestamp, args));
            lastTimestamp = nowTimestamp;
        }

        @Override
        public void onComplete() {
            subscriber.onComplete();
        }

        @Override
        public void onError(Throwable e) {
            subscriber.onError(e);
        }
    };
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:27,代码来源:OperatorTimeInterval.java


示例4: testTimeInterval

import rx.schedulers.TimeInterval; //导入依赖的package包/类
@Test
public void testTimeInterval() {
    InOrder inOrder = inOrder(observer);
    observable.subscribe(observer);

    testScheduler.advanceTimeBy(1000, TIME_UNIT);
    subject.onNext(1);
    testScheduler.advanceTimeBy(2000, TIME_UNIT);
    subject.onNext(2);
    testScheduler.advanceTimeBy(3000, TIME_UNIT);
    subject.onNext(3);
    subject.onComplete();

    inOrder.verify(observer, times(1)).onNext(
            new TimeInterval<Integer>(1000, 1));
    inOrder.verify(observer, times(1)).onNext(
            new TimeInterval<Integer>(2000, 2));
    inOrder.verify(observer, times(1)).onNext(
            new TimeInterval<Integer>(3000, 3));
    inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:23,代码来源:OperatorTimeIntervalTest.java


示例5: call

import rx.schedulers.TimeInterval; //导入依赖的package包/类
@Override
public Subscriber<? super T> call(final Subscriber<? super TimeInterval<T>> subscriber) {
    return new Subscriber<T>(subscriber) {

        // The beginning time is the time when the observer subscribes.
        private long lastTimestamp = scheduler.now();


        @Override
        public void onNext(T args) {
            long nowTimestamp = scheduler.now();
            subscriber.onNext(new TimeInterval<T>(nowTimestamp - lastTimestamp, args));
            lastTimestamp = nowTimestamp;
        }

        @Override
        public void onCompleted() {
            subscriber.onCompleted();
        }

        @Override
        public void onError(Throwable e) {
            subscriber.onError(e);
        }
    };
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:27,代码来源:OperatorTimeInterval.java


示例6: runCode

import rx.schedulers.TimeInterval; //导入依赖的package包/类
public void runCode() {

        //将一个Observable转换为发射两个数据之间所耗费时间的Observable

        Observable<Long> values = Observable.interval(100, TimeUnit.MILLISECONDS);
        values.take(3)
                .timeInterval()
                .subscribe(new Action1<TimeInterval>() {
                    @Override
                    public void call(TimeInterval mTimeInterval) {
                        println(mTimeInterval.toString());
                    }
                });

    }
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:16,代码来源:Fragment_TimeInterval.java


示例7: collectTapSequence

import rx.schedulers.TimeInterval; //导入依赖的package包/类
Observable.Transformer<Void, List<TimeInterval<Void>>> collectTapSequence() {
	return observable -> observable
			.observeOn(Schedulers.io())
			.doOnNext(clickEvent -> Timber.d("tap"))
			.timeInterval()
			.skip(1)
			.timeout(timeInterval -> Observable.timer(1500, TimeUnit.MILLISECONDS), Observable.empty())
			.toList()
			.observeOn(AndroidSchedulers.mainThread());
}
 
开发者ID:egineering-llc,项目名称:secretknock,代码行数:11,代码来源:MainActivity.java


示例8: initializeRecorder

import rx.schedulers.TimeInterval; //导入依赖的package包/类
private void initializeRecorder() {
	clickSubscription = RxView.clicks(recordingMessage)
			.compose(collectTapSequence())
			.subscribe(new Subscriber<List<TimeInterval<Void>>>() {
				@Override
				public void onCompleted() {
					Timber.v("tapsSubscriber onCompleted");
				}

				@Override
				public void onError(Throwable e) {
					Timber.v(e, "ruh roh");
				}

				@Override
				public void onNext(List<TimeInterval<Void>> durations) {
					Timber.v("onNext");

					if (patternIsValid(durations)) {
						storePattern(durations);
						activateLock();
					} else {
						Timber.v("pattern invalid");
						Toast.makeText(MainActivity.this, R.string.pattern_invalid, Toast.LENGTH_SHORT).show();
						Handler handler = new Handler();
						handler.post(()-> initializeRecorder());
					}

				}
			}
	);

}
 
开发者ID:egineering-llc,项目名称:secretknock,代码行数:34,代码来源:MainActivity.java


示例9: initializeTapToUnlock

import rx.schedulers.TimeInterval; //导入依赖的package包/类
public void initializeTapToUnlock() {
	clickSubscription = RxView.clicks(hiddenMessage)
			.doOnNext(clickEvent -> {
				Timber.v("unlock tap");
				showBorderAnimation();
			})
			.compose(collectTapSequence())
			.subscribe(new Subscriber<List<TimeInterval<Void>>>() {
				@Override
				public void onCompleted() {
					hideBorderAnimation();
				}

				@Override
				public void onError(Throwable e) {
					Timber.v(e, "ruh roh");
				}

				@Override
				public void onNext(List<TimeInterval<Void>> durations) {
					Timber.v("onNext");

					if (patternMatches(durations)) {
						Timber.v("lock deactivated");
						deactivateLock();
					} else {
						Timber.v("pattern incorrect");
						Toast.makeText(MainActivity.this, R.string.pattern_incorrect, Toast.LENGTH_SHORT).show();
						hiddenMessage.setBackgroundResource(R.drawable.message_background);
						Handler handler = new Handler();
						handler.post(()-> initializeTapToUnlock());
					}

				}
			});

}
 
开发者ID:egineering-llc,项目名称:secretknock,代码行数:38,代码来源:MainActivity.java


示例10: patternMatches

import rx.schedulers.TimeInterval; //导入依赖的package包/类
private boolean patternMatches(List<TimeInterval<Void>> durations) {
	Long[] durationArray = convertTimeIntervalsToLongs(durations);

	List<Long> storedPattern = retrievePattern();
	Timber.v("storedPattern: %s", storedPattern.toString());
	Timber.v("enteredPattern: %s", durations.toString());
	if (durations.size() != storedPattern.size()) {
		Timber.v("patterns not same number of taps");
		return false;
	}

	// scale entered pattern to be same length as stored pattern
	Long totalStoredPatternDuration = 0L;
	Long totalEnteredPatternDuration = 0L;
	for (int i = 0; i < storedPattern.size(); i++) {
		totalStoredPatternDuration += storedPattern.get(i);
		totalEnteredPatternDuration += durationArray[i];
	}
	double scalingFactor = (double) totalStoredPatternDuration / (double) totalEnteredPatternDuration;

	// check stored pattern versus scaled pattern
	for (int i = 0; i < storedPattern.size(); i++) {
		Timber.v("stored:%s entered:%s scaled:%s", storedPattern.get(i), durations.get(i), Math.round(scalingFactor * durationArray[i]));
		if (Math.abs(storedPattern.get(i) - Math.round(scalingFactor * durationArray[i])) > ALLOWED_ERROR) {
			return false;
		}
	}

	return true;
}
 
开发者ID:egineering-llc,项目名称:secretknock,代码行数:31,代码来源:MainActivity.java


示例11: convertTimeIntervalsToLongs

import rx.schedulers.TimeInterval; //导入依赖的package包/类
private Long[] convertTimeIntervalsToLongs(List<TimeInterval<Void>> durations) {
	Long[] durationArray = new Long[durations.size()];
	for (int i = 0; i < durations.size(); i++) {
		durationArray[i] = durations.get(i).getIntervalInMilliseconds();
	}
	return durationArray;
}
 
开发者ID:egineering-llc,项目名称:secretknock,代码行数:8,代码来源:MainActivity.java


示例12: timedObservable

import rx.schedulers.TimeInterval; //导入依赖的package包/类
/**
 * creates an observable that emits object with time between
 */
public static Observable timedObservable(int delay,TimeUnit timeUnit, final Observable delayedObservable) {

  Observable<TimeInterval<Long>> timer = Observable.interval(delay, timeUnit).timeInterval();
  return Observable.zip(timer, delayedObservable, new Func2() {
    @Override public Object call(Object o, Object o2) {
      return o2;
    }
  });
}
 
开发者ID:Dmedina88,项目名称:ShilaFlux,代码行数:13,代码来源:RxUtil.java


示例13: timeInterval

import rx.schedulers.TimeInterval; //导入依赖的package包/类
public final ParallelObservable<TimeInterval<T>> timeInterval() {
	return create(new Func1<Observable<T>, Observable<TimeInterval<T>>>() {
		@Override
		public Observable<TimeInterval<T>> call(Observable<T> o) {
			return o.timeInterval();
		}
	});
}
 
开发者ID:davidmoten,项目名称:rxjava-parallel,代码行数:9,代码来源:ParallelObservable.java


示例14: timeInterval

import rx.schedulers.TimeInterval; //导入依赖的package包/类
public final Observable<TimeInterval<T>> timeInterval() {
    return timeInterval(Schedulers.immediate());
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:Observable.java


示例15: patternIsValid

import rx.schedulers.TimeInterval; //导入依赖的package包/类
private boolean patternIsValid(List<TimeInterval<Void>> durations) {
	return durations.size() > 1;
}
 
开发者ID:egineering-llc,项目名称:secretknock,代码行数:4,代码来源:MainActivity.java


示例16: storePattern

import rx.schedulers.TimeInterval; //导入依赖的package包/类
private void storePattern(List<TimeInterval<Void>> durations) {
	Long[] durationArray = convertTimeIntervalsToLongs(durations);
	editor.putString(DURATIONS, TextUtils.join(",", durationArray)).apply();
	Timber.v("Pattern stored.");
}
 
开发者ID:egineering-llc,项目名称:secretknock,代码行数:6,代码来源:MainActivity.java


示例17: timeInterval

import rx.schedulers.TimeInterval; //导入依赖的package包/类
/**
 * @return
 * @see rx.Observable#timeInterval()
 */
public final Observable<TimeInterval<T>> timeInterval() {
    return boxed.timeInterval();
}
 
开发者ID:aol,项目名称:cyclops,代码行数:8,代码来源:ObservableKind.java



注:本文中的rx.schedulers.TimeInterval类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java QueueUserACLInfoProtoOrBuilder类代码示例发布时间:2022-05-22
下一篇:
Java EV3IRSensor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap