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
dcc24a08
Commit
dcc24a08
authored
May 26, 2022
by
刘鹏
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'd/lancet/4.3.93_muse' into 'd/4.3.93_muse'
fix 18162 See merge request app_android_lib/YDL-Component!56
parents
5ee5bcec
63dbb89e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
9 deletions
+77
-9
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+4
-0
MeditationFloatEvent.kt
m-muse/src/main/java/com/yidianling/muse/event/MeditationFloatEvent.kt
+2
-0
MeditationWindowService.kt
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
+71
-9
No files found.
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
dcc24a08
...
...
@@ -886,12 +886,16 @@ class PlayMeditationActivity : BaseActivity() {
mDisposable
?.
dispose
()
initRxTimeOff
((
minute
*
60
*
1000
).
toLong
(),
1
)
}
val
event
=
MeditationFloatEvent
(
false
,(
minute
*
60
*
1000
).
toLong
())
EventBus
.
getDefault
().
post
(
event
)
}
else
{
initPlayCompletionListener
()
mDisposable
?.
dispose
()
tv_time_off
.
visibility
=
View
.
GONE
tv_time_off_pure_music
.
visibility
=
View
.
GONE
mMediaPlayer
?.
isLooping
=
false
val
event
=
MeditationFloatEvent
(
false
,
0
)
EventBus
.
getDefault
().
post
(
event
)
}
}
}
...
...
m-muse/src/main/java/com/yidianling/muse/event/MeditationFloatEvent.kt
View file @
dcc24a08
...
...
@@ -4,5 +4,6 @@ import com.yidianling.muse.bean.MeditationPlayModuleBean
class
MeditationFloatEvent
(
val
show
:
Boolean
,
val
time
:
Long
?=
null
,
val
meditationDetail
:
MeditationPlayModuleBean
.
MeditationDetail
?=
null
)
\ No newline at end of file
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
View file @
dcc24a08
...
...
@@ -28,12 +28,20 @@ import com.yidianling.muse.activity.PlayMeditationActivity
import
com.yidianling.muse.bean.MeditationPlayModuleBean
import
com.yidianling.muse.constants.MuseBIConstants
import
com.yidianling.muse.event.MeditationFloatEvent
import
com.yidianling.muse.helper.FloatViewTouchListener
import
com.yidianling.muse.helper.MediaPlayerManager
import
com.yidianling.muse.utils.MediaPlayerTimeUtil
import
de.greenrobot.event.EventBus
import
io.feeeei.circleseekbar.CircleSeekBar
import
io.reactivex.Observable
import
io.reactivex.Observer
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.Disposable
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
import
kotlin.math.roundToInt
class
MeditationWindowService
:
LifecycleService
()
{
...
...
@@ -55,6 +63,10 @@ class MeditationWindowService : LifecycleService() {
private
var
windowIsShow
=
false
private
var
mDisposable
:
Disposable
?
=
null
private
var
mObservable
:
Observable
<
Long
>?
=
null
private
var
mObserver
:
Observer
<
Long
>?
=
null
override
fun
onCreate
()
{
super
.
onCreate
()
...
...
@@ -87,7 +99,7 @@ class MeditationWindowService : LifecycleService() {
format
=
PixelFormat
.
RGBA_8888
width
=
outMetrics
.
widthPixels
-
dp2px
(
32F
)
height
=
WRAP_CONTENT
gravity
=
Gravity
.
CENTER_HORIZONTAL
or
Gravity
.
TOP
gravity
=
Gravity
.
LEFT
or
Gravity
.
TOP
x
=
outMetrics
.
widthPixels
/
2
-
width
/
2
y
=
outMetrics
.
heightPixels
-
height
*
2
...
...
@@ -99,21 +111,31 @@ class MeditationWindowService : LifecycleService() {
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))
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
()
if
(
event
.
time
!=
null
){
if
(
event
.
time
>
0
){
initRxTimeOff
(
event
.
time
)
}
else
{
mDisposable
?.
dispose
()
}
}
else
{
if
(!
event
.
show
)
{
hideFloatWindow
()
}
if
(
event
.
show
&&
event
.
meditationDetail
!=
null
)
{
if
(!
windowIsShow
)
{
showWindow
()
}
updateFloatView
(
event
.
meditationDetail
)
}
updateFloatView
(
event
.
meditationDetail
)
}
}
private
fun
updateFloatView
(
meditation
:
MeditationPlayModuleBean
.
MeditationDetail
)
{
...
...
@@ -259,6 +281,46 @@ class MeditationWindowService : LifecycleService() {
return
(
dp
*
scale
+
0.5f
).
toInt
()
}
private
fun
initRxTimeOff
(
time
:
Long
)
{
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
)
{
}
override
fun
onError
(
e
:
Throwable
)
{
}
override
fun
onComplete
()
{
if
(
mMediaPlayer
?.
isPlaying
==
true
)
{
mMediaPlayer
?.
stop
()
ivPlayOrPause
?.
setImageResource
(
R
.
drawable
.
icon_meditation_float_pause
)
}
hideFloatWindow
()
}
}
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
>)
}
}
private
fun
postPlayRecord
(
isQuit
:
Int
,
playTime
:
Int
,
...
...
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