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
5305185d
Commit
5305185d
authored
2 years ago
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
meditation play float view
parent
09ce85ea
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
377 additions
and
47 deletions
+377
-47
MainActivity.kt
app/src/main/java/com/ydl/component/MainActivity.kt
+12
-1
config.gradle
config.gradle
+4
-4
MeditationTypeAdapter.kt
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
+16
-10
build.gradle
m-muse/build.gradle
+2
-2
AndroidManifest.xml
m-muse/src/main/AndroidManifest.xml
+6
-0
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+22
-4
MeditationPlayModuleBean.kt
m-muse/src/main/java/com/yidianling/muse/bean/MeditationPlayModuleBean.kt
+8
-1
MeditationFloatEvent.kt
m-muse/src/main/java/com/yidianling/muse/event/MeditationFloatEvent.kt
+9
-0
FloatViewTouchListener.kt
m-muse/src/main/java/com/yidianling/muse/helper/FloatViewTouchListener.kt
+5
-2
MeditationViewModel.kt
m-muse/src/main/java/com/yidianling/muse/helper/MeditationViewModel.kt
+0
-16
MeditationWindowService.kt
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
+247
-0
icon_meditation_float_pause.xml
m-muse/src/main/res/drawable/icon_meditation_float_pause.xml
+12
-0
icon_meditation_float_play.xml
m-muse/src/main/res/drawable/icon_meditation_float_play.xml
+18
-0
layout_meditation_play_float_view.xml
m-muse/src/main/res/layout/layout_meditation_play_float_view.xml
+16
-7
No files found.
app/src/main/java/com/ydl/component/MainActivity.kt
View file @
5305185d
...
@@ -30,6 +30,8 @@ import com.yidianling.common.tools.LogUtil
...
@@ -30,6 +30,8 @@ import com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.consultant.api.IConsultantService
import
com.yidianling.consultant.api.IConsultantService
import
com.yidianling.fm.api.service.IFMService
import
com.yidianling.fm.api.service.IFMService
import
com.yidianling.muse.helper.MediaPlayerManager
import
com.yidianling.muse.service.MeditationWindowService
import
com.yidianling.tests.home.NewTestHomeActivity
import
com.yidianling.tests.home.NewTestHomeActivity
import
com.yidianling.user.StatusUtils
import
com.yidianling.user.StatusUtils
import
com.yidianling.user.ui.collect.CollectSexAndBirthActivity
import
com.yidianling.user.ui.collect.CollectSexAndBirthActivity
...
@@ -52,6 +54,8 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
...
@@ -52,6 +54,8 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
private
var
secretDialog
:
SecretDialog
?
=
null
private
var
secretDialog
:
SecretDialog
?
=
null
protected
var
playService
:
PlayService
?
=
null
protected
var
playService
:
PlayService
?
=
null
private
var
meditationIntent
:
Intent
?=
null
override
fun
getContentViewId
():
Int
{
override
fun
getContentViewId
():
Int
{
return
R
.
id
.
lce_content_view
return
R
.
id
.
lce_content_view
}
}
...
@@ -82,6 +86,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
...
@@ -82,6 +86,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// 初始化一键登录sdk
// 初始化一键登录sdk
OneKeyLoginHelp
.
sdkInit
(
this
,
OneKeyLoginHelp
.
YDL_USER_APP
,
PhoneNumberAuthHelper
.
SERVICE_TYPE_LOGIN
)
OneKeyLoginHelp
.
sdkInit
(
this
,
OneKeyLoginHelp
.
YDL_USER_APP
,
PhoneNumberAuthHelper
.
SERVICE_TYPE_LOGIN
)
bindService
()
bindService
()
meditationIntent
=
Intent
(
this
,
MeditationWindowService
::
class
.
java
)
startService
(
meditationIntent
)
reLoadData
()
reLoadData
()
requestPermission
()
requestPermission
()
bt_mdt
.
setOnClickListener
{
bt_mdt
.
setOnClickListener
{
...
@@ -273,6 +281,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
...
@@ -273,6 +281,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
if
(
serviceConnection
!=
null
)
{
if
(
serviceConnection
!=
null
)
{
unbindService
(
serviceConnection
)
unbindService
(
serviceConnection
)
}
}
if
(
meditationIntent
!=
null
){
MediaPlayerManager
.
getInstance
(
this
)
?.
stop
()
stopService
(
meditationIntent
)
}
super
.
onDestroy
()
super
.
onDestroy
()
}
}
...
@@ -286,7 +298,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
...
@@ -286,7 +298,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
}
}
}
}
private
fun
showEnsureDialog
()
{
private
fun
showEnsureDialog
()
{
secretDialog
=
SecretDialog
(
this
,
object
:
OnSecretDialogListener
{
secretDialog
=
SecretDialog
(
this
,
object
:
OnSecretDialogListener
{
override
fun
onCancel
()
{
override
fun
onCancel
()
{
...
...
This diff is collapsed.
Click to expand it.
config.gradle
View file @
5305185d
...
@@ -9,12 +9,12 @@ ext {
...
@@ -9,12 +9,12 @@ ext {
"m-consultant"
:
"0.0.60.25"
,
"m-consultant"
:
"0.0.60.25"
,
"m-fm"
:
"0.0.30.08"
,
"m-fm"
:
"0.0.30.08"
,
"m-user"
:
"0.0.62.12"
,
"m-user"
:
"0.0.62.12"
,
"m-home"
:
"0.0.23.5
6
"
,
"m-home"
:
"0.0.23.5
7
"
,
"m-im"
:
"0.0.21.44"
,
"m-im"
:
"0.0.21.44"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-article"
:
"0.0.0.10"
,
"m-article"
:
"0.0.0.10"
,
"m-muse"
:
"0.0.28.3
5
"
,
"m-muse"
:
"0.0.28.3
6
"
,
"m-tests"
:
"0.0.24.18"
,
"m-tests"
:
"0.0.24.18"
,
"m-course"
:
"0.0.43.37"
,
"m-course"
:
"0.0.43.37"
,
...
@@ -94,12 +94,12 @@ ext {
...
@@ -94,12 +94,12 @@ ext {
"m-consultant"
:
"0.0.60.25"
,
"m-consultant"
:
"0.0.60.25"
,
"m-fm"
:
"0.0.30.08"
,
"m-fm"
:
"0.0.30.08"
,
"m-user"
:
"0.0.62.12"
,
"m-user"
:
"0.0.62.12"
,
"m-home"
:
"0.0.23.5
6
"
,
"m-home"
:
"0.0.23.5
7
"
,
"m-im"
:
"0.0.21.44"
,
"m-im"
:
"0.0.21.44"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-article"
:
"0.0.0.8"
,
"m-article"
:
"0.0.0.8"
,
"m-muse"
:
"0.0.28.3
5
"
,
"m-muse"
:
"0.0.28.3
6
"
,
"m-tests"
:
"0.0.24.18"
,
"m-tests"
:
"0.0.24.18"
,
"m-course"
:
"0.0.43.37"
,
"m-course"
:
"0.0.43.37"
,
//-------------- 业务模块 API 层 --------------
//-------------- 业务模块 API 层 --------------
...
...
This diff is collapsed.
Click to expand it.
m-home/src/main/java/com/yidianling/home/MeditationTypeAdapter.kt
View file @
5305185d
...
@@ -22,12 +22,12 @@ import kotlinx.android.synthetic.ydl.home_fragment.*
...
@@ -22,12 +22,12 @@ import kotlinx.android.synthetic.ydl.home_fragment.*
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
moreLink
:
String
,
private
val
moreLink
:
String
?
,
private
val
homeLink
:
String
?=
null
,
private
val
homeLink
:
String
?=
null
,
private
val
cateId
:
Long
?=
null
,
private
val
cateId
:
Long
?=
null
,
private
val
mark
:
Int
?=
null
,
private
val
mark
:
Int
?=
null
,
private
val
meditationType
:
Int
private
val
meditationType
:
Int
?
=
null
)
:
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
{
...
@@ -54,13 +54,13 @@ class MeditationTypeAdapter(
...
@@ -54,13 +54,13 @@ class MeditationTypeAdapter(
is
MeditationTypeViewHolder
->
{
is
MeditationTypeViewHolder
->
{
holder
.
ivType
?.
let
{
holder
.
ivType
?.
let
{
Glide
.
with
(
context
)
Glide
.
with
(
context
)
.
load
(
data
[
position
]
.
coverImageUrl
)
.
load
(
data
?.
get
(
position
)
?
.
coverImageUrl
)
.
transition
(
DrawableTransitionOptions
.
withCrossFade
())
.
transition
(
DrawableTransitionOptions
.
withCrossFade
())
.
into
(
it
)
.
into
(
it
)
}
}
holder
.
tvName
?.
let
{
holder
.
tvName
?.
let
{
it
.
text
=
data
[
position
].
title
it
.
text
=
data
?.
get
(
position
)
?.
title
?:
""
}
}
holder
.
cvLayout
?.
setOnClickListener
{
holder
.
cvLayout
?.
setOnClickListener
{
...
@@ -72,8 +72,11 @@ class MeditationTypeAdapter(
...
@@ -72,8 +72,11 @@ class MeditationTypeAdapter(
if
(!
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
loginByOneKeyLogin
(
context
,
true
)){
if
(!
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
loginByOneKeyLogin
(
context
,
true
)){
return
@setOnClickListener
return
@setOnClickListener
}
}
if
(
data
==
null
){
return
@setOnClickListener
}
ARouter
.
getInstance
().
build
(
"/muse/play"
)
ARouter
.
getInstance
().
build
(
"/muse/play"
)
.
withLong
(
"MEDITATION_ID"
,
data
[
position
].
meditationId
)
.
withLong
(
"MEDITATION_ID"
,
data
[
position
]
?
.
meditationId
)
.
withInt
(
"MEDITATION_TYPE"
,
meditationType
)
.
withInt
(
"MEDITATION_TYPE"
,
meditationType
)
.
withFloat
(
"MEDIA_DURATION"
,
data
[
position
].
duration
?:
0.0f
)
.
withFloat
(
"MEDIA_DURATION"
,
data
[
position
].
duration
?:
0.0f
)
.
withString
(
"MEDIA_URL"
,
data
[
position
].
mediaIdCoverImageUrl
)
.
withString
(
"MEDIA_URL"
,
data
[
position
].
mediaIdCoverImageUrl
)
...
@@ -84,7 +87,10 @@ class MeditationTypeAdapter(
...
@@ -84,7 +87,10 @@ class MeditationTypeAdapter(
//防止连击
//防止连击
return
@setOnClickListener
return
@setOnClickListener
}
}
val
homeLink
=
"${homeLink}mark=$mark&cateId=$cateId&meditationId=${data[position].meditationId}"
if
(
data
==
null
){
return
@setOnClickListener
}
val
homeLink
=
"${homeLink}mark=$mark&cateId=$cateId&meditationId=${data[position]?.meditationId}"
if
(!
homeLink
.
isNullOrBlank
())
{
if
(!
homeLink
.
isNullOrBlank
())
{
NewH5Activity
.
start
(
context
,
H5Params
(
homeLink
,
null
))
NewH5Activity
.
start
(
context
,
H5Params
(
homeLink
,
null
))
}
}
...
@@ -108,17 +114,17 @@ class MeditationTypeAdapter(
...
@@ -108,17 +114,17 @@ class MeditationTypeAdapter(
}
}
override
fun
getItemCount
():
Int
{
override
fun
getItemCount
():
Int
{
return
if
(
data
.
isNotEmpty
()
)
{
return
if
(
data
?.
isNotEmpty
()
==
true
)
{
data
.
size
+
1
data
.
size
+
1
}
else
{
}
else
{
data
.
size
0
}
}
}
}
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
{
return
if
(
data
.
isNotEmpty
()
&&
position
==
data
.
size
)
{
return
if
(
data
?.
isNotEmpty
()
==
true
&&
position
==
data
.
size
)
{
FOOTER_TYPE
FOOTER_TYPE
}
else
{
}
else
{
CONTENT_TYPE
CONTENT_TYPE
...
...
This diff is collapsed.
Click to expand it.
m-muse/build.gradle
View file @
5305185d
...
@@ -59,11 +59,11 @@ dependencies {
...
@@ -59,11 +59,11 @@ dependencies {
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
implementation
'com.github.weidongjian:androidWheelView:1.0.0'
implementation
'com.github.weidongjian:androidWheelView:1.0.0'
implementation
'com.github.feeeei:CircleSeekbar:v1.1.2'
// solve build problem
// solve build problem
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// cannot access 'androidx.lifecycle.hasdefaultviewmodelproviderfactory'
// Comment out when compiling
// Comment out when compiling
// implementation "androidx.lifecycle:lifecycle-extensions:2.2
.0"
implementation
"androidx.lifecycle:lifecycle-extensions:2.0
.0"
implementation
"com.alibaba:arouter-api:$arouter_api"
implementation
"com.alibaba:arouter-api:$arouter_api"
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/AndroidManifest.xml
View file @
5305185d
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.yidianling.muse"
>
package=
"com.yidianling.muse"
>
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<application>
<application>
<activity
<activity
android:name=
".activity.MuseActivity"
android:name=
".activity.MuseActivity"
...
@@ -18,5 +21,8 @@
...
@@ -18,5 +21,8 @@
android:name=
".activity.MeditationTimeOffActivity"
android:name=
".activity.MeditationTimeOffActivity"
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
android:theme=
"@style/platform_NoTitleTheme"
/>
android:theme=
"@style/platform_NoTitleTheme"
/>
<service
android:name=
".service.MeditationWindowService"
/>
</application>
</application>
</manifest>
</manifest>
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
5305185d
...
@@ -3,6 +3,7 @@ package com.yidianling.muse.activity
...
@@ -3,6 +3,7 @@ package com.yidianling.muse.activity
import
android.content.Intent
import
android.content.Intent
import
android.media.MediaPlayer
import
android.media.MediaPlayer
import
android.os.Bundle
import
android.os.Bundle
import
android.os.Handler
import
android.view.View
import
android.view.View
import
android.widget.SeekBar
import
android.widget.SeekBar
import
com.alibaba.android.arouter.facade.annotation.Route
import
com.alibaba.android.arouter.facade.annotation.Route
...
@@ -23,6 +24,7 @@ import com.yidianling.common.tools.ToastUtil
...
@@ -23,6 +24,7 @@ import com.yidianling.common.tools.ToastUtil
import
com.yidianling.home.http.MuseHttp
import
com.yidianling.home.http.MuseHttp
import
com.yidianling.muse.R
import
com.yidianling.muse.R
import
com.yidianling.muse.bean.MeditationPlayModuleBean
import
com.yidianling.muse.bean.MeditationPlayModuleBean
import
com.yidianling.muse.event.MeditationFloatEvent
import
com.yidianling.muse.helper.MediaPlayerManager
import
com.yidianling.muse.helper.MediaPlayerManager
import
com.yidianling.muse.utils.MediaPlayerTimeUtil
import
com.yidianling.muse.utils.MediaPlayerTimeUtil
import
com.yidianling.muse.widget.QuitMeditationDialog
import
com.yidianling.muse.widget.QuitMeditationDialog
...
@@ -127,6 +129,9 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -127,6 +129,9 @@ class PlayMeditationActivity : BaseActivity() {
mediaListLink
=
module
.
playDetailUrl
mediaListLink
=
module
.
playDetailUrl
module
.
mediaList
?.
forEach
{
meditationPlayBean
->
module
.
mediaList
?.
forEach
{
meditationPlayBean
->
if
(
meditationPlayBean
.
mediaId
==
mediaId
)
{
if
(
meditationPlayBean
.
mediaId
==
mediaId
)
{
currentMeditation
=
meditationPlayBean
.
copy
(
mediaType
=
meditationType
,
meditationId
=
meditationId
!!
)
mediaId
=
module
?.
mediaId
?:
0L
mediaId
=
module
?.
mediaId
?:
0L
val
title
=
meditationPlayBean
.
title
?:
"未知标题"
val
title
=
meditationPlayBean
.
title
?:
"未知标题"
val
desc
=
meditationPlayBean
.
desc
?:
""
val
desc
=
meditationPlayBean
.
desc
?:
""
...
@@ -188,7 +193,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -188,7 +193,7 @@ class PlayMeditationActivity : BaseActivity() {
if
(
meditationPlayBean
.
mediaId
==
mediaId
)
{
if
(
meditationPlayBean
.
mediaId
==
mediaId
)
{
currentMeditation
=
meditationPlayBean
currentMeditation
=
meditationPlayBean
.
copy
(
meditationId
=
meditationId
!!
)
mediaId
=
module
?.
mediaId
?:
0L
mediaId
=
module
?.
mediaId
?:
0L
val
title
=
meditationPlayBean
.
title
val
title
=
meditationPlayBean
.
title
...
@@ -239,6 +244,9 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -239,6 +244,9 @@ class PlayMeditationActivity : BaseActivity() {
}
}
private
fun
updateUIByMeditationType
()
{
private
fun
updateUIByMeditationType
()
{
val
event
=
MeditationFloatEvent
(
false
)
EventBus
.
getDefault
().
post
(
event
)
// 声音类型
// 声音类型
if
(
meditationType
==
0
)
{
if
(
meditationType
==
0
)
{
exo_rew
.
visibility
=
View
.
GONE
exo_rew
.
visibility
=
View
.
GONE
...
@@ -370,7 +378,17 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -370,7 +378,17 @@ class PlayMeditationActivity : BaseActivity() {
}
}
iv_back
.
setOnClickListener
{
iv_back
.
setOnClickListener
{
finish
()
// MeditationViewModel.isVisible.postValue(true)
// MeditationViewModel.meditation.postValue(currentMeditation)
// MeditationViewModel.meditations.postValue(meditations as ArrayList<MeditationPlayModuleBean.MeditationDetail>)
// LogUtil.d("Lancet=======","post $currentMeditation")
val
event
=
MeditationFloatEvent
(
true
,
meditationDetail
=
currentMeditation
)
EventBus
.
getDefault
().
post
(
event
)
Handler
().
postDelayed
({
finish
()
},
300
)
}
}
iv_share
.
setOnClickListener
{
iv_share
.
setOnClickListener
{
...
@@ -447,7 +465,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -447,7 +465,7 @@ class PlayMeditationActivity : BaseActivity() {
postPlayRecord
(
isQuit
=
0
,
playTime
=
0
,
isComplete
=
0
)
postPlayRecord
(
isQuit
=
0
,
playTime
=
0
,
isComplete
=
0
)
val
meditation
=
meditations
[
currentPosition
-
1
]
val
meditation
=
meditations
[
currentPosition
-
1
]
currentMeditation
=
meditation
currentMeditation
=
meditation
.
copy
(
meditationId
=
meditationId
!!
)
mediaId
=
meditation
.
mediaId
mediaId
=
meditation
.
mediaId
val
mediaCoverUrl
=
meditation
.
coverImageUrl
val
mediaCoverUrl
=
meditation
.
coverImageUrl
...
@@ -567,7 +585,7 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -567,7 +585,7 @@ class PlayMeditationActivity : BaseActivity() {
mMediaPlayer
?.
setOnCompletionListener
{
mMediaPlayer
?.
setOnCompletionListener
{
postPlayRecord
(
isQuit
=
0
,
postPlayRecord
(
isQuit
=
0
,
playTime
=
mMediaPlayer
?.
duration
?:
0
,
playTime
=
(
seekbar_play_progress
.
progress
/
1000.00
).
roundToInt
()
,
isComplete
=
1
)
isComplete
=
1
)
isPlaying
=
if
(
it
.
isPlaying
)
{
isPlaying
=
if
(
it
.
isPlaying
)
{
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_play
)
exo_play
.
setImageResource
(
R
.
drawable
.
icon_pause_play
)
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/bean/MeditationPlayModuleBean.kt
View file @
5305185d
...
@@ -16,7 +16,9 @@ class MeditationPlayModuleBean : HomeItemBaseBean {
...
@@ -16,7 +16,9 @@ class MeditationPlayModuleBean : HomeItemBaseBean {
var
mediaList
:
ArrayList
<
MeditationDetail
>?
=
null
var
mediaList
:
ArrayList
<
MeditationDetail
>?
=
null
data class
MeditationDetail
(
data class
MeditationDetail
(
val
mediaId
:
Long
,
val
mediaType
:
Int
?
=
null
,
val
mediaId
:
Long
?=
null
,
val
meditationId
:
Long
,
val
title
:
String
,
val
title
:
String
,
val
author
:
String
,
val
author
:
String
,
val
coverImageUrl
:
String
,
val
coverImageUrl
:
String
,
...
@@ -30,4 +32,8 @@ class MeditationPlayModuleBean : HomeItemBaseBean {
...
@@ -30,4 +32,8 @@ class MeditationPlayModuleBean : HomeItemBaseBean {
val
coverImageUrlIcon
:
String
val
coverImageUrlIcon
:
String
)
)
override
fun
toString
():
String
{
return
"MeditationPlayModuleBean(meditationId=$meditationId, mediaId=$mediaId, mediaType=$mediaType, playDetailUrl=$playDetailUrl, mediaList=$mediaList)"
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/event/MeditationFloatEvent.kt
0 → 100644
View file @
5305185d
package
com.yidianling.muse.event
import
com.yidianling.muse.bean.MeditationPlayModuleBean
class
MeditationFloatEvent
(
val
show
:
Boolean
,
val
meditationDetail
:
MeditationPlayModuleBean
.
MeditationDetail
?=
null
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/helper/FloatViewTouchListener.kt
View file @
5305185d
...
@@ -3,9 +3,10 @@ package com.yidianling.muse.helper
...
@@ -3,9 +3,10 @@ package com.yidianling.muse.helper
import
android.view.MotionEvent
import
android.view.MotionEvent
import
android.view.View
import
android.view.View
import
android.view.WindowManager
import
android.view.WindowManager
import
com.ydl.ydlcommon.utils.LogUtil
class
FloatViewTouchListener
(
val
wl
:
WindowManager
.
LayoutParams
,
val
windowManager
:
WindowManager
)
:
class
FloatViewTouchListener
(
val
wl
:
WindowManager
.
LayoutParams
,
val
windowManager
:
WindowManager
)
:
View
.
OnTouchListener
{
View
.
OnTouchListener
{
private
var
x
=
0
private
var
x
=
0
private
var
y
=
0
private
var
y
=
0
override
fun
onTouch
(
view
:
View
,
motionEvent
:
MotionEvent
):
Boolean
{
override
fun
onTouch
(
view
:
View
,
motionEvent
:
MotionEvent
):
Boolean
{
...
@@ -26,6 +27,8 @@ View.OnTouchListener{
...
@@ -26,6 +27,8 @@ View.OnTouchListener{
x
+=
movedX
x
+=
movedX
y
+=
movedY
y
+=
movedY
}
}
LogUtil
.
d
(
"Lancet======="
,
"nowY=====$nowY"
)
LogUtil
.
d
(
"Lancet======="
,
"movedY=====$movedY"
)
//更新悬浮窗位置
//更新悬浮窗位置
windowManager
.
updateViewLayout
(
view
,
wl
)
windowManager
.
updateViewLayout
(
view
,
wl
)
}
}
...
...
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/helper/MeditationViewModel.kt
deleted
100644 → 0
View file @
09ce85ea
package
com.yidianling.muse.helper
import
androidx.lifecycle.MutableLiveData
import
androidx.lifecycle.ViewModel
object
MeditationViewModel
:
ViewModel
()
{
//悬浮窗口创建 移除 基于无障碍服务
var
isShowWindow
=
MutableLiveData
<
Boolean
>()
//悬浮窗口创建 移除
var
isShowSuspendWindow
=
MutableLiveData
<
Boolean
>()
//悬浮窗口显示 隐藏
var
isVisible
=
MutableLiveData
<
Boolean
>()
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
0 → 100644
View file @
5305185d
package
com.yidianling.muse.service
import
android.content.Intent
import
android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import
android.graphics.PixelFormat
import
android.media.MediaPlayer
import
android.os.Build
import
android.util.DisplayMetrics
import
android.view.Gravity
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import
android.view.WindowManager
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.lifecycle.LifecycleService
import
com.bumptech.glide.Glide
import
com.ydl.ydlcommon.data.http.ThrowableConsumer
import
com.yidianling.home.http.MuseHttp
import
com.yidianling.muse.R
import
com.yidianling.muse.activity.PlayMeditationActivity
import
com.yidianling.muse.bean.MeditationPlayModuleBean
import
com.yidianling.muse.event.MeditationFloatEvent
import
com.yidianling.muse.helper.FloatViewTouchListener
import
com.yidianling.muse.helper.MediaPlayerManager
import
de.greenrobot.event.EventBus
import
io.feeeei.circleseekbar.CircleSeekBar
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
java.util.*
import
kotlin.math.roundToInt
class
MeditationWindowService
:
LifecycleService
()
{
private
lateinit
var
mWindowManager
:
WindowManager
private
var
floatRootView
:
View
?
=
null
private
var
ivClose
:
ImageView
?
=
null
private
var
ivCover
:
ImageView
?
=
null
private
var
tvTitle
:
TextView
?
=
null
private
var
ivProgress
:
CircleSeekBar
?
=
null
private
var
ivPlayOrPause
:
ImageView
?
=
null
private
var
mMediaPlayer
:
MediaPlayer
?
=
null
private
var
mTimer
=
Timer
()
private
var
mCurrentMeditation
:
MeditationPlayModuleBean
.
MeditationDetail
?
=
null
private
var
windowIsShow
=
false
override
fun
onCreate
()
{
super
.
onCreate
()
EventBus
.
getDefault
().
register
(
this
)
}
private
fun
showWindow
()
{
mWindowManager
=
getSystemService
(
WINDOW_SERVICE
)
as
WindowManager
val
outMetrics
=
DisplayMetrics
()
mWindowManager
.
defaultDisplay
.
getMetrics
(
outMetrics
)
var
layoutParams
=
WindowManager
.
LayoutParams
().
apply
{
type
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
WindowManager
.
LayoutParams
.
TYPE_APPLICATION_OVERLAY
}
else
{
WindowManager
.
LayoutParams
.
TYPE_PHONE
}
flags
=
WindowManager
.
LayoutParams
.
FLAG_NOT_TOUCH_MODAL
or
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
format
=
PixelFormat
.
RGBA_8888
width
=
outMetrics
.
widthPixels
-
dp2px
(
32F
)
height
=
WRAP_CONTENT
gravity
=
Gravity
.
CENTER_HORIZONTAL
or
Gravity
.
BOTTOM
}
floatRootView
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
layout_meditation_play_float_view
,
null
)
ivClose
=
floatRootView
?.
findViewById
(
R
.
id
.
iv_close
)
ivCover
=
floatRootView
?.
findViewById
(
R
.
id
.
iv_cover
)
tvTitle
=
floatRootView
?.
findViewById
(
R
.
id
.
tv_title
)
ivProgress
=
floatRootView
?.
findViewById
(
R
.
id
.
progress_bar
)
ivPlayOrPause
=
floatRootView
?.
findViewById
(
R
.
id
.
iv_play_status
)
floatRootView
?.
setOnTouchListener
(
FloatViewTouchListener
(
layoutParams
,
mWindowManager
))
mWindowManager
.
addView
(
floatRootView
,
layoutParams
)
windowIsShow
=
true
}
fun
onEventMainThread
(
event
:
MeditationFloatEvent
)
{
if
(!
event
.
show
)
{
hideFloatWindow
()
}
if
(
event
.
show
&&
event
.
meditationDetail
!=
null
)
{
if
(!
windowIsShow
)
{
showWindow
()
}
updateFloatView
(
event
.
meditationDetail
)
}
}
private
fun
updateFloatView
(
meditation
:
MeditationPlayModuleBean
.
MeditationDetail
)
{
mMediaPlayer
=
MediaPlayerManager
.
getInstance
(
this
)
?.
getMediaPlayer
()
floatRootView
?.
setOnClickListener
{
val
intent
=
Intent
(
this
,
PlayMeditationActivity
::
class
.
java
)
intent
.
putExtra
(
"MEDIA_ID"
,
meditation
.
mediaId
)
intent
.
putExtra
(
"MEDITATION_ID"
,
meditation
.
meditationId
)
intent
.
putExtra
(
"MEDITATION_TYPE"
,
meditation
.
mediaType
)
intent
.
putExtra
(
"MEDIA_COVER_URL"
,
meditation
.
coverImageUrl
)
intent
.
flags
=
FLAG_ACTIVITY_NEW_TASK
startActivity
(
intent
)
}
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
ivPlayOrPause
?.
setImageResource
(
R
.
drawable
.
icon_meditation_float_play
)
}
else
{
ivPlayOrPause
?.
setImageResource
(
R
.
drawable
.
icon_meditation_float_pause
)
}
ivProgress
?.
maxProcess
=
mMediaPlayer
?.
duration
?:
0
ivProgress
?.
curProcess
=
mMediaPlayer
?.
currentPosition
?:
0
Glide
.
with
(
floatRootView
!!
)
.
load
(
meditation
.
coverImageUrl
)
.
into
(
ivCover
!!
)
tvTitle
?.
text
=
meditation
.
title
ivPlayOrPause
?.
setOnClickListener
{
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
MediaPlayerManager
.
getInstance
(
this
)
?.
pause
()
if
(
meditation
.
meditationId
!=
null
&&
meditation
.
mediaId
!=
null
)
{
MuseHttp
.
getInstance
().
postMeditationPlayRecord
(
meditationId
=
meditation
.
meditationId
!!
.
toInt
(),
isQuit
=
1
,
mediaId
=
meditation
.
mediaId
!!
,
playTime
=
(
ivProgress
?.
curProcess
?.
div
(
1000.00
))
?.
roundToInt
()
?:
0
,
isComplete
=
0
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
},
{
object
:
ThrowableConsumer
()
{
override
fun
accept
(
msg
:
String
)
{
}
}
})
}
}
else
{
MediaPlayerManager
.
getInstance
(
this
)
?.
play
()
}
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
ivPlayOrPause
?.
setImageResource
(
R
.
drawable
.
icon_meditation_float_play
)
}
else
{
ivPlayOrPause
?.
setImageResource
(
R
.
drawable
.
icon_meditation_float_pause
)
}
}
mTimer
.
schedule
(
object
:
TimerTask
()
{
override
fun
run
()
{
ivProgress
?.
curProcess
=
mMediaPlayer
?.
currentPosition
?:
0
}
},
0
,
50
)
mMediaPlayer
?.
setOnCompletionListener
{
postPlayRecord
(
0
,
(
ivProgress
?.
curProcess
?.
div
(
1000.00
))
?.
roundToInt
()
?:
0
,
1
,
meditation
.
meditationId
.
toInt
(),
meditation
.
mediaId
?:
0L
)
}
ivClose
?.
setOnClickListener
{
postPlayRecord
(
1
,
(
ivProgress
?.
curProcess
?.
div
(
1000.00
))
?.
roundToInt
()
?:
0
,
0
,
meditation
.
meditationId
.
toInt
(),
meditation
.
mediaId
?:
0L
)
MediaPlayerManager
.
getInstance
(
this
)
?.
stop
()
hideFloatWindow
()
}
}
private
fun
hideFloatWindow
()
{
if
(
floatRootView
!=
null
&&
floatRootView
?.
windowToken
!=
null
)
{
if
(
mWindowManager
!=
null
)
{
windowIsShow
=
false
mTimer
.
cancel
()
mWindowManager
.
removeViewImmediate
(
floatRootView
)
}
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
if
(
EventBus
.
getDefault
().
isRegistered
(
this
))
{
EventBus
.
getDefault
().
unregister
(
this
)
}
}
private
fun
dp2px
(
dp
:
Float
):
Int
{
val
scale
=
resources
.
displayMetrics
.
density
return
(
dp
*
scale
+
0.5f
).
toInt
()
}
private
fun
postPlayRecord
(
isQuit
:
Int
,
playTime
:
Int
,
isComplete
:
Int
,
meditationId
:
Int
,
mediaId
:
Long
)
{
MuseHttp
.
getInstance
().
postMeditationPlayRecord
(
meditationId
=
meditationId
,
isQuit
=
isQuit
,
mediaId
=
mediaId
,
playTime
=
playTime
,
isComplete
=
isComplete
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
},
{
object
:
ThrowableConsumer
()
{
override
fun
accept
(
msg
:
String
)
{
}
}
})
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
m-muse/src/main/res/drawable/icon_meditation_float_pause.xml
0 → 100644
View file @
5305185d
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"8dp"
android:height=
"9dp"
android:viewportWidth=
"8"
android:viewportHeight=
"9"
>
<path
android:pathData=
"M6.64877,5.7528L1.82138,8.7257C1.46481,8.94528 0.99774,8.83422 0.77811,8.47766C0.7045,8.35811 0.66553,8.22046 0.66553,8.08006L0.66553,0.84302C0.66553,0.42426 1.005,0.08478 1.42377,0.08478C1.56418,0.08478 1.70181,0.12375 1.82138,0.19738L6.64877,3.17028C7.36191,3.60946 7.58401,4.54359 7.14481,5.25674C7.02051,5.4586 6.85062,5.62849 6.64877,5.7528L6.64877,5.7528Z"
android:strokeWidth=
"1"
android:fillColor=
"#FFFFFF"
android:fillType=
"nonZero"
android:strokeColor=
"#00000000"
/>
</vector>
This diff is collapsed.
Click to expand it.
m-muse/src/main/res/drawable/icon_meditation_float_play.xml
0 → 100644
View file @
5305185d
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"9dp"
android:height=
"9dp"
android:viewportWidth=
"9"
android:viewportHeight=
"9"
>
<path
android:pathData=
"M1.97559,0.16724C2.66594,0.16724 3.22559,0.72688 3.22559,1.41724L3.22559,6.91724C3.22559,7.60759 2.66594,8.16724 1.97559,8.16724C1.28523,8.16724 0.72559,7.60759 0.72559,6.91724L0.72559,1.41724C0.72559,0.72688 1.28523,0.16724 1.97559,0.16724Z"
android:strokeWidth=
"1"
android:fillColor=
"#FFFFFF"
android:fillType=
"evenOdd"
android:strokeColor=
"#00000000"
/>
<path
android:pathData=
"M6.97559,0.16724C7.66594,0.16724 8.22559,0.72688 8.22559,1.41724L8.22559,6.91724C8.22559,7.60759 7.66594,8.16724 6.97559,8.16724C6.28523,8.16724 5.72559,7.60759 5.72559,6.91724L5.72559,1.41724C5.72559,0.72688 6.28523,0.16724 6.97559,0.16724Z"
android:strokeWidth=
"1"
android:fillColor=
"#FFFFFF"
android:fillType=
"evenOdd"
android:strokeColor=
"#00000000"
/>
</vector>
This diff is collapsed.
Click to expand it.
m-muse/src/main/res/layout/layout_meditation_play_float_view.xml
View file @
5305185d
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
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:background=
"@drawable/bg_play_meditation_float_view"
android:layout_marginHorizontal=
"16dp"
android:layout_marginBottom=
"20dp"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
...
@@ -9,9 +12,8 @@
...
@@ -9,9 +12,8 @@
android:id=
"@+id/csl_root_layout"
android:id=
"@+id/csl_root_layout"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"56dp"
android:layout_height=
"56dp"
tools:background=
"@drawable/play_float_background"
android:background=
"@drawable/bg_play_meditation_float_view"
android:background=
"@drawable/bg_play_meditation_float_view"
android:layout_marginHorizontal=
"16dp
"
>
tools:background=
"@drawable/play_float_background
"
>
<ImageView
<ImageView
android:id=
"@+id/iv_close"
android:id=
"@+id/iv_close"
...
@@ -40,6 +42,7 @@
...
@@ -40,6 +42,7 @@
android:id=
"@+id/iv_cover"
android:id=
"@+id/iv_cover"
android:layout_width=
"40dp"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_height=
"40dp"
android:scaleType=
"centerCrop"
android:src=
"@drawable/platform_loading_logo"
android:src=
"@drawable/platform_loading_logo"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
...
@@ -67,17 +70,23 @@
...
@@ -67,17 +70,23 @@
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
>
app:layout_constraintBottom_toBottomOf=
"parent"
>
<
Progress
Bar
<
io.feeeei.circleseekbar.CircleSeek
Bar
android:id=
"@+id/progress_bar"
android:id=
"@+id/progress_bar"
android:layout_width=
"24dp"
android:layout_width=
"24dp"
android:layout_height=
"24dp"
android:layout_height=
"24dp"
android:layout_gravity=
"center"
/>
android:layout_gravity=
"center"
app:wheel_unreached_color=
"#FF282E3F"
app:wheel_reached_color=
"#FFFFFF"
app:wheel_unreached_width=
"2dp"
app:wheel_reached_width=
"2dp"
/>
<ImageView
<ImageView
android:id=
"@+id/iv_play_status"
android:id=
"@+id/iv_play_status"
android:layout_width=
"wrap_content"
android:layout_width=
"20dp"
android:layout_height=
"wrap_content"
android:layout_height=
"20dp"
android:layout_gravity=
"center"
/>
android:padding=
"5dp"
android:layout_gravity=
"center"
android:src=
"@drawable/icon_meditation_float_pause"
/>
</FrameLayout>
</FrameLayout>
...
...
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