| | |
| | | private val cardBannerAdapter by lazy { BgmBannerAdapter(list,this) } |
| | | private val fromPrivacy by lazy { intent.getBooleanExtra("fromPrivacy",false) } //从私人定制过来,设置完成需要发送停止引导的事件 |
| | | private val player by lazy { AudioUtils() } |
| | | private var isSilent = false //true:bgm静音 |
| | | |
| | | override fun initClick() { |
| | | iv_back.setOnClickListener { finish() } |
| | | iv_silent.setOnClickListener { |
| | | sb_voice.progress = 0 |
| | | } |
| | | banner_landscape.setOnBannerListener { data, position -> |
| | | banner_landscape.setOnBannerListener { _, position -> |
| | | cardBannerAdapter.playPosition = position |
| | | cardBannerAdapter.notifyDataSetChanged() |
| | | player.startPlayMusic(this,list[position].audioFile) |
| | |
| | | } |
| | | }) |
| | | |
| | | sb_silent.setOnClickListener { |
| | | isSilent = !isSilent |
| | | sb_silent.setImageResource(if (!isSilent) R.mipmap.sw_on else R.mipmap.sw_off) |
| | | } |
| | | |
| | | tv_action.setOnClickListener { |
| | | //存音量 |
| | | SPUtils.instance().put(Const.User.VOLUME,sb_voice.progress).apply() |
| | | if (list.isNotEmpty()){ //存bgm和bg |
| | | SPUtils.instance().put(Const.User.BG,list[banner_landscape.currentItem].imageUrl) |
| | | .put(Const.User.BGM,list[banner_landscape.currentItem].audioFile).apply() |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.CHANGE_BGM)) |
| | | tv_action.isEnabled = false |
| | | HttpManager.saveUserHomeBackgroundMusic(list[banner_landscape.currentItem].id).request(this,success = {_,_-> |
| | | //存音量 |
| | | // SPUtils.instance().put(Const.User.VOLUME,sb_voice.progress).apply() |
| | | SPUtils.instance().put(Const.User.VOLUME,if (isSilent) 0 else 50).apply() |
| | | SPUtils.instance().put(Const.User.BG,list[banner_landscape.currentItem].imageUrl) |
| | | .put(Const.User.BGM,list[banner_landscape.currentItem].audioFile).apply() |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.CHANGE_BGM)) |
| | | toast("保存成功") |
| | | startActivity<MainActivity>() |
| | | }){_,_-> |
| | | tv_action.isEnabled = true |
| | | } |
| | | } |
| | | toast("保存成功") |
| | | startActivity<MainActivity>() |
| | | if (fromPrivacy) |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.FINISH_GUIDE_AUDIO)) |
| | | } |
| | |
| | | banner_landscape.setBannerGalleryEffect(110,12,0.85f) |
| | | player.setOnAudioStatusUpdateListener(this) |
| | | sb_voice.progress = SPUtils.instance().getInt(Const.User.VOLUME,50) |
| | | player.setVolume(sb_voice.progress.toFloat()/100) |
| | | isSilent = SPUtils.instance().getInt(Const.User.VOLUME,50) == 0 |
| | | sb_silent.setImageResource(if (!isSilent) R.mipmap.sw_on else R.mipmap.sw_off) |
| | | // player.setVolume(sb_voice.progress.toFloat()/100) |
| | | getData() |
| | | } |
| | | |
| | |
| | | val indexOf = list.map { it.audioFile }.indexOf(bgm) |
| | | if (indexOf>=0){ |
| | | banner_landscape.currentItem = indexOf |
| | | }else if (list.size>2){ |
| | | banner_landscape.currentItem = 1 |
| | | } |
| | | cardBannerAdapter.notifyDataSetChanged() |
| | | } |