Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.nativeCanvas
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.toSize
import androidx.core.graphics.createBitmap
Expand Down Expand Up @@ -69,6 +70,12 @@ fun DotLottieAnimation(
threads: UInt? = null,
loopCount: UInt = 0u,
) {
// Ignores rendering in Android Studio design preview.
if (LocalInspectionMode.current) {
Box(modifier = modifier.defaultMinSize(200.dp, 200.dp))
return
}

val context = LocalContext.current

remember(context) { DotLottieJNI.ensureAndroidInitialized(context); Unit }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.lottiefiles.dotlottie.core.compose.ui

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.unit.dp
import com.dotlottie.dlplayer.Layout
import com.dotlottie.dlplayer.Mode
import com.dotlottie.dlplayer.createDefaultLayout
Expand Down Expand Up @@ -40,6 +44,12 @@ fun DotLottieGLAnimation(
threads: UInt? = null,
loopCount: UInt = 0u,
) {
// Ignores rendering in Android Studio design preview.
if (LocalInspectionMode.current) {
Box(modifier = modifier.defaultMinSize(200.dp, 200.dp))
return
}

// TODO: Add HardwareBuffer support for API 31+
DotLottieGLSurfaceAnimation(
modifier = modifier,
Expand Down
Loading