| | |
| | | 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.ui.login.LoginActivity |
| | | import com.sinata.xqmuse.ui.mine.VipActivity |
| | | import com.sinata.xqmuse.utils.Const |
| | | import com.sinata.xqmuse.utils.cache.ProxyVideoCacheManager |
| | | import com.sinata.xqmuse.utils.event.EmptyEvent |
| | | import com.sinata.xqmuse.utils.interfaces.StringCallback |
| | | import kotlinx.android.synthetic.main.fragment_home.* |
| | |
| | | adapter.callback = object :StringCallback{ |
| | | override fun onResult(rst: String) { |
| | | showDialog() |
| | | HttpManager.getMeditationDetails(rst).requestByF(this@HomeFragment,success = {_,data-> |
| | | HttpManager.getMeditationDetails(rst).requestByF( |
| | | this@HomeFragment, |
| | | success = { _, data -> |
| | | dismissDialog() |
| | | data?.goDetail(requireContext()) |
| | | }){_,_-> |
| | |
| | | startActivity<BGMSettingActivity>() |
| | | } |
| | | topMenuAdapter.setOnItemClickListener { view, position -> |
| | | startActivity<TypeVoiceActivity>("title" to topMenu[position].categoryName,"id" to topMenu[position].id) |
| | | startActivity<TypeVoiceActivity>( |
| | | "title" to topMenu[position].categoryName, |
| | | "id" to topMenu[position].id |
| | | ) |
| | | } |
| | | iv_today.setOnClickListener { |
| | | if (today!=null){ |
| | | if (today?.isShow == 1){ //跳转播放微电影 |
| | | startActivity<MicroVideoActivity>("url" to today?.meditationVideo?.videoUrl,"title" to today?.meditationVideo?.title) |
| | | startActivity<MicroVideoActivity>( |
| | | "url" to today?.meditationVideo?.videoUrl, |
| | | "title" to today?.meditationVideo?.title |
| | | ) |
| | | }else if (ThinkAudioService.voice?.id == today?.meditationId){ |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.PAUSE_OR_RESUME_THINK)) |
| | | if (ThinkAudioService.playing) //播放中 |
| | |
| | | iv_play_today.setImageResource(R.mipmap.play) |
| | | }else{ |
| | | showDialog() |
| | | HttpManager.getMeditationDetails(today!!.meditationId).requestByF(this,success = {_,data-> |
| | | HttpManager.getMeditationDetails(today!!.meditationId).requestByF( |
| | | this, |
| | | success = { _, data -> |
| | | dismissDialog() |
| | | if (data?.chargeType == 2&&data.isVip != 1){ //会员免费 |
| | | startActivity<VipActivity>() |
| | |
| | | startActivity<BuyVoiceActivity>("id" to data.id) |
| | | }else{ |
| | | if (ThinkAudioService.playing) |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.FINISH_THINK)) |
| | | EventBus.getDefault() |
| | | .post(EmptyEvent(Const.EventCode.FINISH_THINK)) |
| | | ThinkAudioService.voice = data |
| | | EventBus.getDefault().post(EmptyEvent(Const.EventCode.START_THINK)) |
| | | } |
| | |
| | | } |
| | | banner_privacy.setOnBannerListener { data, position -> |
| | | showDialog() |
| | | HttpManager.getMeditationDetails(privacy[position].id).requestByF(this,success = {_,data-> |
| | | HttpManager.getMeditationDetails(privacy[position].id).requestByF( |
| | | this, |
| | | success = { _, data -> |
| | | dismissDialog() |
| | | data?.goDetail(requireContext()) |
| | | }){_,_-> |
| | |
| | | iv_home.invisible() |
| | | player.visible() |
| | | player.release() |
| | | player.setUrl(video) |
| | | val cacheServer = ProxyVideoCacheManager.getProxy(context) |
| | | val proxyUrl = cacheServer.getProxyUrl(video) |
| | | player.setUrl(proxyUrl) |
| | | player.setLooping(true) |
| | | player.start() |
| | | } else if (bg.isNotEmpty()){ |
| | |
| | | }else{ |
| | | iv_daily_empty.gone() |
| | | iv_today.setImageURI(today?.imageUrl) |
| | | tv_length_today.text = "${today?.clientMeditationVO?.meditationTitle?.ellipsize(12)} | ${"%02d:%02d".format((data?.time?:0)/60,(data?.time?:0)%60)}" |
| | | tv_length_today.text = "${today?.clientMeditationVO?.meditationTitle?.ellipsize( |
| | | 12 |
| | | )} | ${"%02d:%02d".format((data?.time ?: 0) / 60, (data?.time ?: 0) % 60)}" |
| | | tv_today_count.text = "${(today?.clientMeditationVO?.realLearnedNum?:0)+(today?.clientMeditationVO?.virtualLearnedNum?:0)}人已参加学习" |
| | | } |
| | | }else{ |
| | |
| | | }else{ |
| | | iv_daily_empty.gone() |
| | | iv_today.setImageURI(today?.meditationVideo?.imageUrl) |
| | | tv_length_today.text = "${today?.meditationVideo?.title?.ellipsize(18)} | ${"%02d:%02d".format((today?.meditationVideo?.videoSecond?:0)/60,(today?.meditationVideo?.videoSecond?:0)%60)}" |
| | | tv_length_today.text = "${today?.meditationVideo?.title?.ellipsize(18)} | ${"%02d:%02d".format( |
| | | (today?.meditationVideo?.videoSecond ?: 0) / 60, |
| | | (today?.meditationVideo?.videoSecond ?: 0) % 60 |
| | | )}" |
| | | tv_today_count.text = "" |
| | | } |
| | | } |