日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

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

廢話不多說直接上代碼

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參數意思如下

/*** 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());}

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。