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
37323969
Commit
37323969
authored
May 31, 2022
by
范玉宾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Manage floating window state
parent
94352583
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
32 deletions
+80
-32
MainActivity.kt
app/src/main/java/com/ydl/component/MainActivity.kt
+25
-6
PlayFragment.java
app/src/main/java/com/ydl/component/music/PlayFragment.java
+0
-11
config.gradle
config.gradle
+8
-8
MsgViewHolderConfirmOrder.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderConfirmOrder.java
+0
-1
MeditationWindowService.kt
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
+31
-6
AudioPlayer.kt
ydl-media/src/main/java/com/ydl/media/audio/AudioPlayer.kt
+6
-0
MeditationFloatEvent.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/event/MeditationFloatEvent.kt
+10
-0
No files found.
app/src/main/java/com/ydl/component/MainActivity.kt
View file @
37323969
...
...
@@ -53,10 +53,13 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
DemoContract
.
View
{
private
var
secretDescriptionDialog
:
SecretDescriptionDialog
?
=
null
private
var
serviceConnection
:
ServiceConnection
?
=
null
private
var
meditationServiceConnection
:
ServiceConnection
?
=
null
private
var
secretDialog
:
SecretDialog
?
=
null
protected
var
playService
:
PlayService
?
=
null
pr
ivate
var
meditationIntent
:
Intent
?=
null
pr
otected
var
meditationService
:
MeditationWindowService
?=
null
override
fun
getContentViewId
():
Int
{
return
R
.
id
.
lce_content_view
...
...
@@ -89,9 +92,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// 初始化一键登录sdk
OneKeyLoginHelp
.
sdkInit
(
this
,
OneKeyLoginHelp
.
YDL_USER_APP
,
PhoneNumberAuthHelper
.
SERVICE_TYPE_LOGIN
)
bindService
()
meditationIntent
=
Intent
(
this
,
MeditationWindowService
::
class
.
java
)
startService
(
meditationIntent
)
bindMeditationService
()
reLoadData
()
requestPermission
()
...
...
@@ -264,6 +265,13 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
bindService
(
intent
,
serviceConnection
,
Context
.
BIND_AUTO_CREATE
)
}
private
fun
bindMeditationService
(){
val
intent
=
Intent
()
intent
.
setClass
(
this
,
MeditationWindowService
::
class
.
java
)
meditationServiceConnection
=
MeditationServiceConnection
()
bindService
(
intent
,
meditationServiceConnection
,
Context
.
BIND_AUTO_CREATE
)
}
override
fun
onResume
()
{
super
.
onResume
()
MobclickAgent
.
onResume
(
this
)
...
...
@@ -287,10 +295,10 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
if
(
serviceConnection
!=
null
)
{
unbindService
(
serviceConnection
)
}
if
(
meditation
Intent
!=
null
){
if
(
meditation
ServiceConnection
!=
null
){
EventBus
.
getDefault
().
post
(
MeditationFloatEvent
(
false
))
MediaPlayerManager
.
getInstance
(
this
)
?.
stop
()
stopService
(
meditationIntent
)
unbindService
(
meditationServiceConnection
)
}
if
(
EventBus
.
getDefault
().
isRegistered
(
this
)){
EventBus
.
getDefault
().
unregister
(
this
)
...
...
@@ -308,6 +316,17 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
}
}
private
inner
class
MeditationServiceConnection
:
ServiceConnection
{
override
fun
onServiceConnected
(
name
:
ComponentName
?,
service
:
IBinder
?)
{
meditationService
=
(
service
as
MeditationWindowService
.
MeditationBinder
).
service
}
override
fun
onServiceDisconnected
(
name
:
ComponentName
?)
{
}
}
private
fun
showEnsureDialog
()
{
secretDialog
=
SecretDialog
(
this
,
object
:
OnSecretDialogListener
{
override
fun
onCancel
()
{
...
...
app/src/main/java/com/ydl/component/music/PlayFragment.java
View file @
37323969
...
...
@@ -28,7 +28,6 @@ import java.util.HashMap;
import
java.util.Locale
;
import
java.util.Objects
;
import
de.greenrobot.event.EventBus
;
/**
* Created by haorui on 2019-10-28 .
...
...
@@ -64,12 +63,8 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
@Override
public
void
onActivityCreated
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onActivityCreated
(
savedInstanceState
);
EventBus
.
getDefault
().
register
(
this
);
initPlayMode
();
MeditationFloatEvent
event
=
new
MeditationFloatEvent
(
false
,
true
,
null
,
null
,
null
);
EventBus
.
getDefault
().
post
(
event
);
onChangeImpl
(
AudioPlayer
.
Companion
.
get
().
getPlayMusic
());
AudioPlayer
.
Companion
.
get
().
addOnPlayEventListener
(
this
);
}
...
...
@@ -269,9 +264,6 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
public
void
onDestroy
()
{
AudioPlayer
.
Companion
.
get
().
removeOnPlayEventListener
(
this
);
PlayerFloatHelper
.
Companion
.
onDestroy
();
if
(
EventBus
.
getDefault
().
isRegistered
(
this
)){
EventBus
.
getDefault
().
unregister
(
this
);
}
super
.
onDestroy
();
}
...
...
@@ -302,8 +294,5 @@ public class PlayFragment extends Fragment implements View.OnClickListener,
ivCover
=
bindSource
.
findViewById
(
R
.
id
.
iv_cover
);
}
public
void
onEventMainThread
(
MeditationFloatEvent
event
){
}
}
config.gradle
View file @
37323969
...
...
@@ -10,11 +10,11 @@ ext {
"m-fm"
:
"0.0.30.08"
,
"m-user"
:
"0.0.62.24"
,
"m-home"
:
"0.0.23.78"
,
"m-im"
:
"0.0.21.
44
"
,
"m-im"
:
"0.0.21.
50
"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-article"
:
"0.0.0.10"
,
"m-muse"
:
"0.0.28.6
1
"
,
"m-muse"
:
"0.0.28.6
2
"
,
"m-tests"
:
"0.0.24.18"
,
"m-course"
:
"0.0.43.37"
,
...
...
@@ -35,11 +35,11 @@ ext {
//mdt 组件
"ydl-tuicore"
:
"0.0.23"
,
//第一步
"ydl-platform"
:
"0.0.41.2
0
"
,
"ydl-platform"
:
"0.0.41.2
4
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.86"
,
"ydl-media"
:
"0.0.21.4
4
"
,
"ydl-media"
:
"0.0.21.4
6
"
,
"ydl-pay"
:
"0.0.18.19"
,
"m-audioim"
:
"0.0.49.29.94"
,
"ydl-flutter-base"
:
"0.0.14.38"
,
...
...
@@ -95,11 +95,11 @@ ext {
"m-fm"
:
"0.0.30.08"
,
"m-user"
:
"0.0.62.24"
,
"m-home"
:
"0.0.23.78"
,
"m-im"
:
"0.0.21.
44
"
,
"m-im"
:
"0.0.21.
50
"
,
"m-dynamic"
:
"0.0.7.73"
,
"m-article"
:
"0.0.0.8"
,
"m-muse"
:
"0.0.28.6
1
"
,
"m-muse"
:
"0.0.28.6
2
"
,
"m-tests"
:
"0.0.24.18"
,
"m-course"
:
"0.0.43.37"
,
//-------------- 业务模块 API 层 --------------
...
...
@@ -118,11 +118,11 @@ ext {
//mdt组件
"ydl-tuicore"
:
"0.0.23"
,
//第一步
"ydl-platform"
:
"0.0.41.2
0
"
,
"ydl-platform"
:
"0.0.41.2
4
"
,
//第二步 若干
"ydl-webview"
:
"0.0.38.86"
,
"ydl-media"
:
"0.0.21.4
4
"
,
"ydl-media"
:
"0.0.21.4
6
"
,
"ydl-pay"
:
"0.0.18.19"
,
"m-audioim"
:
"0.0.49.29.94"
,
"ydl-flutter-base"
:
"0.0.14.38"
,
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderConfirmOrder.java
View file @
37323969
...
...
@@ -104,7 +104,6 @@ public class MsgViewHolderConfirmOrder extends MsgViewHolderBase {
orderId
=
customAttachment
.
orderId
;
serviceId
=
customAttachment
.
serviceId
;
flag
=
customAttachment
.
status
;
ToastUtil
.
toastShort
(
"flag:"
+
flag
);
if
(
flag
==
1
)
{
// 1代表已确认,0代表待确认
tv_submit
.
setText
(
"已确认"
);
...
...
m-muse/src/main/java/com/yidianling/muse/service/MeditationWindowService.kt
View file @
37323969
...
...
@@ -2,13 +2,16 @@ package com.yidianling.muse.service
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.Service
import
android.content.ComponentName
import
android.content.Context
import
android.content.Intent
import
android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import
android.graphics.PixelFormat
import
android.media.MediaPlayer
import
android.os.Binder
import
android.os.Build
import
android.os.IBinder
import
android.util.DisplayMetrics
import
android.view.Gravity
import
android.view.LayoutInflater
...
...
@@ -17,14 +20,10 @@ import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import
android.view.WindowManager
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.appcompat.widget.AppCompatSeekBar
import
androidx.core.app.NotificationCompat
import
androidx.lifecycle.LifecycleService
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners
import
com.ydl.ydlcommon.data.http.ThrowableConsumer
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.home.http.MuseHttp
import
com.yidianling.muse.R
import
com.yidianling.muse.activity.PlayMeditationActivity
...
...
@@ -47,7 +46,7 @@ import java.util.*
import
java.util.concurrent.TimeUnit
import
kotlin.math.roundToInt
class
MeditationWindowService
:
Lifecycle
Service
()
{
class
MeditationWindowService
:
Service
()
{
private
lateinit
var
mWindowManager
:
WindowManager
private
var
floatRootView
:
View
?
=
null
...
...
@@ -74,6 +73,11 @@ class MeditationWindowService : LifecycleService() {
private
var
currentMediaId
:
Long
?
=
null
inner
class
MeditationBinder
:
Binder
()
{
val
service
:
MeditationWindowService
get
()
=
this
@MeditationWindowService
}
override
fun
onCreate
()
{
super
.
onCreate
()
...
...
@@ -122,7 +126,22 @@ class MeditationWindowService : LifecycleService() {
windowIsShow
=
true
}
fun
onEventMainThread
(
event
:
MeditationFloatEvent
)
{
fun
onEventMainThread
(
event
:
Any
)
{
if
(
event
is
com
.
ydl
.
ydlcommon
.
event
.
MeditationFloatEvent
){
if
(
event
.
show
!=
null
&&
!
event
.
show
)
{
if
(
event
.
stop
==
true
){
try
{
mMediaPlayer
?.
stop
()
}
catch
(
e
:
Exception
){
}
hideFloatWindow
()
}
hideFloatWindow
()
}
}
if
(
event
is
MeditationFloatEvent
){
if
(
event
.
time
!=
null
){
if
(
event
.
time
>
0
){
initRxTimeOff
(
event
.
time
)
...
...
@@ -148,6 +167,8 @@ class MeditationWindowService : LifecycleService() {
updateFloatView
(
event
.
meditation
)
}
}
}
}
...
...
@@ -324,6 +345,10 @@ class MeditationWindowService : LifecycleService() {
}
}
override
fun
onBind
(
intent
:
Intent
?):
IBinder
?
{
return
MeditationBinder
()
}
private
fun
dp2px
(
dp
:
Float
):
Int
{
val
scale
=
resources
.
displayMetrics
.
density
return
(
dp
*
scale
+
0.5f
).
toInt
()
...
...
ydl-media/src/main/java/com/ydl/media/audio/AudioPlayer.kt
View file @
37323969
...
...
@@ -13,8 +13,10 @@ import com.ydl.media.audio.manager.NotifyManager
import
com.ydl.media.audio.model.Music
import
com.ydl.media.audio.receiver.NoisyAudioStreamReceiver
import
com.ydl.media.audio.utils.PlayProgressUtil
import
com.ydl.ydlcommon.event.MeditationFloatEvent
import
com.ydl.ydlcommon.utils.LogUtil
import
com.yidianling.common.tools.ToastUtil
import
de.greenrobot.event.EventBus
import
tv.danmaku.ijk.media.player.IMediaPlayer
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
import
java.io.IOException
...
...
@@ -341,6 +343,10 @@ class AudioPlayer private constructor() {
listener
.
onPlayerStart
()
}
}
val
event
=
MeditationFloatEvent
(
show
=
false
,
stop
=
true
,
time
=
null
)
EventBus
.
getDefault
().
post
(
event
)
}
/**
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/event/MeditationFloatEvent.kt
0 → 100644
View file @
37323969
package
com.ydl.ydlcommon.event
class
MeditationFloatEvent
(
val
show
:
Boolean
,
val
stop
:
Boolean
?
=
null
,
val
time
:
Long
?
=
null
// val meditation: MeditationPlayModuleBean.MeditationDetail? = null,
// val meditations: ArrayList<MeditationPlayModuleBean.MeditationDetail>? = null
)
\ No newline at end of file
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