| | |
| | | import cn.sinata.xldutils.invisible |
| | | import cn.sinata.xldutils.utils.ellipsize |
| | | import cn.sinata.xldutils.visible |
| | | import com.google.android.exoplayer2.upstream.DataSpec |
| | | import com.google.android.exoplayer2.upstream.RawResourceDataSource |
| | | import com.sinata.xqmuse.MainActivity |
| | | import com.sinata.xqmuse.R |
| | | import com.sinata.xqmuse.ThinkAudioService |
| | | import com.sinata.xqmuse.network.HttpManager |
| | | import com.sinata.xqmuse.network.entity.* |
| | | import com.sinata.xqmuse.network.requestByF |
| | |
| | | iv_privacy.setOnClickListener { |
| | | startActivity<GuideActivity>() |
| | | } |
| | | iv_guide.setOnClickListener { |
| | | tv_3.setOnClickListener { |
| | | HttpManager.getH5(4).requestByF(this){ _, data-> |
| | | data?.let { |
| | | startActivity<H5Activity>("title" to "新手冥想指南","url" to it.content) |
| | |
| | | if (today!=null){ |
| | | if (today?.isShow == 1){ //跳转播放微电影 |
| | | startActivity<MicroVideoActivity>("url" to today?.meditationVideo?.videoUrl,"title" to today?.meditationVideo?.title) |
| | | }else if (MainActivity.voice?.id == today?.meditationId){ |
| | | }else if (ThinkAudioService.voice?.id == today?.meditationId){ |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.PAUSE_OR_RESUME_THINK)) |
| | | if (MainActivity.playing) //播放中 |
| | | if (ThinkAudioService.playing) //播放中 |
| | | iv_play_today.setImageResource(R.mipmap.player_pause) |
| | | else |
| | | iv_play_today.setImageResource(R.mipmap.play) |
| | |
| | | }else if (data?.chargeType == 3&&data.isBuy != 1){ //单独收费且未购买 |
| | | startActivity<BuyVoiceActivity>("id" to data.id) |
| | | }else{ |
| | | if (MainActivity.playing) |
| | | if (ThinkAudioService.playing) |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.FINISH_THINK)) |
| | | MainActivity.voice = data |
| | | ThinkAudioService.voice = data |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_THINK)) |
| | | } |
| | | }){_,_-> |
| | |
| | | player.release() |
| | | player.gone() |
| | | iv_home.visible() |
| | | }else{ |
| | | iv_home.invisible() |
| | | player.visible() |
| | | player.release() |
| | | //ExoPlayer |
| | | val dataSpec = DataSpec(RawResourceDataSource.buildRawResourceUri(R.raw.default_bg)) |
| | | val rawResourceDataSource = RawResourceDataSource(requireContext()) |
| | | try { |
| | | rawResourceDataSource.open(dataSpec) |
| | | } catch (e: RawResourceDataSource.RawResourceDataSourceException) { |
| | | e.printStackTrace() |
| | | } |
| | | val url = rawResourceDataSource.uri.toString() |
| | | player.setUrl(url) |
| | | player.setLooping(true) |
| | | player.start() |
| | | } |
| | | } |
| | | |
| | |
| | | HttpManager.getTodayMeditation().requestByF(this){_,data-> |
| | | today = data |
| | | if (data?.isShow == 0){ |
| | | tv_1.text = "每日疗愈" |
| | | tv_sub_1.text = "Daily Meditation" |
| | | if (today?.clientMeditationVO?.backgroundUrl.isNullOrEmpty()){ |
| | | iv_daily_empty.visible() |
| | | }else{ |
| | |
| | | tv_today_count.text = "${(today?.clientMeditationVO?.realLearnedNum?:0)+(today?.clientMeditationVO?.virtualLearnedNum?:0)}人已参加学习" |
| | | } |
| | | }else{ |
| | | tv_1.text = "泉疗愈 微电影" |
| | | tv_sub_1.text = "Spring Healing Microfilm" |
| | | if (today?.meditationVideo?.videoUrl.isNullOrEmpty()){ |
| | | iv_daily_empty.visible() |
| | | }else{ |
| | |
| | | } |
| | | |
| | | fun refreshTodayPlayingState(){ |
| | | if (MainActivity.voice?.id == today?.meditationId&&MainActivity.playing) |
| | | if (ThinkAudioService.voice?.id == today?.meditationId&&ThinkAudioService.playing) |
| | | iv_play_today.setImageResource(R.mipmap.player_pause) |
| | | else |
| | | iv_play_today.setImageResource(R.mipmap.play) |