Commit 7eaad204 by 徐健

修复FM播放动画在页面onResume的时候出现的异常

parent 3f39fc79
......@@ -168,13 +168,13 @@ dependencies {
if (rootProject.ext.dev_mode) {
//开发模式
api project(':m-user')
//api project(':m-fm')
api project(':m-fm')
api project(':m-tests')
api project(':m-consultant')
api (project(':ydl-platform')){
transitive = true
}
implementation project(':ydl-webview')
// implementation project(':ydl-webview')
implementation project(':ydl-media')
} else {
//发布模式
......
......@@ -555,7 +555,11 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen
@Override
protected void onResume() {
super.onResume();
fmSurfaceView.surfaceCreated(null);
if (AudioPlayer.Companion.get().isPlaying()) {
fmSurfaceView.playTimer();
}else {
fmSurfaceView.stopTimer();
}
if (PlayerFloatHelper.Companion.isShow(this)) {
PlayerFloatHelper.Companion.removeView(this);
......
......@@ -86,42 +86,40 @@ class FMSurfaceView(context: Context?, attrs: AttributeSet?) : SurfaceView(conte
}
private fun drawAnimate() {
synchronized(this) {
mHolder?.let {
canvas = mHolder?.lockCanvas()
canvas?.let {
//清空画布,进行重绘
canvas?.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
//重置最小六边形半径
resetPresentRadius()
paint?.style = Paint.Style.FILL //设置画笔为填充模式
//绘制四个变化的六边形
drawMinHexagon()
drawMiddleHexagon()
drawMaxHexagon()
drawMMaxHexagon()
//绘制图片外面包围的一层圆
canvas?.let {
paint?.strokeWidth = ringWidth + 0.5f
paint?.style = Paint.Style.STROKE //设置画笔为线模式
paint?.color = Color.parseColor("#D0FFFFFF")
paint?.setShadowLayer(ringWidth, 1F, 1F, Color.parseColor("#D0FFFFFF"))
canvas!!.drawCircle((canvas?.width!! / 2).toFloat(), (canvas?.height!! / 2).toFloat(), ringRadius + 0.5f, paint!!)
paint?.setShadowLayer(0F, 0F, 0F, Color.WHITE)
}
presentRadius += presentRadiusChangeNumber //每次循环presentRadius+presentRadiusChangeNumber
}
//这里有些机型上面会出现异常,暴力try一次,也可以用 mHolder?.surface?.isValid先进行一次判断后进行try
try {
mHolder?.unlockCanvasAndPost(canvas) // android 4.3 会有IllegalArgumentException
} catch (e: Exception) {
}
mHolder?.let {
canvas = mHolder?.lockCanvas()
canvas?.let {
//清空画布,进行重绘
canvas?.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
//重置最小六边形半径
resetPresentRadius()
paint?.style = Paint.Style.FILL //设置画笔为填充模式
//绘制四个变化的六边形
drawMinHexagon()
drawMiddleHexagon()
drawMaxHexagon()
drawMMaxHexagon()
//绘制图片外面包围的一层圆
canvas?.let {
paint?.strokeWidth = ringWidth + 0.5f
paint?.style = Paint.Style.STROKE //设置画笔为线模式
paint?.color = Color.parseColor("#D0FFFFFF")
paint?.setShadowLayer(ringWidth, 1F, 1F, Color.parseColor("#D0FFFFFF"))
canvas!!.drawCircle((canvas?.width!! / 2).toFloat(), (canvas?.height!! / 2).toFloat(), ringRadius + 0.5f, paint!!)
paint?.setShadowLayer(0F, 0F, 0F, Color.WHITE)
}
presentRadius += presentRadiusChangeNumber //每次循环presentRadius+presentRadiusChangeNumber
}
//这里有些机型上面会出现异常,暴力try一次,也可以用 mHolder?.surface?.isValid先进行一次判断后进行try
try {
mHolder?.unlockCanvasAndPost(canvas) // android 4.3 会有IllegalArgumentException
} catch (e: Exception) {
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment