|
1 | 1 | package com.margelo.nitro.rive |
2 | 2 |
|
| 3 | +import android.util.Log |
3 | 4 | import androidx.annotation.Keep |
4 | 5 | import com.facebook.proguard.annotations.DoNotStrip |
5 | 6 | import com.facebook.react.uimanager.ThemedReactContext |
@@ -147,29 +148,31 @@ class HybridRiveView(val context: ThemedReactContext) : HybridRiveViewSpec() { |
147 | 148 | } |
148 | 149 |
|
149 | 150 | 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 | + } |
173 | 176 | } |
174 | 177 | //endregion |
175 | 178 |
|
@@ -223,5 +226,14 @@ class HybridRiveView(val context: ThemedReactContext) : HybridRiveViewSpec() { |
223 | 226 | Fit.LAYOUT -> RiveFit.LAYOUT |
224 | 227 | } |
225 | 228 | } |
| 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 | + } |
226 | 238 | //endregion |
227 | 239 | } |
0 commit comments