Skip to content

Commit 78599a8

Browse files
committed
fix: add logged to android
1 parent 233cd12 commit 78599a8

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

android/src/main/java/com/margelo/nitro/rive/HybridRiveView.kt

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.margelo.nitro.rive
22

3+
import android.util.Log
34
import androidx.annotation.Keep
45
import com.facebook.proguard.annotations.DoNotStrip
56
import com.facebook.react.uimanager.ThemedReactContext
@@ -147,29 +148,31 @@ class HybridRiveView(val context: ThemedReactContext) : HybridRiveViewSpec() {
147148
}
148149

149150
override fun afterUpdate() {
150-
firstUpdate = false
151-
val hybridFile = file as? HybridRiveFile
152-
val riveFile = hybridFile?.riveFile ?: return
153-
154-
val config = ViewConfiguration(
155-
artboardName = artboardName,
156-
stateMachineName = stateMachineName,
157-
autoPlay = autoPlay ?: DefaultConfiguration.AUTOPLAY,
158-
riveFile = riveFile,
159-
alignment = convertAlignment(alignment) ?: DefaultConfiguration.ALIGNMENT,
160-
fit = convertFit(fit) ?: DefaultConfiguration.FIT,
161-
layoutScaleFactor = layoutScaleFactor?.toFloat() ?: DefaultConfiguration.LAYOUTSCALEFACTOR,
162-
bindData = dataBind.toBindData()
163-
)
164-
view.configure(config, needsReload)
165-
166-
if (needsReload && hybridFile != null) {
167-
hybridFile.registerView(this)
168-
registeredFile = hybridFile
169-
}
170-
171-
needsReload = false
172-
super.afterUpdate()
151+
logged(TAG, "afterUpdate") {
152+
firstUpdate = false
153+
val hybridFile = file as? HybridRiveFile
154+
val riveFile = hybridFile?.riveFile ?: return@logged
155+
156+
val config = ViewConfiguration(
157+
artboardName = artboardName,
158+
stateMachineName = stateMachineName,
159+
autoPlay = autoPlay ?: DefaultConfiguration.AUTOPLAY,
160+
riveFile = riveFile,
161+
alignment = convertAlignment(alignment) ?: DefaultConfiguration.ALIGNMENT,
162+
fit = convertFit(fit) ?: DefaultConfiguration.FIT,
163+
layoutScaleFactor = layoutScaleFactor?.toFloat() ?: DefaultConfiguration.LAYOUTSCALEFACTOR,
164+
bindData = dataBind.toBindData()
165+
)
166+
view.configure(config, needsReload)
167+
168+
if (needsReload && hybridFile != null) {
169+
hybridFile.registerView(this)
170+
registeredFile = hybridFile
171+
}
172+
173+
needsReload = false
174+
super.afterUpdate()
175+
}
173176
}
174177
//endregion
175178

@@ -223,5 +226,14 @@ class HybridRiveView(val context: ThemedReactContext) : HybridRiveViewSpec() {
223226
Fit.LAYOUT -> RiveFit.LAYOUT
224227
}
225228
}
229+
230+
fun logged(tag: String, note: String? = null, fn: () -> Unit) {
231+
try {
232+
fn()
233+
} catch (e: Exception) {
234+
// TODO add onError callback
235+
Log.e("[RIVE]", "$tag ${note ?: ""} $e")
236+
}
237+
}
226238
//endregion
227239
}

0 commit comments

Comments
 (0)