本文主要是介绍RxJava常用操作符 Observable.fromIterable,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import io.reactivex.Observable
val bannerItemData: ArrayList<HomeBean.Issue.Item> = mData.take(bannerItemSize).toCollection(ArrayList())val bannerFeedList = ArrayList<String>()val bannerTitleList = ArrayList<String>()//取出banner 显示的 img 和 TitleObservable.fromIterable(bannerItemData).subscribe { list ->bannerFeedList.add(list.data?.cover?.feed ?: "")bannerTitleList.add(list.data?.title ?: "")}//设置 bannerwith(holder) {getView<BGABanner>(R.id.banner).run {setAutoPlayAble(bannerFeedList.size > 1)setData(bannerFeedList, bannerTitleList)setAdapter { banner, _, feedImageUrl, position ->GlideApp.with(mContext).load(feedImageUrl).transition(DrawableTransitionOptions().crossFade()).placeholder(R.drawable.placeholder_banner).into(banner.getItemImageView(position))}}}//没有使用到的参数在 kotlin 中用"_"代替holder.getView<BGABanner>(R.id.banner).setDelegate { _, imageView, _, i ->goToVideoPlayer(mContext as Activity, imageView, bannerItemData[i])}
这篇关于RxJava常用操作符 Observable.fromIterable的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!