From 509b99b86d0a9a351fd71d27a63a18087e692ca3 Mon Sep 17 00:00:00 2001 From: Mario Zorz Date: Wed, 18 Mar 2020 13:00:37 -0300 Subject: [PATCH] creating a new FrameSaveManager on each Service bind call given FrameSaveManager is itself a CoorutineScope that gets definitively cancelled when the Service is destroyed --- .../portkey/compose/ComposeLoopFrameActivity.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/automattic/portkey/compose/ComposeLoopFrameActivity.kt b/app/src/main/java/com/automattic/portkey/compose/ComposeLoopFrameActivity.kt index 417ce88af..a54336f04 100644 --- a/app/src/main/java/com/automattic/portkey/compose/ComposeLoopFrameActivity.kt +++ b/app/src/main/java/com/automattic/portkey/compose/ComposeLoopFrameActivity.kt @@ -129,7 +129,6 @@ class ComposeLoopFrameActivity : AppCompatActivity(), OnStoryFrameSelectorTapped private var isEditingText: Boolean = false private lateinit var storyViewModel: StoryViewModel - private lateinit var frameSaveManager: FrameSaveManager private lateinit var transition: LayoutTransition private lateinit var frameSaveService: FrameSaveService @@ -140,7 +139,10 @@ class ComposeLoopFrameActivity : AppCompatActivity(), OnStoryFrameSelectorTapped Log.d("ComposeLoopFrame", "onServiceConnected()") val binder = service as FrameSaveService.FrameSaveServiceBinder frameSaveService = binder.getService() - frameSaveService.saveStoryFrames(0, frameSaveManager, StoryRepository.getImmutableCurrentStoryFrames()) + frameSaveService.saveStoryFrames(0, + FrameSaveManager(photoEditor), + StoryRepository.getImmutableCurrentStoryFrames() + ) saveServiceBound = true } @@ -231,8 +233,6 @@ class ComposeLoopFrameActivity : AppCompatActivity(), OnStoryFrameSelectorTapped } }) - frameSaveManager = FrameSaveManager(photoEditor) - backgroundSurfaceManager = BackgroundSurfaceManager( savedInstanceState, lifecycle, @@ -324,7 +324,6 @@ class ComposeLoopFrameActivity : AppCompatActivity(), OnStoryFrameSelectorTapped override fun onDestroy() { doUnbindService() - frameSaveManager.onCancel() EventBus.getDefault().unregister(this) super.onDestroy() }