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
b818b158
Commit
b818b158
authored
Aug 05, 2022
by
王佳洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
悬浮窗内存泄漏尝试修复
parent
19f73ce3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
PlayerFloatHelper.kt
ydl-media/src/main/java/com/ydl/media/view/PlayerFloatHelper.kt
+3
-3
PlayerFloatView.kt
ydl-media/src/main/java/com/ydl/media/view/PlayerFloatView.kt
+8
-7
No files found.
ydl-media/src/main/java/com/ydl/media/view/PlayerFloatHelper.kt
View file @
b818b158
...
...
@@ -109,9 +109,9 @@ class PlayerFloatHelper {
}
fun
removeView
(
context
:
Context
)
{
if
(
TextUtils
.
isEmpty
(
showingPageName
)
||
showingPageName
!=
context
::
class
.
qualifiedName
)
{
return
}
//
if (TextUtils.isEmpty(showingPageName) || showingPageName != context::class.qualifiedName) {
//
return
//
}
mPlayerFloatView
?.
visibility
=
View
.
GONE
wm
?.
removeViewImmediate
(
mPlayerFloatView
)
showingPageName
=
""
...
...
ydl-media/src/main/java/com/ydl/media/view/PlayerFloatView.kt
View file @
b818b158
package
com.ydl.media.view
import
android.annotation.SuppressLint
import
android.app.Application
import
android.content.Context
import
android.text.TextUtils
import
android.view.MotionEvent
...
...
@@ -20,22 +21,22 @@ import java.util.concurrent.CopyOnWriteArraySet
import
kotlin.math.abs
class
PlayerFloatView
(
private
val
ctx
:
Context
)
:
FrameLayout
(
ctx
)
{
class
PlayerFloatView
(
ctx
:
Context
)
:
FrameLayout
(
ctx
.
applicationContext
)
{
private
var
mTouchDownX
:
Float
=
0
.
toFloat
()
private
var
mTouchDownY
:
Float
=
0
.
toFloat
()
private
var
mTouchX
:
Float
=
0
.
toFloat
()
private
var
mTouchY
:
Float
=
0
.
toFloat
()
private
val
mTouchSlop
:
Int
=
(
ViewConfiguration
.
get
(
c
tx
).
scaledTouchSlop
+
8
)
*
3
private
val
mTouchSlop
:
Int
=
(
ViewConfiguration
.
get
(
c
ontext
).
scaledTouchSlop
+
8
)
*
3
private
val
mWindowManager
:
WindowManager
=
c
tx
.
getSystemService
(
Context
.
WINDOW_SERVICE
)
as
WindowManager
private
val
mWindowManager
:
WindowManager
=
c
ontext
.
getSystemService
(
Context
.
WINDOW_SERVICE
)
as
WindowManager
//全局变量,用以保存悬浮窗口的属性
var
mFloatViewParams
=
WindowManager
.
LayoutParams
()
private
var
mListeners
:
CopyOnWriteArraySet
<
FloatViewPlayListener
>
=
CopyOnWriteArraySet
()
private
var
mStateChangeListener
:
OnPlayerEventListener
?
=
null
private
val
mStatusBarHeight
:
Int
=
StatusBarUtil
.
getStatusBarHeight
(
c
tx
)
private
val
mStatusBarHeight
:
Int
=
StatusBarUtil
.
getStatusBarHeight
(
c
ontext
)
fun
resetLayoutParams
()
{
...
...
@@ -46,7 +47,7 @@ class PlayerFloatView(private val ctx: Context) : FrameLayout(ctx) {
View
.
inflate
(
context
,
R
.
layout
.
item_playing_float_btn
,
this
)
resetFloatView
()
if
(!
TextUtils
.
isEmpty
(
AudioPlayer
.
get
().
playMusic
?.
coverPath
))
{
GlideApp
.
with
(
context
.
applicationContext
)
GlideApp
.
with
(
context
)
.
load
(
AudioPlayer
.
get
().
playMusic
?.
coverPath
)
.
transform
(
GlideRoundTransform
(
context
,
4
))
.
error
(
R
.
drawable
.
ico_play_float_pic
)
...
...
@@ -61,7 +62,7 @@ class PlayerFloatView(private val ctx: Context) : FrameLayout(ctx) {
mListeners
.
forEach
{
it
.
onPauseClick
()
}
PlayerFloatHelper
.
removeView
(
c
tx
)
PlayerFloatHelper
.
removeView
(
c
ontext
)
PlayerFloatHelper
.
playTempData
.
clear
()
AudioPlayer
.
get
().
resetPlayer
()
}
...
...
@@ -135,7 +136,7 @@ class PlayerFloatView(private val ctx: Context) : FrameLayout(ctx) {
@SuppressLint
(
"SetTextI18n"
)
fun
resetFloatView
()
{
if
(!
TextUtils
.
isEmpty
(
AudioPlayer
.
get
().
playMusic
?.
coverPath
))
{
GlideApp
.
with
(
context
.
applicationContext
)
GlideApp
.
with
(
context
)
.
load
(
AudioPlayer
.
get
().
playMusic
?.
coverPath
)
.
transform
(
GlideRoundTransform
(
context
,
4
))
.
error
(
R
.
drawable
.
ico_play_float_pic
)
...
...
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