|
@@ -38,10 +38,6 @@ class AliCameraView(private val context: Context, private val channel: MethodCha
|
|
|
private var recorder: AliyunIRecorder? = null
|
|
private var recorder: AliyunIRecorder? = null
|
|
|
private val mainHandler: Handler = Handler(Looper.getMainLooper())
|
|
private val mainHandler: Handler = Handler(Looper.getMainLooper())
|
|
|
|
|
|
|
|
- init {
|
|
|
|
|
- setUpView(context)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private fun setUpView(context: Context) {
|
|
private fun setUpView(context: Context) {
|
|
|
if (frameLayout == null) {
|
|
if (frameLayout == null) {
|
|
|
frameLayout = FrameLayout(context)
|
|
frameLayout = FrameLayout(context)
|
|
@@ -233,19 +229,24 @@ class AliCameraView(private val context: Context, private val channel: MethodCha
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fun onDestroy() {
|
|
fun onDestroy() {
|
|
|
- recorder?.stopPreview()
|
|
|
|
|
- recorder?.stopRecording()
|
|
|
|
|
- recorder?.destroy()
|
|
|
|
|
- recorder = null
|
|
|
|
|
|
|
+ if (recorder != null) {
|
|
|
|
|
+ recorder?.stopPreview()
|
|
|
|
|
+ recorder?.stopRecording()
|
|
|
|
|
+ recorder?.destroy()
|
|
|
|
|
+ recorder = null
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun getView(): View {
|
|
override fun getView(): View {
|
|
|
|
|
+ setUpView(context)
|
|
|
return frameLayout!!
|
|
return frameLayout!!
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun dispose() {
|
|
override fun dispose() {
|
|
|
- if (frameLayout == null) return
|
|
|
|
|
- frameLayout?.removeView(surfaceView)
|
|
|
|
|
|
|
+ if (frameLayout != null) {
|
|
|
|
|
+ frameLayout?.removeView(surfaceView)
|
|
|
|
|
+ frameLayout = null
|
|
|
|
|
+ }
|
|
|
if (surfaceView != null) {
|
|
if (surfaceView != null) {
|
|
|
surfaceView = null
|
|
surfaceView = null
|
|
|
}
|
|
}
|