-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debug: rn-hole-view fix long conversion
- Loading branch information
1 parent
b0e55f2
commit dd62fb0
Showing
1 changed file
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- /tmp/tmp-status-mobile-5b51e12a2/tmp.WmuJISspjL/RNHoleViewManagerImpl.kt 2024-09-15 13:09:24.262947000 +0530 | ||
+++ ./node_modules/react-native-hole-view/android/src/main/java/com/ibitcy/react_native_hole_view/RNHoleViewManagerImpl.kt 2024-09-15 13:10:40.971677598 +0530 | ||
@@ -14,9 +14,10 @@ | ||
import com.ibitcy.react_native_hole_view.events.AnimFinishEvent | ||
|
||
import kotlin.math.roundToInt | ||
+import kotlin.math.roundToLong | ||
|
||
class RNHoleViewManagerImpl(reactContext: ReactApplicationContext) { | ||
- | ||
+ | ||
val reactContext: ReactApplicationContext = reactContext | ||
|
||
companion object { | ||
@@ -25,20 +26,39 @@ | ||
} | ||
|
||
public fun setAnimation(view: RNHoleView, animation: ReadableMap?) { | ||
- if (animation != null) { | ||
- var duration = RNHoleView.ANIMATION_DURATION_DEFAULT | ||
- if (animation.hasKey("duration")) { | ||
- duration = animation.getDouble("duration").toLong() | ||
- } | ||
- var timingFunction: RNHoleView.EAnimationTimingFunction? = null | ||
- if (animation.hasKey("timingFunction")) { | ||
- timingFunction = | ||
- RNHoleView.EAnimationTimingFunction.valueOf(animation.getString("timingFunction")!!) | ||
- } | ||
- | ||
- if (timingFunction != null) { | ||
- view.animation = RNHoleView.Animation(duration, timingFunction) | ||
+ try { | ||
+ if (animation != null) { | ||
+ var duration = RNHoleView.ANIMATION_DURATION_DEFAULT | ||
+ if (animation.hasKey("duration")) { | ||
+ val durationDouble = animation.getDouble("duration") | ||
+ duration = durationDouble.roundToLong() | ||
+ if (duration.toDouble() != durationDouble) { | ||
+ Log.w("RNHoleView", "Precision loss in animation duration: $durationDouble -> $duration") | ||
+ } | ||
+ } | ||
+ | ||
+ var timingFunction: RNHoleView.EAnimationTimingFunction? = null | ||
+ if (animation.hasKey("timingFunction")) { | ||
+ val timingFunctionString = animation.getString("timingFunction") | ||
+ timingFunction = try { | ||
+ RNHoleView.EAnimationTimingFunction.valueOf(timingFunctionString!!) | ||
+ } catch (e: IllegalArgumentException) { | ||
+ Log.e("RNHoleView", "Invalid timing function: $timingFunctionString", e) | ||
+ null | ||
+ } | ||
+ } | ||
+ | ||
+ if (timingFunction != null) { | ||
+ view.animation = RNHoleView.Animation(duration, timingFunction) | ||
+ Log.d("RNHoleView", "Animation set: duration=$duration, timingFunction=$timingFunction") | ||
+ } else { | ||
+ Log.w("RNHoleView", "Animation not set due to missing or invalid timing function") | ||
+ } | ||
+ } else { | ||
+ Log.d("RNHoleView", "No animation provided") | ||
} | ||
+ } catch (e: Exception) { | ||
+ Log.e("RNHoleView", "Error setting animation: ${e.message}", e) | ||
} | ||
} | ||
|