@@ -9,14 +9,14 @@ import com.github.grishberg.android.layoutinspector.process.LayoutFileSystem
99import com.github.grishberg.android.layoutinspector.process.LayoutInspectorCaptureTask
1010import com.github.grishberg.android.layoutinspector.process.RecordingConfig
1111import com.github.grishberg.android.layoutinspector.process.providers.ScreenSizeProvider
12+ import java.io.IOException
13+ import java.text.SimpleDateFormat
14+ import java.util.Date
1215import kotlinx.coroutines.CoroutineExceptionHandler
1316import kotlinx.coroutines.CoroutineScope
1417import kotlinx.coroutines.Job
1518import kotlinx.coroutines.async
1619import kotlinx.coroutines.launch
17- import java.io.IOException
18- import java.text.SimpleDateFormat
19- import java.util.Date
2020
2121private const val TAG = " Logic"
2222
@@ -33,6 +33,7 @@ class Logic(
3333 private val coroutineScope : CoroutineScope ,
3434 private val dispatchers : CoroutinesDispatchers
3535) {
36+
3637 private val screenSizeProvider = ScreenSizeProvider (dispatchers)
3738 private var recordingJob: Job ? = null
3839 private var isOpenedLayout = false
@@ -88,7 +89,6 @@ class Logic(
8889 val dpPerPixels = (density / 160.0 )
8990 logger.d(" $TAG : dp per pixels = $dpPerPixels " )
9091
91-
9292 val config = RecordingConfig (
9393 recordOptions.client,
9494 window,
@@ -114,7 +114,7 @@ class Logic(
114114 }
115115 val windowList: List <ClientWindow > = windows.await()
116116 if (windowList.any { it.displayName == config.clientWindow.displayName }) {
117- captureLayouts(config)
117+ captureLayouts(config, isRefresh = true )
118118 } else {
119119 recodLayoutFromNewDevice()
120120 }
@@ -123,7 +123,7 @@ class Logic(
123123 }
124124
125125 private suspend fun captureLayouts (
126- config : RecordingConfig ,
126+ config : RecordingConfig , isRefresh : Boolean = false
127127 ) {
128128 val task = LayoutInspectorCaptureTask (layoutFileSystem, coroutineScope, logger, dispatchers)
129129
@@ -134,13 +134,12 @@ class Logic(
134134 if (liResult.data == null || liResult.root == null ) {
135135 output.showError(liResult.error)
136136 } else {
137- onSuccessCaptured(config, liResult)
137+ onSuccessCaptured(config, liResult, isRefresh )
138138 }
139139 }
140140
141141 private fun onSuccessCaptured (
142- config : RecordingConfig ,
143- liResult : LayoutInspectorResult ,
142+ config : RecordingConfig , liResult : LayoutInspectorResult , isRefresh : Boolean = false
144143 ) {
145144 val dpPerPixels = config.dpPerPixels
146145 val fileNamePrefix = config.recordOptions.fileNamePrefix
@@ -158,7 +157,7 @@ class Logic(
158157 metaRepository.serialize()
159158
160159 logger.d(" $TAG : Received result" )
161- output.showResult(LayoutFileData .fromLayoutInspectorResult(liResult), config.recordOptions.label )
160+ output.showResult(LayoutFileData .fromLayoutInspectorResult(liResult), isRefresh )
162161 isOpenedLayout = true
163162 }
164163
0 commit comments