-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Grigory-Rylov/fix_giraffe_support
Fix giraffe support
- Loading branch information
Showing
9 changed files
with
137 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/kotlin/com/android/layoutinspector/model/ModernClientViewInspector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.android.layoutinspector.model | ||
|
||
import com.android.ddmlib.Client | ||
import com.android.ddmlib.DebugViewDumpHandler | ||
import com.android.layoutinspector.common.AppLogger | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.filterNotNull | ||
import kotlinx.coroutines.flow.first | ||
import java.nio.ByteBuffer | ||
import java.util.concurrent.TimeUnit | ||
|
||
class ModernClientViewInspector : ClientWindow.ClientViewInspector { | ||
override suspend fun dumpViewHierarchy( | ||
logger: AppLogger, | ||
client: Client, | ||
clientWindowTitle: String, | ||
skipChildren: Boolean, | ||
includeProperties: Boolean, | ||
useV2: Boolean, | ||
timeout: Long, | ||
timeUnit: TimeUnit | ||
): ByteArray? { | ||
val handler = DumpViewHierarchyDebugViewDumpHandler() | ||
client.dumpViewHierarchy(clientWindowTitle, skipChildren, includeProperties, useV2, handler) | ||
return handler.value.filterNotNull().first() | ||
} | ||
|
||
private inner class DumpViewHierarchyDebugViewDumpHandler : DebugViewDumpHandler() { | ||
val value = MutableStateFlow<ByteArray?>(null) | ||
override fun handleViewDebugResult(data: ByteBuffer?) { | ||
value.value = data?.array() | ||
} | ||
} | ||
|
||
override suspend fun captureView( | ||
logger: AppLogger, | ||
client: Client, | ||
clientWindowTitle: String, | ||
node: ViewNode, | ||
timeout: Long, | ||
timeUnit: TimeUnit | ||
): ByteArray? { | ||
val handler = CaptureViewDebugViewDumpHandler() | ||
client.captureView(clientWindowTitle, node.toString(), handler) | ||
return handler.value.filterNotNull().first() | ||
} | ||
|
||
private inner class CaptureViewDebugViewDumpHandler : DebugViewDumpHandler() { | ||
val value = MutableStateFlow<ByteArray?>(null) | ||
|
||
override fun handleViewDebugResult(data: ByteBuffer?) { | ||
value.value = data?.array() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.