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
448abcc2
Commit
448abcc2
authored
Jul 28, 2022
by
刘鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: PlayService移除
parent
8cc2f486
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
142 deletions
+0
-142
MainActivity.kt
app/src/main/java/com/ydl/component/MainActivity.kt
+0
-49
DemoAppLifecycles.kt
app/src/main/java/com/ydl/component/base/DemoAppLifecycles.kt
+0
-10
AndroidManifest.xml
ydl-media/src/main/AndroidManifest.xml
+0
-2
PlayService.kt
ydl-media/src/main/java/com/ydl/media/audio/PlayService.kt
+0
-81
No files found.
app/src/main/java/com/ydl/component/MainActivity.kt
View file @
448abcc2
...
...
@@ -33,7 +33,6 @@ import com.ydl.component.mvp.DemoPresenter
import
com.ydl.component.route.PlatformTempCommonRouteImpl
import
com.ydl.component.rtc.MDTLoginActivity
import
com.ydl.confide.home.ConfideHomeActivity
import
com.ydl.media.audio.PlayService
import
com.ydl.ydlcommon.data.http.ThrowableConsumer
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.mvp.lce.BaseLceActivity
...
...
@@ -77,11 +76,6 @@ import kotlin.math.roundToInt
@Route
(
path
=
"/main/main"
)
class
MainActivity
:
BaseLceActivity
<
DemoContract
.
View
,
DemoContract
.
Presenter
>(),
DemoContract
.
View
{
// private var secretDescriptionDialog: SecretDescriptionDialog? = null
private
var
serviceConnection
:
ServiceConnection
?
=
null
private
var
secretDialog
:
SecretDialog
?
=
null
protected
var
playService
:
PlayService
?
=
null
private
var
mFloatDisposable
:
Disposable
?=
null
...
...
@@ -295,9 +289,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
private
fun
bindService
()
{
val
intent
=
Intent
()
intent
.
setClass
(
this
,
PlayService
::
class
.
java
!!
)
serviceConnection
=
PlayServiceConnection
()
bindService
(
intent
,
serviceConnection
,
Context
.
BIND_AUTO_CREATE
)
}
private
fun
initMeditationObserver
(){
...
...
@@ -317,11 +308,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override
fun
onResume
()
{
super
.
onResume
()
MobclickAgent
.
onResume
(
this
)
// ModularServiceManager.provide(IConsultantService::class.java)
// .
// (this)
val
trtcCalling
=
TRTCCalling
.
sharedInstance
(
this
)
if
(!
TextUtils
.
isEmpty
(
trtcCalling
.
mRoomId
)
&&
!
TextUtils
.
isEmpty
(
trtcCalling
.
mUserId
))
{
val
intent
=
Intent
(
mContext
,
YDLInvitionActivity
::
class
.
java
)
...
...
@@ -333,11 +319,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
}
}
override
fun
onPause
()
{
super
.
onPause
()
// ModularServiceManager.provide(IConsultantService::class.java).hideConsultAssistantDialog()
}
fun
onEvent
(
event
:
MeditationFloatEvent
)
{
...
...
@@ -345,10 +327,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
@SuppressLint
(
"MissingSuperCall"
)
override
fun
onDestroy
()
{
if
(
serviceConnection
!=
null
)
{
unbindService
(
serviceConnection
)
}
MediaPlayerManager
.
getInstance
(
this
)
?.
stop
()
hideFloatWindow
()
...
...
@@ -362,33 +340,6 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
super
.
onDestroy
()
}
private
inner
class
PlayServiceConnection
:
ServiceConnection
{
override
fun
onServiceConnected
(
name
:
ComponentName
,
service
:
IBinder
)
{
playService
=
(
service
as
PlayService
.
PlayBinder
).
service
}
override
fun
onServiceDisconnected
(
name
:
ComponentName
)
{
Log
.
e
(
javaClass
.
simpleName
,
"service disconnected"
)
}
}
private
fun
showEnsureDialog
()
{
secretDialog
=
SecretDialog
(
this
,
object
:
OnSecretDialogListener
{
override
fun
onCancel
()
{
secretDialog
!!
.
dismiss
()
// finishAll()
// Process.killProcess(Process.myPid())
// System.exit(0)
}
override
fun
onSure
()
{
secretDialog
!!
.
dismiss
()
}
})
secretDialog
!!
.
setCanceledOnTouchOutside
(
false
)
secretDialog
!!
.
show
()
}
private
lateinit
var
mWindowManager
:
WindowManager
private
var
floatRootView
:
View
?
=
null
...
...
app/src/main/java/com/ydl/component/base/DemoAppLifecycles.kt
View file @
448abcc2
...
...
@@ -20,7 +20,6 @@ import com.umeng.socialize.UMShareAPI
import
com.ydl.component.BuildConfig
import
com.ydl.component.MainActivity
import
com.ydl.component.R
import
com.ydl.media.audio.PlayService
import
com.ydl.ydlcommon.actions.crash.Cockroach
import
com.ydl.ydlcommon.actions.crash.ExceptionHandler
import
com.ydl.ydlcommon.base.config.HttpConfig
...
...
@@ -78,15 +77,6 @@ class DemoAppLifecycles : IAppLifecycles {
// YDLCommonPlugin plugin = new YDLCommonPlugin();
// flutterEngine.getLocalizationChannel().channel.setMethodCallHandler(plugin);
val
intent
=
Intent
(
application
,
PlayService
::
class
.
java
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
application
.
startForegroundService
(
intent
)
}
else
{
application
.
startService
(
intent
)
}
// application.registerActivityLifecycleCallbacks(new CoursePlayLifecycle());
}
}
...
...
ydl-media/src/main/AndroidManifest.xml
View file @
448abcc2
...
...
@@ -4,8 +4,6 @@
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE"
/>
<application>
<service
android:name=
".audio.PlayService"
/>
<receiver
android:name=
".audio.receiver.RemoteControlReceiver"
>
<intent-filter>
<action
android:name=
"android.intent.action.MEDIA_BUTTON"
/>
...
...
ydl-media/src/main/java/com/ydl/media/audio/PlayService.kt
deleted
100644 → 0
View file @
8cc2f486
package
com.ydl.media.audio
import
android.app.NotificationChannel
import
android.app.NotificationManager
import
android.app.Service
import
android.content.Context
import
android.content.Intent
import
android.os.Binder
import
android.os.Build
import
android.os.IBinder
import
android.util.Log
import
androidx.core.app.NotificationCompat
import
com.ydl.media.audio.constants.Extras
import
com.ydl.media.audio.manager.MediaSessionManager
import
com.ydl.media.audio.manager.NotifyManager
/**
* Created by haorui on 2019-10-27 .
* Des: 音乐播放后台服务
*/
class
PlayService
:
Service
()
{
inner
class
PlayBinder
:
Binder
()
{
val
service
:
PlayService
get
()
=
this
@PlayService
}
override
fun
onCreate
()
{
super
.
onCreate
()
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
){
var
nm
=
getSystemService
(
NOTIFICATION_SERVICE
)
as
NotificationManager
;
//数字是随便写的“40”,
nm
.
createNotificationChannel
(
NotificationChannel
(
"40"
,
"App Service"
,
NotificationManager
.
IMPORTANCE_DEFAULT
));
var
builder
=
NotificationCompat
.
Builder
(
this
,
"40"
);
//其中的2,是也随便写的,正式项目也是随便写
startForeground
(
2
,
builder
.
build
());
}
Log
.
i
(
TAG
,
"onCreate: "
+
javaClass
.
simpleName
)
AudioPlayer
.
get
().
init
(
this
)
MediaSessionManager
.
get
().
init
(
this
)
NotifyManager
.
get
().
init
(
this
)
}
override
fun
onBind
(
intent
:
Intent
):
IBinder
?
{
return
PlayBinder
()
}
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
if
(
intent
!=
null
&&
intent
.
action
!=
null
)
{
when
(
intent
.
action
)
{
Extras
.
ACTION_STOP
->
stop
()
}
}
return
Service
.
START_NOT_STICKY
}
private
fun
stop
()
{
AudioPlayer
.
get
().
stopPlayer
()
NotifyManager
.
get
().
cancelAll
()
}
companion
object
{
private
val
TAG
=
"Service"
fun
startCommand
(
context
:
Context
,
action
:
String
)
{
val
intent
=
Intent
(
context
,
PlayService
::
class
.
java
)
intent
.
action
=
action
try
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
context
.
startForegroundService
(
intent
)
}
else
{
context
.
startService
(
intent
)
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
}
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