日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

Rxjava 优雅的实现短信验证码发送

發(fā)布時間:2025/4/5 78 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Rxjava 优雅的实现短信验证码发送 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

廢話不多說直接上代碼

private fun countDown() {btn_send_code_activity_login.isEnabled = falsedisPose = Flowable.intervalRange(0,120,0,1,TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).doOnNext {btn_send_code_activity_login.text = String.format(getString(R.string.label_code_time), 120 - it)}.doOnComplete {btn_send_code_activity_login.isEnabled = truebtn_send_code_activity_login.text = getString(R.string.label_get_code)}.`as`(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(this))).subscribe()}

這里利用intervalRange參數(shù)意思如下

/*** Signals a range of long values, the first after some initial delay and the rest periodically after.* <p>* The sequence completes immediately after the last value (start + count - 1) has been reached.* <dl>* <dt><b>Backpressure:</b></dt>* <dd>The operator signals a {@code MissingBackpressureException} if the downstream can't keep up.</dd>* <dt><b>Scheduler:</b></dt>* <dd>{@code intervalRange} by default operates on the {@link Schedulers#computation() computation} {@link Scheduler}.</dd>* </dl>* @param start that start value of the range* @param count the number of values to emit in total, if zero, the operator emits an onComplete after the initial delay.* @param initialDelay the initial delay before signaling the first value (the start)* @param period the period between subsequent values* @param unit the unit of measure of the initialDelay and period amounts* @return the new Flowable instance*/@CheckReturnValue@BackpressureSupport(BackpressureKind.ERROR)@SchedulerSupport(SchedulerSupport.COMPUTATION)public static Flowable<Long> intervalRange(long start, long count, long initialDelay, long period, TimeUnit unit) { return intervalRange(start, count, initialDelay, period, unit, Schedulers.computation());}

總結(jié)

以上是生活随笔為你收集整理的Rxjava 优雅的实现短信验证码发送的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。