Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
f17e2613
Commit
f17e2613
authored
2 years ago
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
meditation time off by rx
parent
a5f63d1f
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
560 additions
and
469 deletions
+560
-469
MeditationTypeAdapter.kt
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
+19
-6
MeditationViewPagerAdapter.kt
m-home/src/main/java/com/yidianling/home/MeditationViewPagerAdapter.kt
+2
-2
MeditationTypeModel.kt
m-home/src/main/java/com/yidianling/home/model/MeditationTypeModel.kt
+0
-8
MeditationModuleBean.kt
m-home/src/main/java/com/yidianling/home/model/bean/MeditationModuleBean.kt
+2
-2
HomeMuseView.kt
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
+9
-36
AndroidManifest.xml
m-muse/src/main/AndroidManifest.xml
+0
-4
MeditationWheelViewUtil.java
m-muse/src/main/java/com/yidianling/muse/MeditationWheelViewUtil.java
+25
-4
MeditationTimeOffActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/MeditationTimeOffActivity.kt
+21
-24
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+282
-52
PlayPureMusicActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayPureMusicActivity.kt
+0
-122
CollectResultModule.kt
m-muse/src/main/java/com/yidianling/muse/bean/CollectResultModule.kt
+5
-0
MeditationCollectRequestModule.kt
m-muse/src/main/java/com/yidianling/muse/bean/MeditationCollectRequestModule.kt
+10
-0
MeditationPlayModuleBean.kt
m-muse/src/main/java/com/yidianling/muse/bean/MeditationPlayModuleBean.kt
+35
-0
MuseHttp.kt
m-muse/src/main/java/com/yidianling/muse/http/MuseHttp.kt
+34
-0
MusePagerApi.kt
m-muse/src/main/java/com/yidianling/muse/http/MusePagerApi.kt
+36
-2
MediaPlayerTimeUtil.kt
m-muse/src/main/java/com/yidianling/muse/utils/MediaPlayerTimeUtil.kt
+31
-0
activity_play_meditation.xml
m-muse/src/main/res/layout/activity_play_meditation.xml
+48
-15
activity_play_pure_music.xml
m-muse/src/main/res/layout/activity_play_pure_music.xml
+0
-170
layout_wheel_item.xml
m-muse/src/main/res/layout/layout_wheel_item.xml
+0
-21
player_control_view.xml
m-muse/src/main/res/layout/player_control_view.xml
+1
-1
No files found.
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
View file @
f17e2613
package
com.yidianling.home
import
android.content.Context
import
android.content.Intent
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.LinearLayout
import
android.widget.TextView
import
androidx.cardview.widget.CardView
import
androidx.recyclerview.widget.RecyclerView
import
com.alibaba.android.arouter.launcher.ARouter
import
com.bumptech.glide.Glide
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.home.model.MeditationTypeModel
import
com.yidianling.home.model.bean.MeditationModuleBean
class
MeditationTypeAdapter
(
private
val
context
:
Context
,
private
val
data
:
List
<
MeditationModuleBean
.
MeditationDetail
>
private
val
data
:
List
<
MeditationModuleBean
.
MeditationDetail
>,
private
val
meditationType
:
Int
)
:
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
RecyclerView
.
ViewHolder
{
...
...
@@ -31,7 +35,6 @@ class MeditationTypeAdapter(
LayoutInflater
.
from
(
context
)
.
inflate
(
R
.
layout
.
layout_meditation_more_type
,
parent
,
false
)
)
}
}
...
...
@@ -50,6 +53,12 @@ class MeditationTypeAdapter(
holder
.
tvName
?.
let
{
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
->
{
holder
.
llMoreLayout
?.
setOnClickListener
{
...
...
@@ -61,14 +70,17 @@ class MeditationTypeAdapter(
}
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
getItemViewType
(
position
:
Int
):
Int
{
val
isMore
=
false
return
if
(
isMore
)
{
return
if
(
data
.
isNotEmpty
()
&&
position
==
data
.
size
)
{
FOOTER_TYPE
}
else
{
CONTENT_TYPE
...
...
@@ -76,6 +88,7 @@ class MeditationTypeAdapter(
}
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
tvName
:
TextView
?
=
itemView
.
findViewById
(
R
.
id
.
tv_meditation_type
)
}
...
...
This diff is collapsed.
Click to expand it.
m-home/src/main/java/com/yidianling/home/MeditationViewPagerAdapter.kt
View file @
f17e2613
...
...
@@ -6,7 +6,7 @@ import android.view.View
import
android.view.ViewGroup
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.y
idianling.home.model.MeditationTypeMode
l
import
com.y
dl.ydlcommon.utils.LogUti
l
import
com.yidianling.home.model.bean.MeditationModuleBean
class
MeditationViewPagerAdapter
(
private
val
context
:
Context
,
private
val
data
:
...
...
@@ -24,7 +24,7 @@ class MeditationViewPagerAdapter(private val context: Context, private val data:
rv
.
adapter
=
data
.
mditationListResponse
?.
get
(
position
)
?.
let
{
MeditationTypeAdapter
(
context
,
it
.
mditationResponseList
)
it
.
mditationResponseList
,
it
.
meditionType
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
m-home/src/main/java/com/yidianling/home/model/MeditationTypeModel.kt
deleted
100644 → 0
View file @
a5f63d1f
package
com.yidianling.home.model
data class
MeditationTypeModel
(
val
imageUrl
:
String
,
val
name
:
String
,
val
id
:
String
,
val
isMore
:
Boolean
=
false
)
This diff is collapsed.
Click to expand it.
m-home/src/main/java/com/yidianling/home/model/bean/MeditationModuleBean.kt
View file @
f17e2613
...
...
@@ -8,7 +8,7 @@ class MeditationModuleBean : HomeItemBaseBean {
constructor
():
super
(
false
)
constructor
(
isRealEmpty
:
Boolean
):
super
(
isRealEmpty
)
var
m
e
ditationIndexInfo
:
MeditationSlogan
?
=
null
var
mditationIndexInfo
:
MeditationSlogan
?
=
null
data class
MeditationSlogan
(
val
greetings
:
String
?=
null
,
...
...
@@ -32,7 +32,7 @@ class MeditationModuleBean : HomeItemBaseBean {
)
data class
MeditationDetail
(
val
meditationId
:
Int
,
val
meditationId
:
Long
,
val
title
:
String
,
val
coverImageUrl
:
String
,
val
tagId
:
Int
...
...
This diff is collapsed.
Click to expand it.
m-home/src/ydl/java/com/yidianling/home/ui/view/HomeMuseView.kt
View file @
f17e2613
...
...
@@ -15,13 +15,12 @@ import com.google.android.material.tabs.TabLayout
import
com.google.android.material.tabs.TabLayoutMediator
import
com.google.gson.Gson
import
com.ydl.ydl_image.module.GlideApp
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.home.MeditationViewPagerAdapter
import
com.yidianling.home.R
import
com.yidianling.home.constract.HomeViewConfig
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.MuseModuleBean
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
?)
:
LinearLayout
(
mContext
)
{
private
var
cacheList
:
ArrayList
<
HomeMuseView
>
=
ArrayList
()
private
val
meditationTitles
=
mutableListOf
<
String
>()
init
{
...
...
@@ -63,24 +60,27 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
homeEvent
?.
museMoreClick
(
Gson
().
toJson
(
bean
))
}
val
greeting
=
bean
?.
me
ditationIndexInfo
?.
greetings
?:
"你好"
val
greeting
=
bean
.
m
ditationIndexInfo
?.
greetings
?:
"你好"
tv_time
.
text
=
greeting
val
slogan
=
if
(
bean
?.
me
ditationIndexInfo
?.
mditationDay
==
null
){
if
(
bean
.
m
ditationIndexInfo
?.
mditationDay
==
null
){
"无常的日子里,呼吸间拾起力量"
}
else
{
"已连续冥想${bean?.m
e
ditationIndexInfo?.mditationDay}天"
"已连续冥想${bean?.mditationIndexInfo?.mditationDay}天"
}
tv_meditation_slogan
.
text
=
slogan
val
videoUrl
=
bean
?.
m
e
ditationIndexInfo
?.
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
)
.
load
(
videoUrl
)
.
into
(
iv_video_background
)
video_view
?.
setVideoPath
(
videoUrl
)
video_view
?.
setOnErrorListener
{
mp
,
what
,
extra
->
ToastUtil
.
toastShort
(
"视频播放失败!"
)
true
}
video_view
?.
setOnPreparedListener
{
it
?.
setVideoScalingMode
(
MediaPlayer
.
VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
)
video_view
?.
setOnInfoListener
{
mp
,
what
,
extra
->
...
...
@@ -94,36 +94,10 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
}
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
{
meditationTitles
.
add
(
it
.
comment
)
}
view_pager
.
adapter
=
MeditationViewPagerAdapter
(
mContext
,
bean
)
tab_layout
.
addOnTabSelectedListener
(
object
:
TabLayout
.
OnTabSelectedListener
{
...
...
@@ -154,7 +128,6 @@ class HomeMuseView(private val mContext: Context, private var homeEvent: IHomeEv
tab
.
text
=
meditationTitles
[
position
]
}.
attach
()
}
}
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/AndroidManifest.xml
View file @
f17e2613
...
...
@@ -15,10 +15,6 @@
android:screenOrientation=
"portrait"
android:theme=
"@style/platform_NoTitleTheme"
/>
<activity
android:name=
".activity.PlayPureMusicActivity"
android:screenOrientation=
"portrait"
android:theme=
"@style/platform_NoTitleTheme"
/>
<activity
android:name=
".activity.MeditationTimeOffActivity"
android:screenOrientation=
"portrait"
android:theme=
"@style/platform_NoTitleTheme"
/>
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/MeditationWheelViewUtil.java
View file @
f17e2613
...
...
@@ -14,7 +14,7 @@ public class MeditationWheelViewUtil {
private
List
<
String
>
hours
=
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
();
createMinutes
();
...
...
@@ -31,22 +31,43 @@ public class MeditationWheelViewUtil {
wheelViewH
.
setStyle
(
style
);
wheelViewH
.
setExtraText
(
"小时"
,
Color
.
parseColor
(
"#FFFFFFFF"
),
50
,
120
);
wheelViewH
.
setSelection
(
selectionH
);
wheelViewM
.
setWheelAdapter
(
new
ArrayWheelAdapter
(
context
));
wheelViewM
.
setWheelData
(
minutes
);
wheelViewM
.
setStyle
(
style
);
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
++)
{
hours
.
add
(
""
+
i
);
}
}
private
void
createMinutes
()
{
for
(
int
i
=
0
;
i
<
60
;
i
+=
5
)
{
if
(
i
<
10
)
{
for
(
int
i
=
0
;
i
<
60
;
i
+=
5
)
{
if
(
i
<
10
)
{
minutes
.
add
(
"0"
+
i
);
}
else
{
minutes
.
add
(
""
+
i
);
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/activity/MeditationTimeOffActivity.kt
View file @
f17e2613
...
...
@@ -2,16 +2,16 @@ package com.yidianling.muse.activity
import
android.content.Intent
import
android.os.Bundle
import
com.blankj.utilcode.util.SPUtils
import
com.ydl.ydlcommon.base.BaseActivity
import
com.ydl.ydlcommon.bean.StatusBarOptions
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.StatusBarUtils
import
com.ydl.ydlcommon.utils.remind.ToastHelper
import
com.yidianling.muse.MeditationWheelViewUtil
import
com.yidianling.muse.R
import
kotlinx.android.synthetic.main.activity_play_meditation_time_off.*
class
MeditationTimeOffActivity
:
BaseActivity
()
{
class
MeditationTimeOffActivity
:
BaseActivity
()
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
StatusBarUtils
.
setTransparentForImageView
(
this
,
null
)
...
...
@@ -26,36 +26,31 @@ class MeditationTimeOffActivity:BaseActivity() {
tv_save_setting
?.
setOnClickListener
{
ToastHelper
.
show
(
"保存设置"
)
val
hour
=
if
(
wheel_view_hour
.
selectionItem
.
equals
(
"0"
)){
""
}
else
{
wheel_view_hour
.
selectionItem
}
val
minute
=
if
(
wheel_view_minute
.
selectionItem
.
equals
(
"00"
)){
""
}
else
{
wheel_view_minute
.
selectionItem
}
val
hour
=
wheel_view_hour
.
selectionItem
val
minute
=
wheel_view_minute
.
selectionItem
LogUtil
.
d
(
"time off"
,
"hour=$hour === minute=$minute"
)
val
selectedHour
=
wheel_view_hour
.
currentPosition
val
selectedMinute
=
wheel_view_minute
.
currentPosition
SPUtils
.
getInstance
().
put
(
"SELECT_H"
,
selectedHour
)
SPUtils
.
getInstance
().
put
(
"SELECT_M"
,
selectedMinute
)
val
intent
=
Intent
()
intent
.
putExtra
(
"TIME_OFF_HOUR"
,
hour
.
toString
())
intent
.
putExtra
(
"TIME_OFF_MINUTE"
,
minute
.
toString
())
setResult
(
RESULT_OK
,
intent
)
if
(
hour
is
String
&&
minute
is
String
){
val
minute
=
(
hour
.
toInt
()*
60
).
plus
(
minute
.
toInt
())
intent
.
putExtra
(
"TIME_OFF_MINUTE"
,
minute
)
}
setResult
(
RESULT_OK
,
intent
)
finish
()
}
tv_cancel_time_off
?.
setOnClickListener
{
ToastHelper
.
show
(
"关闭定时"
)
SPUtils
.
getInstance
().
put
(
"SELECT_H"
,
0
)
SPUtils
.
getInstance
().
put
(
"SELECT_M"
,
1
)
val
intent
=
Intent
()
intent
.
putExtra
(
"TIME_OFF_HOUR"
,
""
)
intent
.
putExtra
(
"TIME_OFF_MINUTE"
,
""
)
setResult
(
RESULT_OK
,
intent
)
intent
.
putExtra
(
"TIME_OFF_MINUTE"
,
0
)
setResult
(
RESULT_OK
,
intent
)
finish
()
}
...
...
@@ -64,9 +59,11 @@ class MeditationTimeOffActivity:BaseActivity() {
}
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
{
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
f17e2613
...
...
@@ -3,29 +3,42 @@ package com.yidianling.muse.activity
import
android.content.Intent
import
android.media.MediaPlayer
import
android.os.Bundle
import
android.view.View
import
android.widget.SeekBar
import
com.alibaba.android.arouter.facade.annotation.Route
import
com.bumptech.glide.Glide
import
com.google.gson.Gson
import
com.ydl.ydlcommon.base.BaseActivity
import
com.ydl.ydlcommon.bean.StatusBarOptions
import
com.ydl.ydlcommon.data.http.RxUtils
import
com.ydl.ydlcommon.data.http.ThrowableConsumer
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.home.http.MuseHttp
import
com.yidianling.muse.R
import
com.yidianling.muse.helper.MediaPlayerManager
import
com.yidianling.muse.utils.MediaPlayerTimeUtil
import
com.yidianling.muse.widget.QuitMeditationDialog
import
com.yidianling.muse.widget.ShareMeditationDialog
import
io.reactivex.Observable
import
io.reactivex.Observer
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.Disposable
import
io.reactivex.functions.Consumer
import
io.reactivex.schedulers.Schedulers
import
kotlinx.android.synthetic.main.activity_play_meditation.*
import
kotlinx.android.synthetic.main.player_control_view.*
import
java.util.*
import
java.util.concurrent.TimeUnit
@Route
(
path
=
"/muse/play"
)
class
PlayMeditationActivity
:
BaseActivity
()
{
private
var
meditationId
=
0L
private
var
meditationType
=
0
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"
...
...
@@ -42,23 +55,181 @@ class PlayMeditationActivity : BaseActivity() {
private
var
quitDialog
:
QuitMeditationDialog
?
=
null
private
var
mTimer
=
Timer
()
private
var
mMediaPlayer
:
MediaPlayer
?=
null
private
var
mMediaPlayer
:
MediaPlayer
?
=
null
private
var
duration
=
0
private
var
isSeekbarChanging
=
false
private
var
mDisposable
:
Disposable
?
=
null
private
var
mObservable
:
Observable
<
Long
>?
=
null
private
var
mObserver
:
Observer
<
Long
>?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
setTransparentForImageView
(
this
,
null
)
statusBarLightMode
(
this
)
super
.
onCreate
(
savedInstanceState
)
meditationId
=
intent
?.
getLongExtra
(
"MEDITATION_ID"
,
0L
)
?:
0L
meditationType
=
intent
?.
getIntExtra
(
"MEDITATION_TYPE"
,
0
)
?:
0
initView
()
getData
()
}
override
fun
initDataAndEvent
()
{
}
private
fun
getData
()
{
updateUIByMeditationType
()
// 声音详情
if
(
meditationType
==
0
)
{
MuseHttp
.
getInstance
().
getPureMusicPlayDetail
(
meditionType
=
meditationType
,
meditationId
=
meditationId
)
.
compose
(
RxUtils
.
applySchedulers
())
.
map
{
it
}
.
subscribe
(
Consumer
{
if
(
it
.
code
.
equals
(
"200"
)
&&
it
.
data
!=
null
)
{
val
module
=
it
.
data
val
title
=
module
.
title
?:
"未知标题"
val
desc
=
module
.
dec
?:
"写着人们心疼的曲折,我想我很快乐,做一个旁观者"
val
bgImageUrl
=
if
(
module
.
mditationBackgroundImage
.
isNullOrEmpty
())
{
bgUrl
}
else
{
module
.
mditationBackgroundImage
}
val
mediaUrl
=
module
.
mediaUrl
val
currentPosition
=
module
.
broadcastTime
Glide
.
with
(
this
)
.
load
(
bgImageUrl
)
.
into
(
iv_bg
)
tv_title
.
text
=
title
tv_content
.
text
=
desc
initMediaPlayer
(
mediaUrl
)
}
},
object
:
ThrowableConsumer
()
{
override
fun
accept
(
msg
:
String
)
{
}
})
}
else
if
(
meditationType
==
1
)
{
MuseHttp
.
getInstance
().
getMeditationPlayDetail
(
meditionType
=
1
,
mediaId
=
1
,
meditationId
=
1
)
.
compose
(
RxUtils
.
applySchedulers
())
.
map
{
it
}
.
filter
{
true
}
.
subscribe
(
Consumer
{
if
(
it
.
code
.
equals
(
"200"
)
&&
it
.
data
!=
null
)
{
val
module
=
it
.
data
val
title
=
module
.
title
?:
"未知标题"
val
desc
=
module
.
dec
?:
"写着人们心疼的曲折,我想我很快乐,做一个旁观者"
val
bgImageUrl
=
module
.
mditationBackgroundImage
?:
""
val
mediaUrl
=
module
.
mediaUrl
val
currentPosition
=
module
.
broadcastTime
Glide
.
with
(
this
)
.
load
(
bgImageUrl
)
.
into
(
iv_bg
)
tv_title
.
text
=
title
tv_content
.
text
=
desc
}
var
dataJson
=
Gson
().
toJson
(
it
.
data
)
},
object
:
ThrowableConsumer
()
{
override
fun
accept
(
msg
:
String
)
{
}
})
}
}
private
fun
updateUIByMeditationType
()
{
// 声音类型
if
(
meditationType
==
0
)
{
exo_rew
.
visibility
=
View
.
GONE
exo_ffwd
.
visibility
=
View
.
GONE
exo_prev
.
visibility
=
View
.
GONE
exo_next
.
visibility
=
View
.
GONE
iv_time_off
.
visibility
=
View
.
GONE
tv_time_off
.
visibility
=
View
.
GONE
ll_pure_music_time_off
.
visibility
=
View
.
VISIBLE
iv_pure_music_list
.
visibility
=
View
.
VISIBLE
}
else
{
exo_rew
.
visibility
=
View
.
VISIBLE
exo_ffwd
.
visibility
=
View
.
VISIBLE
exo_prev
.
visibility
=
View
.
VISIBLE
exo_next
.
visibility
=
View
.
VISIBLE
iv_time_off
.
visibility
=
View
.
VISIBLE
tv_time_off
.
visibility
=
View
.
VISIBLE
ll_pure_music_time_off
.
visibility
=
View
.
GONE
iv_pure_music_list
.
visibility
=
View
.
GONE
}
initClickListener
()
}
private
fun
initClickListener
()
{
iv_pure_music_list
.
setOnClickListener
{
}
iv_collect
.
setOnClickListener
{
collected
=
!
collected
if
(
collected
)
{
ToastHelper
.
show
(
"收藏成功!"
)
iv_collect
.
setImageResource
(
R
.
drawable
.
icon_meditation_collected
)
}
else
{
ToastHelper
.
show
(
"取消收藏!"
)
iv_collect
.
setImageResource
(
R
.
drawable
.
icon_play_meditation_collect
)
}
}
}
override
fun
layoutResId
():
Int
{
return
R
.
layout
.
activity_play_meditation
}
...
...
@@ -68,9 +239,6 @@ class PlayMeditationActivity : BaseActivity() {
}
private
fun
initView
()
{
Glide
.
with
(
this
)
.
load
(
bgUrl
)
.
into
(
iv_bg
)
iv_close
.
setOnClickListener
{
if
(
quitDialog
==
null
)
{
...
...
@@ -104,25 +272,19 @@ class PlayMeditationActivity : BaseActivity() {
}
}
tv_title
.
text
=
"这是一首简单的冥想BGM"
tv_content
.
text
=
"写着人们心疼的曲折,我想我很快乐,做一个旁观者"
iv_collect
.
setOnClickListener
{
collected
=
!
collected
if
(
collected
)
{
ToastHelper
.
show
(
"收藏成功!"
)
iv_collect
.
setImageResource
(
R
.
drawable
.
icon_meditation_collected
)
}
else
{
ToastHelper
.
show
(
"取消收藏!"
)
iv_collect
.
setImageResource
(
R
.
drawable
.
icon_play_meditation_collect
)
}
}
iv_time_off
.
setOnClickListener
{
startActivityForResult
(
Intent
(
this
,
MeditationTimeOffActivity
::
class
.
java
),
request_code
)
startActivityForResult
(
Intent
(
this
,
MeditationTimeOffActivity
::
class
.
java
),
request_code
)
}
initMediaPlayer
()
ll_pure_music_time_off
.
setOnClickListener
{
startActivityForResult
(
Intent
(
this
,
MeditationTimeOffActivity
::
class
.
java
),
request_code
)
}
exo_play
.
setOnClickListener
{
if
(
isPlaying
)
{
...
...
@@ -139,13 +301,13 @@ class PlayMeditationActivity : BaseActivity() {
if
(
duration
!=
null
)
{
seekbar_play_progress
.
max
=
duration
}
mTimer
.
schedule
(
object
:
TimerTask
()
{
mTimer
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
if
(!
isSeekbarChanging
){
seekbar_play_progress
.
progress
=
mMediaPlayer
?.
currentPosition
?:
0
if
(!
isSeekbarChanging
)
{
seekbar_play_progress
.
progress
=
mMediaPlayer
?.
currentPosition
?:
0
}
}
},
0
,
50
)
},
0
,
50
)
}
isPlaying
=
!
isPlaying
...
...
@@ -164,11 +326,11 @@ class PlayMeditationActivity : BaseActivity() {
if
(
duration
!=
null
)
{
seekbar_play_progress
.
max
=
duration
}
mTimer
.
schedule
(
object
:
TimerTask
()
{
mTimer
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
seekbar_play_progress
.
progress
=
mMediaPlayer
?.
currentPosition
?:
0
seekbar_play_progress
.
progress
=
mMediaPlayer
?.
currentPosition
?:
0
}
},
0
,
50
)
},
0
,
50
)
true
}
else
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_meditation
)
...
...
@@ -183,13 +345,13 @@ class PlayMeditationActivity : BaseActivity() {
if
(
duration
!=
null
)
{
seekbar_play_progress
.
max
=
duration
}
mTimer
.
schedule
(
object
:
TimerTask
()
{
mTimer
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
if
(!
isSeekbarChanging
){
seekbar_play_progress
.
progress
=
mMediaPlayer
?.
currentPosition
?:
0
if
(!
isSeekbarChanging
)
{
seekbar_play_progress
.
progress
=
mMediaPlayer
?.
currentPosition
?:
0
}
}
},
0
,
50
)
},
0
,
50
)
true
}
else
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_meditation
)
...
...
@@ -198,7 +360,7 @@ class PlayMeditationActivity : BaseActivity() {
}
exo_rew
.
setOnClickListener
{
if
(
mMediaPlayer
!=
null
)
{
if
(
mMediaPlayer
!=
null
)
{
val
currentPosition
=
mMediaPlayer
!!
.
currentPosition
val
seekPosition
=
0
.
coerceAtLeast
(
currentPosition
-
15000
)
mMediaPlayer
!!
.
seekTo
(
seekPosition
)
...
...
@@ -206,19 +368,19 @@ class PlayMeditationActivity : BaseActivity() {
}
exo_ffwd
.
setOnClickListener
{
if
(
mMediaPlayer
!=
null
)
{
if
(
mMediaPlayer
!=
null
)
{
val
currentPosition
=
mMediaPlayer
!!
.
currentPosition
val
seekPosition
=
duration
.
coerceAtMost
(
currentPosition
+
15000
)
mMediaPlayer
!!
.
seekTo
(
seekPosition
)
}
}
seekbar_play_progress
.
setOnSeekBarChangeListener
(
object
:
SeekBar
.
OnSeekBarChangeListener
{
seekbar_play_progress
.
setOnSeekBarChangeListener
(
object
:
SeekBar
.
OnSeekBarChangeListener
{
override
fun
onProgressChanged
(
seekBar
:
SeekBar
?,
progress
:
Int
,
fromUser
:
Boolean
)
{
if
(
mMediaPlayer
!=
null
)
{
if
(
mMediaPlayer
!=
null
)
{
val
totalDuration
=
mMediaPlayer
!!
.
duration
/
1000
val
position
=
mMediaPlayer
!!
.
currentPosition
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
position
/
1000
)
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
position
/
1000
)
exo_duration
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
totalDuration
)
}
...
...
@@ -234,9 +396,9 @@ class PlayMeditationActivity : BaseActivity() {
MediaPlayerManager
.
getInstance
(
this
@PlayMeditationActivity
).
seekTo
(
it
)
if
(
mMediaPlayer
!=
null
)
{
if
(
mMediaPlayer
!=
null
)
{
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
mMediaPlayer
!!
.
currentPosition
/
1000
mMediaPlayer
!!
.
currentPosition
/
1000
)
}
...
...
@@ -257,40 +419,108 @@ class PlayMeditationActivity : BaseActivity() {
}
private
fun
initMediaPlayer
(
)
{
private
fun
initMediaPlayer
(
path
:
String
)
{
mMediaPlayer
=
MediaPlayerManager
.
getInstance
(
this
).
mediaPlayer
MediaPlayerManager
.
getInstance
(
this
).
path
=
path
val
currentPosition
=
mMediaPlayer
?.
currentPosition
duration
=
mMediaPlayer
?.
duration
?:
0
if
(
currentPosition
!=
null
)
{
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
currentPosition
/
1000
)
duration
=
mMediaPlayer
?.
duration
?:
0
if
(
currentPosition
!=
null
)
{
exo_position
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
currentPosition
/
1000
)
}
if
(
duration
!=
null
)
{
exo_duration
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
duration
/
1000
)
if
(
duration
!=
null
)
{
exo_duration
.
text
=
MediaPlayerTimeUtil
.
calculateTime
(
duration
/
1000
)
}
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
resultCode
==
RESULT_OK
&&
request_code
==
requestCode
){
val
hour
=
data
?.
extras
?.
getString
(
"TIME_OFF_HOUR"
,
""
)
val
minute
=
data
?.
extras
?.
getString
(
"TIME_OFF_MINUTE"
,
""
)
if
(!
hour
.
isNullOrEmpty
()
or
(!
minute
.
isNullOrEmpty
())){
tv_time_off
.
text
=
"$hour:$minute"
if
(
resultCode
==
RESULT_OK
&&
request_code
==
requestCode
)
{
val
minute
=
data
?.
extras
?.
getInt
(
"TIME_OFF_MINUTE"
,
0
)
if
(
minute
!=
null
&&
minute
>
0
)
{
if
(
meditationType
==
0
)
{
tv_time_off_pure_music
.
visibility
=
View
.
VISIBLE
tv_time_off
.
visibility
=
View
.
GONE
mDisposable
?.
dispose
()
initRxTimeOff
((
minute
*
60
*
1000
).
toLong
(),
0
)
}
else
{
tv_time_off_pure_music
.
visibility
=
View
.
GONE
tv_time_off
.
visibility
=
View
.
VISIBLE
mDisposable
?.
dispose
()
initRxTimeOff
((
minute
*
60
*
1000
).
toLong
(),
1
)
}
}
else
{
mDisposable
?.
dispose
()
tv_time_off
.
visibility
=
View
.
GONE
tv_time_off_pure_music
.
visibility
=
View
.
GONE
}
}
}
private
fun
initRxTimeOff
(
time
:
Long
,
meditationType
:
Int
){
mObservable
=
Observable
.
interval
(
0
,
1
,
TimeUnit
.
SECONDS
)
.
take
(
time
/
1000
+
1
)
.
map
{
t
->
time
-
t
*
1000
}
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
mObserver
=
object
:
Observer
<
Long
>{
override
fun
onSubscribe
(
d
:
Disposable
)
{
mDisposable
=
d
}
override
fun
onNext
(
t
:
Long
)
{
if
(
meditationType
==
0
){
tv_time_off_pure_music
.
text
=
MediaPlayerTimeUtil
.
formatTimeOff
(
t
)
}
else
{
tv_time_off
.
text
=
MediaPlayerTimeUtil
.
formatTimeOff
(
t
)
}
}
override
fun
onError
(
e
:
Throwable
)
{
}
override
fun
onComplete
()
{
ToastHelper
.
show
(
"倒计时结束,停止播放吧!"
)
if
(
mMediaPlayer
?.
isPlaying
==
true
){
mMediaPlayer
?.
stop
()
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_meditation
)
}
if
(
meditationType
==
0
){
tv_time_off_pure_music
.
text
=
""
}
else
{
tv_time_off
.
text
=
""
}
}
}
if
(
mObserver
!=
null
&&
mObserver
is
Observer
<
Long
>){
mObservable
?.
subscribe
(
mObserver
as
Observer
<
Long
>)
}
if
(
mDisposable
?.
isDisposed
==
true
&&
mObserver
!=
null
&&
mObserver
is
Observer
<
Long
>){
mObservable
?.
subscribe
(
mObserver
as
Observer
<
Long
>)
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
mDisposable
?.
dispose
()
mTimer
.
cancel
()
MediaPlayerManager
.
getInstance
(
this
).
stop
()
MediaPlayerManager
.
getInstance
(
this
).
release
()
}
companion
object
{
companion
object
{
const
val
request_code
=
0
x0001
}
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/activity/PlayPureMusicActivity.kt
deleted
100644 → 0
View file @
a5f63d1f
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
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/bean/CollectResultModule.kt
0 → 100644
View file @
f17e2613
package
com.yidianling.muse.bean
data class
CollectResultModule
(
val
status
:
Int
)
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/bean/MeditationCollectRequestModule.kt
0 → 100644
View file @
f17e2613
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
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/bean/MeditationPlayModuleBean.kt
0 → 100644
View file @
f17e2613
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
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/http/MuseHttp.kt
View file @
f17e2613
package
com.yidianling.home.http
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.yidianling.muse.bean.CollectResultModule
import
com.yidianling.muse.bean.MeditationCollectRequestModule
import
com.yidianling.muse.bean.MeditationPlayModuleBean
import
com.yidianling.muse.bean.MuseModuleBean
import
io.reactivex.Observable
...
...
@@ -37,4 +42,32 @@ class MuseHttp {
fun
newMuseRequest
():
Observable
<
BaseAPIResponse
<
MuseModuleBean
>>
{
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
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/http/MusePagerApi.kt
View file @
f17e2613
...
...
@@ -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_JAVA
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
io.reactivex.Observable
import
retrofit2.http.GET
import
retrofit2.http.Headers
import
retrofit2.http.*
/**
* @author jiucheng
...
...
@@ -21,4 +23,35 @@ interface MusePagerApi {
@GET
(
"meditation/meditation/list"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
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
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/utils/MediaPlayerTimeUtil.kt
View file @
f17e2613
...
...
@@ -34,6 +34,36 @@ class MediaPlayerTimeUtil {
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
This diff is collapsed.
Click to expand it.
m-muse/src/main/res/layout/activity_play_meditation.xml
View file @
f17e2613
...
...
@@ -4,7 +4,8 @@
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:layout_height=
"match_parent"
tools:background=
"@color/_8c"
>
<ImageView
android:id=
"@+id/iv_bg"
...
...
@@ -38,9 +39,9 @@
app:layout_constraintTop_toTopOf=
"parent"
/>
<View
android:layout_width=
"
1
dp"
android:layout_width=
"
0.5
dp"
android:layout_height=
"20dp"
android:background=
"#FF
8E8E8E
"
android:background=
"#FF
E8E8E8
"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -99,16 +100,6 @@
app:layout_constraintTop_toBottomOf=
"@id/tv_title"
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"
/>
<androidx.constraintlayout.widget.Guideline
...
...
@@ -116,7 +107,37 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
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
android:id=
"@+id/iv_collect"
...
...
@@ -129,6 +150,17 @@
app:layout_constraintEnd_toStartOf=
"@id/guide_line"
/>
<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:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -136,7 +168,8 @@
android:layout_marginBottom=
"48dp"
android:src=
"@drawable/icon_play_meditation_time_off"
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
android:id=
"@+id/tv_time_off"
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/res/layout/activity_play_pure_music.xml
deleted
100644 → 0
View file @
a5f63d1f
<?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
This diff is collapsed.
Click to expand it.
m-muse/src/main/res/layout/layout_wheel_item.xml
deleted
100644 → 0
View file @
a5f63d1f
<?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
This diff is collapsed.
Click to expand it.
m-muse/src/main/res/layout/player_control_view.xml
View file @
f17e2613
...
...
@@ -88,7 +88,7 @@
android:id=
"@+id/exo_duration"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin
End
=
"12dp"
android:layout_margin
Start
=
"12dp"
android:textColor=
"#B3FFFFFF"
android:textSize=
"12sp"
app:layout_constraintBottom_toBottomOf=
"@id/seekbar_play_progress"
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment