Skip to content

Commit

Permalink
Change rendering result data type from `com.android.ide.common.render…
Browse files Browse the repository at this point in the history
…ing.api.Result` to `kotlin.Result`
  • Loading branch information
johnsonlee committed Jan 6, 2024
1 parent b3112b1 commit 8667eb5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/kotlin/io/johnsonlee/playground/sandbox/Sandbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Sandbox(private val environment: Environment) : Closeable {
theme: String = DEFAULT_THEME,
showLayoutBounds: Boolean = true,
inflate: ((BridgeContext, ViewGroup) -> Unit)? = null
): Result {
): kotlin.Result<RenderData> {
val sessionParams = SessionParamsBuilder.from(environment)
.copy(deviceModel = deviceModel)
.withTheme(theme)
Expand Down Expand Up @@ -65,14 +65,13 @@ class Sandbox(private val environment: Environment) : Closeable {
renderSession.render(true).check()
}

val data = RenderData(
kotlin.Result.success(RenderData(
systemViews = bridgeRenderSession.systemRootViews.toList(),
rootViews = bridgeRenderSession.rootViews.toList(),
image = bridgeRenderSession.image,
)
bridgeRenderSession.result.getCopyWithData(data)
))
} catch (e: Throwable) {
bridgeRenderSession.result.takeIf { it.isSuccess } ?: Result.Status.ERROR_RENDER.createResult(e.message, e)
kotlin.Result.failure(e)
} finally {
root.removeAllViews()
AnimationHandler.sAnimatorHandler.set(null)
Expand Down

0 comments on commit 8667eb5

Please sign in to comment.