From 4a44260db7b7e7cdf843500f1ec09da5b4918d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Thu, 16 Nov 2023 10:22:29 +0100 Subject: [PATCH] doc: add kotlin MainActiviy.kt to instructions (#1971) ## Description RN 0.73 has MainActivity in kotlin not java ## Changes - Updated README.md --------- Co-authored-by: Kacper Kafara Co-authored-by: Tymoteusz Boba --- README.md | 22 ++++++++++++++++++++++ ios/RNSScreen.mm | 9 +++++++++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index 07006c505c..c6dfec0922 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,9 @@ For most people using an app built from the react-native template, that means ed You should add this code, which specifically discards any Activity state persisted during the Activity restart process, to avoid inconsistencies that lead to crashes. Please note that the override code should not be placed inside `MainActivityDelegate`, but rather directly in `MainActivity`. +
+Java + ```java import android.os.Bundle; @@ -47,6 +50,25 @@ public class MainActivity extends ReactActivity { } } ``` +
+ +
+Kotlin + +```kotlin +import android.os.Bundle; + +class MainActivity: ReactActivity() { + + //...code + + //react-native-screens override + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(null); + } +} +``` +
For people that must handle cases like this, there is [a more detailed discussion of the difficulties in a series of related comments](https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704633). diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index 740d48c738..4b24cffff6 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -1423,6 +1423,15 @@ - (void)traverseForScrollView:(UIView *)view // we don't want to send `scrollViewDidEndDecelerating` event to JS before the JS thread is ready return; } + + if ([NSStringFromClass([view class]) isEqualToString:@"AVPlayerView"]) { + // Traversing through AVPlayerView is an uncommon edge case that causes the disappearing screen + // to an excessive traversal through all video player elements + // (e.g., for react-native-video, this includes all controls and additional video views). + // Thus, we want to avoid unnecessary traversals through these views. + return; + } + if ([view isKindOfClass:[UIScrollView class]] && ([[(UIScrollView *)view delegate] respondsToSelector:@selector(scrollViewDidEndDecelerating:)])) { [[(UIScrollView *)view delegate] scrollViewDidEndDecelerating:(id)view];