Commit f17e2613 by 范玉宾

meditation time off by rx

parent a5f63d1f
package com.yidianling.home package com.yidianling.home
import android.content.Context import android.content.Context
import android.content.Intent
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.launcher.ARouter
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.home.model.MeditationTypeModel
import com.yidianling.home.model.bean.MeditationModuleBean import com.yidianling.home.model.bean.MeditationModuleBean
class MeditationTypeAdapter( class MeditationTypeAdapter(
private val context: Context, private val context: Context,
private val data: List<MeditationModuleBean.MeditationDetail> private val data: List<MeditationModuleBean.MeditationDetail>,
private val meditationType:Int
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { ) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
...@@ -31,7 +35,6 @@ class MeditationTypeAdapter( ...@@ -31,7 +35,6 @@ class MeditationTypeAdapter(
LayoutInflater.from(context) LayoutInflater.from(context)
.inflate(R.layout.layout_meditation_more_type, parent, false) .inflate(R.layout.layout_meditation_more_type, parent, false)
) )
} }
} }
...@@ -50,6 +53,12 @@ class MeditationTypeAdapter( ...@@ -50,6 +53,12 @@ class MeditationTypeAdapter(
holder.tvName?.let { holder.tvName?.let {
it.text = data[position].title it.text = data[position].title
} }
holder.cvLayout?.setOnClickListener {
ARouter.getInstance().build("/muse/play")
.withLong("MEDITATION_ID",data[position].meditationId)
.withInt("MEDITATION_TYPE",meditationType)
.navigation()
}
} }
is MeditationTypeMoreViewHolder -> { is MeditationTypeMoreViewHolder -> {
holder.llMoreLayout?.setOnClickListener { holder.llMoreLayout?.setOnClickListener {
...@@ -61,14 +70,17 @@ class MeditationTypeAdapter( ...@@ -61,14 +70,17 @@ class MeditationTypeAdapter(
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
return data.size return if (data.isNotEmpty()){
data.size + 1
}else{
data.size
}
} }
override fun getItemId(position: Int) = position.toLong() override fun getItemId(position: Int) = position.toLong()
override fun getItemViewType(position: Int): Int { override fun getItemViewType(position: Int): Int {
val isMore = false return if (data.isNotEmpty() && position == data.size) {
return if (isMore) {
FOOTER_TYPE FOOTER_TYPE
} else { } else {
CONTENT_TYPE CONTENT_TYPE
...@@ -76,6 +88,7 @@ class MeditationTypeAdapter( ...@@ -76,6 +88,7 @@ class MeditationTypeAdapter(
} }
inner class MeditationTypeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { inner class MeditationTypeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val cvLayout:CardView? = itemView.findViewById(R.id.card_view)
val ivType: ImageView? = itemView.findViewById(R.id.iv_meditation_type) val ivType: ImageView? = itemView.findViewById(R.id.iv_meditation_type)
val tvName: TextView? = itemView.findViewById(R.id.tv_meditation_type) val tvName: TextView? = itemView.findViewById(R.id.tv_meditation_type)
} }
......
...@@ -6,7 +6,7 @@ import android.view.View ...@@ -6,7 +6,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.yidianling.home.model.MeditationTypeModel import com.ydl.ydlcommon.utils.LogUtil
import com.yidianling.home.model.bean.MeditationModuleBean import com.yidianling.home.model.bean.MeditationModuleBean
class MeditationViewPagerAdapter(private val context: Context, private val data: class MeditationViewPagerAdapter(private val context: Context, private val data:
...@@ -24,7 +24,7 @@ class MeditationViewPagerAdapter(private val context: Context, private val data: ...@@ -24,7 +24,7 @@ class MeditationViewPagerAdapter(private val context: Context, private val data:
rv.adapter = rv.adapter =
data.mditationListResponse?.get(position)?.let { data.mditationListResponse?.get(position)?.let {
MeditationTypeAdapter(context, MeditationTypeAdapter(context,
it.mditationResponseList) it.mditationResponseList,it.meditionType)
} }
} }
} }
......
package com.yidianling.home.model
data class MeditationTypeModel(
val imageUrl:String,
val name:String,
val id:String,
val isMore:Boolean = false
)
...@@ -8,7 +8,7 @@ class MeditationModuleBean : HomeItemBaseBean { ...@@ -8,7 +8,7 @@ class MeditationModuleBean : HomeItemBaseBean {
constructor():super(false) constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty) constructor(isRealEmpty:Boolean):super(isRealEmpty)
var meditationIndexInfo:MeditationSlogan? = null var mditationIndexInfo:MeditationSlogan? = null
data class MeditationSlogan( data class MeditationSlogan(
val greetings:String?=null, val greetings:String?=null,
...@@ -32,7 +32,7 @@ class MeditationModuleBean : HomeItemBaseBean { ...@@ -32,7 +32,7 @@ class MeditationModuleBean : HomeItemBaseBean {
) )
data class MeditationDetail( data class MeditationDetail(
val meditationId:Int, val meditationId:Long,
val title:String, val title:String,
val coverImageUrl:String, val coverImageUrl:String,
val tagId:Int val tagId:Int
......
...@@ -15,13 +15,12 @@ import com.google.android.material.tabs.TabLayout ...@@ -15,13 +15,12 @@ import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
import com.google.gson.Gson import com.google.gson.Gson
import com.ydl.ydl_image.module.GlideApp import com.ydl.ydl_image.module.GlideApp
import com.yidianling.common.tools.ToastUtil
import com.yidianling.home.MeditationViewPagerAdapter import com.yidianling.home.MeditationViewPagerAdapter
import com.yidianling.home.R import com.yidianling.home.R
import com.yidianling.home.constract.HomeViewConfig import com.yidianling.home.constract.HomeViewConfig
import com.yidianling.home.event.IHomeEvent import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.MeditationTypeModel
import com.yidianling.home.model.bean.MeditationModuleBean import com.yidianling.home.model.bean.MeditationModuleBean
import com.yidianling.home.model.bean.MuseModuleBean
import kotlinx.android.synthetic.ydl.home_muse_view.view.* import kotlinx.android.synthetic.ydl.home_muse_view.view.*
/** /**
...@@ -34,8 +33,6 @@ import kotlinx.android.synthetic.ydl.home_muse_view.view.* ...@@ -34,8 +33,6 @@ import kotlinx.android.synthetic.ydl.home_muse_view.view.*
class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEvent?) : class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEvent?) :
LinearLayout(mContext) { LinearLayout(mContext) {
private var cacheList: ArrayList<HomeMuseView> = ArrayList()
private val meditationTitles = mutableListOf<String>() private val meditationTitles = mutableListOf<String>()
init { init {
...@@ -63,24 +60,27 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -63,24 +60,27 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
homeEvent?.museMoreClick(Gson().toJson(bean)) homeEvent?.museMoreClick(Gson().toJson(bean))
} }
val greeting = bean?.meditationIndexInfo?.greetings?:"你好" val greeting = bean.mditationIndexInfo?.greetings?:"你好"
tv_time.text = greeting tv_time.text = greeting
val slogan = val slogan =
if (bean?.meditationIndexInfo?.mditationDay==null){ if (bean.mditationIndexInfo?.mditationDay==null){
"无常的日子里,呼吸间拾起力量" "无常的日子里,呼吸间拾起力量"
}else{ }else{
"已连续冥想${bean?.meditationIndexInfo?.mditationDay}天" "已连续冥想${bean?.mditationIndexInfo?.mditationDay}天"
} }
tv_meditation_slogan.text = slogan tv_meditation_slogan.text = slogan
val videoUrl = bean?.meditationIndexInfo?.videoLink?:"http://www.w3school.com.cn/example/html5/mov_bbb.mp4" val videoUrl = bean?.mditationIndexInfo?.videoLink?:"http://www.w3school.com.cn/example/html5/mov_bbb.mp4"
GlideApp.with(this) GlideApp.with(this)
.load(videoUrl) .load(videoUrl)
.into(iv_video_background) .into(iv_video_background)
video_view?.setVideoPath(videoUrl) video_view?.setVideoPath(videoUrl)
video_view?.setOnErrorListener { mp, what, extra ->
ToastUtil.toastShort("视频播放失败!")
true
}
video_view?.setOnPreparedListener { video_view?.setOnPreparedListener {
it?.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING) it?.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING)
video_view?.setOnInfoListener { mp, what, extra -> video_view?.setOnInfoListener { mp, what, extra ->
...@@ -94,36 +94,10 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -94,36 +94,10 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
} }
video_view?.setOnCompletionListener { video_view?.start() } video_view?.setOnCompletionListener { video_view?.start() }
val data = mutableListOf<List<MeditationTypeModel>>()
val innerData = mutableListOf<MeditationTypeModel>()
for (i in 0 until 4){
val name = when(i){
0 -> "溪流"
1 -> "田园"
2 -> "雨声"
else -> "更多"
}
val imageUrl = when(i){
0 -> "https://img0.baidu.com/it/u=2451025451,2376393604&fm=253&fmt=auto&app=138&f=JPEG?w=499&h=328"
1 -> "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.9ku.com%2Fgeshoutuji%2Fsingertuji%2F4%2F40945%2F40945_1.jpg&refer=http%3A%2F%2Fimg.9ku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654863419&t=aaea1ecc66afc7859a0cf64c06c6f2a4"
2 -> "https://img2.baidu.com/it/u=3357363842,3633429992&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=740"
else -> "https://img2.baidu.com/it/u=3357363842,3633429992&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=740"
}
val isMore = i == 3
innerData.add(MeditationTypeModel(imageUrl,name,i.toString(),isMore))
}
for (i in 0 until 3){
data.add(innerData)
}
bean?.mditationListResponse?.forEach { bean?.mditationListResponse?.forEach {
meditationTitles.add(it.comment) meditationTitles.add(it.comment)
} }
view_pager.adapter = MeditationViewPagerAdapter(mContext,bean) view_pager.adapter = MeditationViewPagerAdapter(mContext,bean)
tab_layout.addOnTabSelectedListener(object :TabLayout.OnTabSelectedListener{ tab_layout.addOnTabSelectedListener(object :TabLayout.OnTabSelectedListener{
...@@ -154,7 +128,6 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv ...@@ -154,7 +128,6 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
tab.text = meditationTitles[position] tab.text = meditationTitles[position]
}.attach() }.attach()
} }
} }
......
...@@ -15,10 +15,6 @@ ...@@ -15,10 +15,6 @@
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" /> android:theme="@style/platform_NoTitleTheme" />
<activity <activity
android:name=".activity.PlayPureMusicActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".activity.MeditationTimeOffActivity" android:name=".activity.MeditationTimeOffActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" /> android:theme="@style/platform_NoTitleTheme" />
......
...@@ -14,7 +14,7 @@ public class MeditationWheelViewUtil { ...@@ -14,7 +14,7 @@ public class MeditationWheelViewUtil {
private List<String> hours = new ArrayList<>(); private List<String> hours = new ArrayList<>();
private List<String> minutes = new ArrayList<>(); private List<String> minutes = new ArrayList<>();
public void initWheelView(Context context, WheelView wheelViewH, WheelView wheelViewM){ public void initWheelView(Context context, WheelView wheelViewH, int selectionH, WheelView wheelViewM, int selectionM) {
createHours(); createHours();
createMinutes(); createMinutes();
...@@ -31,22 +31,43 @@ public class MeditationWheelViewUtil { ...@@ -31,22 +31,43 @@ public class MeditationWheelViewUtil {
wheelViewH.setStyle(style); wheelViewH.setStyle(style);
wheelViewH.setExtraText("小时", Color.parseColor("#FFFFFFFF"), 50, 120); wheelViewH.setExtraText("小时", Color.parseColor("#FFFFFFFF"), 50, 120);
wheelViewH.setSelection(selectionH);
wheelViewM.setWheelAdapter(new ArrayWheelAdapter(context)); wheelViewM.setWheelAdapter(new ArrayWheelAdapter(context));
wheelViewM.setWheelData(minutes); wheelViewM.setWheelData(minutes);
wheelViewM.setStyle(style); wheelViewM.setStyle(style);
wheelViewM.setExtraText("分钟", Color.parseColor("#FFFFFFFF"), 50, 120); wheelViewM.setExtraText("分钟", Color.parseColor("#FFFFFFFF"), 50, 120);
wheelViewM.setSelection(selectionM);
} }
public void minuteRule(WheelView wh,WheelView wm){
wh.setOnWheelItemSelectedListener((position, o) -> {
if (position == 0 && wh.getCurrentPosition()==0){
wm.setSelection(1);
}
});
wm.setOnWheelItemSelectedListener((position, o) -> {
if (position == 0 && wh.getCurrentPosition()==0){
wm.setSelection(1);
}
});
}
private void createHours(){ private void createHours() {
for (int i = 0; i < 24; i++) { for (int i = 0; i < 24; i++) {
hours.add("" + i); hours.add("" + i);
} }
} }
private void createMinutes() { private void createMinutes() {
for (int i = 0; i < 60; i+=5) { for (int i = 0; i < 60; i += 5) {
if (i < 10 ) { if (i < 10) {
minutes.add("0" + i); minutes.add("0" + i);
} else { } else {
minutes.add("" + i); minutes.add("" + i);
......
...@@ -2,16 +2,16 @@ package com.yidianling.muse.activity ...@@ -2,16 +2,16 @@ package com.yidianling.muse.activity
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import com.blankj.utilcode.util.SPUtils
import com.ydl.ydlcommon.base.BaseActivity import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.muse.MeditationWheelViewUtil import com.yidianling.muse.MeditationWheelViewUtil
import com.yidianling.muse.R import com.yidianling.muse.R
import kotlinx.android.synthetic.main.activity_play_meditation_time_off.* import kotlinx.android.synthetic.main.activity_play_meditation_time_off.*
class MeditationTimeOffActivity:BaseActivity() { class MeditationTimeOffActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
StatusBarUtils.setTransparentForImageView(this, null) StatusBarUtils.setTransparentForImageView(this, null)
...@@ -26,36 +26,31 @@ class MeditationTimeOffActivity:BaseActivity() { ...@@ -26,36 +26,31 @@ class MeditationTimeOffActivity:BaseActivity() {
tv_save_setting?.setOnClickListener { tv_save_setting?.setOnClickListener {
ToastHelper.show("保存设置") ToastHelper.show("保存设置")
val hour = val hour = wheel_view_hour.selectionItem
if (wheel_view_hour.selectionItem.equals("0")){ val minute = wheel_view_minute.selectionItem
""
}else{
wheel_view_hour.selectionItem
}
val minute = val selectedHour = wheel_view_hour.currentPosition
if (wheel_view_minute.selectionItem.equals("00")){ val selectedMinute = wheel_view_minute.currentPosition
""
}else{
wheel_view_minute.selectionItem
}
LogUtil.d("time off","hour=$hour === minute=$minute")
SPUtils.getInstance().put("SELECT_H",selectedHour)
SPUtils.getInstance().put("SELECT_M",selectedMinute)
val intent = Intent() val intent = Intent()
intent.putExtra("TIME_OFF_HOUR",hour.toString()) if (hour is String && minute is String){
intent.putExtra("TIME_OFF_MINUTE",minute.toString()) val minute = (hour.toInt()*60).plus(minute.toInt())
setResult(RESULT_OK,intent) intent.putExtra("TIME_OFF_MINUTE", minute)
}
setResult(RESULT_OK, intent)
finish() finish()
} }
tv_cancel_time_off?.setOnClickListener { tv_cancel_time_off?.setOnClickListener {
ToastHelper.show("关闭定时") ToastHelper.show("关闭定时")
SPUtils.getInstance().put("SELECT_H",0)
SPUtils.getInstance().put("SELECT_M",1)
val intent = Intent() val intent = Intent()
intent.putExtra("TIME_OFF_HOUR","") intent.putExtra("TIME_OFF_MINUTE", 0)
intent.putExtra("TIME_OFF_MINUTE","") setResult(RESULT_OK, intent)
setResult(RESULT_OK,intent)
finish() finish()
} }
...@@ -64,9 +59,11 @@ class MeditationTimeOffActivity:BaseActivity() { ...@@ -64,9 +59,11 @@ class MeditationTimeOffActivity:BaseActivity() {
} }
private fun initWheel() { private fun initWheel() {
val selectionH = SPUtils.getInstance().getInt("SELECT_H",0)
val selectionM = SPUtils.getInstance().getInt("SELECT_M",1)
MeditationWheelViewUtil().initWheelView(this, wheel_view_hour,selectionH, wheel_view_minute,selectionM)
MeditationWheelViewUtil().initWheelView(this,wheel_view_hour,wheel_view_minute) MeditationWheelViewUtil().minuteRule(wheel_view_hour,wheel_view_minute)
} }
override fun getStatusViewOptions(): StatusBarOptions { override fun getStatusViewOptions(): StatusBarOptions {
......
package com.yidianling.muse.activity
import android.os.Build
import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.AppCompatSeekBar
import androidx.constraintlayout.widget.ConstraintLayout
import com.alibaba.android.arouter.facade.annotation.Route
import com.bumptech.glide.Glide
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.setTransparentForImageView
import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.statusBarLightMode
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.muse.R
import com.yidianling.muse.widget.ShareMeditationDialog
import kotlinx.android.synthetic.main.activity_play_meditation.*
import kotlin.properties.Delegates
@Route(path = "/muse/play_pure_music")
class PlayPureMusicActivity : BaseActivity() {
private var bgUrl =
"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcuimianxinli.com%2Fupload%2F2016-07%2F16072613412794.jpg&refer=http%3A%2F%2Fcuimianxinli.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654150276&t=393628420414c371b4b00540943cf0c7"
private var collected = false
private var shareDialog: ShareMeditationDialog? = null
override fun onCreate(savedInstanceState: Bundle?) {
setTransparentForImageView(this, null)
statusBarLightMode(this)
super.onCreate(savedInstanceState)
initView()
}
override fun initDataAndEvent() {
}
override fun layoutResId(): Int {
return R.layout.activity_play_pure_music
}
override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(true, false)
}
private fun initView() {
Glide.with(this)
.load(bgUrl)
.into(iv_bg)
iv_close.setOnClickListener {
finish()
}
iv_back.setOnClickListener {
finish()
}
iv_share.setOnClickListener {
if (shareDialog == null) {
shareDialog = ShareMeditationDialog
.newInstance(
shareImageUrl = bgUrl,
shareContent = "老铁,我是你要分享的内容"
)
}
if (shareDialog != null && shareDialog?.isAdded == false) {
shareDialog?.show(supportFragmentManager, ShareMeditationDialog.TAG)
}
}
tv_title.text = "这是一首简单的冥想BGM"
tv_content.text = "写着人们心疼的曲折,我想我很快乐,做一个旁观者"
iv_collect.setOnClickListener {
collected = !collected
if (collected) {
ToastHelper.show("收藏成功!")
iv_collect.setImageResource(R.drawable.icon_play_meditation_collect)
} else {
ToastHelper.show("取消收藏!")
iv_collect.setImageResource(R.drawable.icon_play_meditation_collect)
}
}
iv_time_off.setOnClickListener {
ToastHelper.show("设置定时关闭!")
}
// iv_play_or_pause.setOnClickListener {
//
// }
// iv_previous.setOnClickListener {
// ToastHelper.show("上一首!")
// }
// iv_next.setOnClickListener {
// ToastHelper.show("下一首!")
// }
// iv_rewind.setOnClickListener {
//
//
// }
//
// iv_fast_forward.setOnClickListener {
//
// }
}
}
\ No newline at end of file
package com.yidianling.muse.bean
data class CollectResultModule(
val status:Int
)
package com.yidianling.muse.bean
import com.ydl.ydlcommon.data.http.BaseCommand
class MeditationCollectRequestModule(
val meditationId:Long,
val status:Int
):BaseCommand() {
}
\ No newline at end of file
package com.yidianling.muse.bean
/**
* 冥想模块所有数据
* Created by xj on 2019/9/16.
*/
class MeditationPlayModuleBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
var meditationId:Long? = null
var mediaId:Long? = null
var title:String?=null
var dec:String?=null
var mditationBackgroundImage:String?=null
var duration:Int=0
var coverImageUrlIcon:String = ""
var uid:Int = 0
var broadcastTime:Int = 0
var mediaUrl:String = ""
var mediaList: ArrayList<MeditationDetail>? = null
data class MeditationDetail(
val id:Long,
val title:String,
val type:String,
val author:String,
val coverImageUrl:String,
val mediaUrl:String,
val duration:Int
)
}
\ No newline at end of file
package com.yidianling.home.http package com.yidianling.home.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlnet.YDLHttpUtils import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.muse.bean.CollectResultModule
import com.yidianling.muse.bean.MeditationCollectRequestModule
import com.yidianling.muse.bean.MeditationPlayModuleBean
import com.yidianling.muse.bean.MuseModuleBean import com.yidianling.muse.bean.MuseModuleBean
import io.reactivex.Observable import io.reactivex.Observable
...@@ -37,4 +42,32 @@ class MuseHttp { ...@@ -37,4 +42,32 @@ class MuseHttp {
fun newMuseRequest(): Observable<BaseAPIResponse<MuseModuleBean>> { fun newMuseRequest(): Observable<BaseAPIResponse<MuseModuleBean>> {
return getMusePagerApi().getMuseData() return getMusePagerApi().getMuseData()
} }
fun getPureMusicPlayDetail(
meditionType: Int,
meditationId: Long
): Observable<BaseAPIResponse<MeditationPlayModuleBean>> {
return getMusePagerApi().getPureMusicPlayDetail(
meditionType = meditionType,
mditationId = meditationId
)
}
fun getMeditationPlayDetail(
meditionType: Int,
mediaId: Long,
meditationId: Long
): Observable<BaseAPIResponse<MeditationPlayModuleBean>> {
return getMusePagerApi().getMeditationPlayDetail(
meditionType = meditionType,
mediaId = mediaId,
meditationId = meditationId
)
}
fun collectMeditation(meditationId:Long,status:Int): Observable<BaseResponse<CollectResultModule>> {
val params = MeditationCollectRequestModule(meditationId, status)
return RxUtils.mapObservable(params).flatMap { getMusePagerApi().collectMeditation(it) }
}
} }
\ No newline at end of file
...@@ -3,10 +3,12 @@ package com.yidianling.home.http ...@@ -3,10 +3,12 @@ package com.yidianling.home.http
import com.ydl.ydlcommon.base.config.YDL_DOMAIN import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.muse.bean.CollectResultModule
import com.yidianling.muse.bean.MeditationPlayModuleBean
import com.yidianling.muse.bean.MuseModuleBean import com.yidianling.muse.bean.MuseModuleBean
import io.reactivex.Observable import io.reactivex.Observable
import retrofit2.http.GET import retrofit2.http.*
import retrofit2.http.Headers
/** /**
* @author jiucheng * @author jiucheng
...@@ -21,4 +23,35 @@ interface MusePagerApi { ...@@ -21,4 +23,35 @@ interface MusePagerApi {
@GET("meditation/meditation/list") @GET("meditation/meditation/list")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA) @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getMuseData(): Observable<BaseAPIResponse<MuseModuleBean>> fun getMuseData(): Observable<BaseAPIResponse<MuseModuleBean>>
/**
* 声音播放详情页
*/
@GET("cms/meditation/mditatiPlayDetail")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getPureMusicPlayDetail(
@Query("meditionType") meditionType: Int = 0,
@Query("mditationId") mditationId: Long
): Observable<BaseAPIResponse<MeditationPlayModuleBean>>
/**
* 冥想播放详情页
*/
@GET("cms/meditation/mditatiPlayDetail")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getMeditationPlayDetail(
@Query("meditionType") meditionType: Int = 1,
@Query("mediaId") mediaId: Long,
@Query("meditationId") meditationId: Long
): Observable<BaseAPIResponse<MeditationPlayModuleBean>>
/**
* 声音播放详情页
*/
@POST("cms/meditation/collect")
fun collectMeditation(@FieldMap params: Map<String, String>
): Observable<BaseResponse<CollectResultModule>>
} }
\ No newline at end of file
...@@ -34,6 +34,36 @@ class MediaPlayerTimeUtil { ...@@ -34,6 +34,36 @@ class MediaPlayerTimeUtil {
return null return null
} }
fun formatTimeOff(finishTime:Long):String{
var totalTime = (finishTime / 1000).toInt() //秒
var minute = 0
var second = 0
if (60 <= totalTime) {
minute = totalTime / 60
totalTime -= 60 * minute
}
if (0 <= totalTime) {
second = totalTime
}
val sb = StringBuilder()
if (minute < 10) {
sb.append("0").append(minute).append(":")
} else {
sb.append(minute).append(":")
}
if (second < 10) {
sb.append("0").append(second)
} else {
sb.append(second)
}
return sb.toString()
}
} }
} }
\ No newline at end of file
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
tools:background="@color/_8c">
<ImageView <ImageView
android:id="@+id/iv_bg" android:id="@+id/iv_bg"
...@@ -38,9 +39,9 @@ ...@@ -38,9 +39,9 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<View <View
android:layout_width="1dp" android:layout_width="0.5dp"
android:layout_height="20dp" android:layout_height="20dp"
android:background="#FF8E8E8E" android:background="#FFE8E8E8"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
...@@ -99,16 +100,6 @@ ...@@ -99,16 +100,6 @@
app:layout_constraintTop_toBottomOf="@id/tv_title" app:layout_constraintTop_toBottomOf="@id/tv_title"
tools:text="舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神" /> tools:text="舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神" />
<!-- <com.google.android.exoplayer2.ui.PlayerView-->
<!-- android:id="@+id/player_view"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="180dp"-->
<!-- android:layout_marginBottom="140dp"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:controller_layout_id="@layout/exo_player_control_view" />-->
<include layout="@layout/player_control_view" /> <include layout="@layout/player_control_view" />
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
...@@ -116,7 +107,37 @@ ...@@ -116,7 +107,37 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" /> app:layout_constraintGuide_percent="0.5"/>
<LinearLayout
android:id="@+id/ll_pure_music_time_off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
app:layout_constraintStart_toStartOf="@id/guide_line"
app:layout_constraintEnd_toEndOf="@id/guide_line"
app:layout_constraintTop_toTopOf="@id/iv_collect"
tools:visibility="visible"
android:visibility="gone">
<ImageView
android:id="@+id/iv_time_off_pure_music"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_play_meditation_time_off" />
<TextView
android:id="@+id/tv_time_off_pure_music"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
tools:text="56:32"
android:textSize="12sp"
android:textColor="@color/white"/>
</LinearLayout>
<ImageView <ImageView
android:id="@+id/iv_collect" android:id="@+id/iv_collect"
...@@ -129,6 +150,17 @@ ...@@ -129,6 +150,17 @@
app:layout_constraintEnd_toStartOf="@id/guide_line" /> app:layout_constraintEnd_toStartOf="@id/guide_line" />
<ImageView <ImageView
android:id="@+id/iv_pure_music_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginBottom="48dp"
android:src="@drawable/icon_pure_music_list"
app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress"
app:layout_constraintStart_toEndOf="@id/guide_line"
android:visibility="gone"/>
<ImageView
android:id="@+id/iv_time_off" android:id="@+id/iv_time_off"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -136,7 +168,8 @@ ...@@ -136,7 +168,8 @@
android:layout_marginBottom="48dp" android:layout_marginBottom="48dp"
android:src="@drawable/icon_play_meditation_time_off" android:src="@drawable/icon_play_meditation_time_off"
app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress" app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress"
app:layout_constraintStart_toEndOf="@id/guide_line" /> app:layout_constraintStart_toEndOf="@id/guide_line"
tools:visibility="gone"/>
<TextView <TextView
android:id="@+id/tv_time_off" android:id="@+id/tv_time_off"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:background="#ff002222">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/csl_layout"
android:layout_width="104dp"
android:layout_height="36dp"
android:background="@drawable/bg_meditation_play_top"
android:layout_marginStart="16dp"
android:layout_marginTop="55dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:paddingVertical="8dp"
android:src="@drawable/icon_close_play_meditation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<View
android:layout_width="1dp"
android:layout_height="20dp"
android:background="#FF8E8E8E"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<ImageView
android:id="@+id/iv_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_play_meditation_down_arrow"
android:paddingHorizontal="16dp"
android:paddingVertical="9dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/iv_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_marginEnd="17dp"
android:src="@drawable/icon_play_meditation_share"
app:layout_constraintBottom_toBottomOf="@id/csl_layout"
app:layout_constraintTop_toTopOf="@id/csl_layout"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="150dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/csl_layout"
tools:text="舒缓安神舒神舒缓安神舒缓安神舒缓安神舒缓安神" />
<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="12dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title"
tools:text="舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神舒缓安神" />
<ImageView
android:id="@+id/iv_play_or_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_pause_meditation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="60dp"/>
<androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/seekbar_play_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="64dp"
android:layout_marginBottom="50dp"
android:thumb="@drawable/play_meditation_thumb"
android:progress="50"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/iv_play_or_pause"/>
<TextView
android:id="@+id/tv_current_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:textColor="#B3FFFFFF"
android:textSize="12sp"
app:layout_constraintEnd_toStartOf="@id/seekbar_play_progress"
app:layout_constraintTop_toTopOf="@id/seekbar_play_progress"
app:layout_constraintBottom_toBottomOf="@id/seekbar_play_progress"
tools:text="03:46"/>
<TextView
android:id="@+id/tv_total_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:textColor="#B3FFFFFF"
android:textSize="12sp"
app:layout_constraintStart_toEndOf="@id/seekbar_play_progress"
app:layout_constraintTop_toTopOf="@id/seekbar_play_progress"
app:layout_constraintBottom_toBottomOf="@id/seekbar_play_progress"
tools:text="13:46"/>
<ImageView
android:id="@+id/iv_time_off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="48dp"
android:src="@drawable/icon_play_meditation_time_off"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress"/>
<ImageView
android:id="@+id/iv_collect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="56dp"
android:layout_marginBottom="48dp"
android:src="@drawable/icon_play_meditation_collect"
app:layout_constraintEnd_toStartOf="@id/iv_time_off"
app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress"/>
<ImageView
android:id="@+id/iv_play_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginBottom="48dp"
android:src="@drawable/icon_pure_music_list"
app:layout_constraintStart_toEndOf="@id/iv_time_off"
app:layout_constraintBottom_toTopOf="@id/seekbar_play_progress"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/tv_item_name"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:layout_margin="10dp"
android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
android:id="@+id/exo_duration" android:id="@+id/exo_duration"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="12dp" android:layout_marginStart="12dp"
android:textColor="#B3FFFFFF" android:textColor="#B3FFFFFF"
android:textSize="12sp" android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@id/seekbar_play_progress" app:layout_constraintBottom_toBottomOf="@id/seekbar_play_progress"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment