Skip to content

Commit

Permalink
doc: add kotlin MainActiviy.kt to instructions (#1971)
Browse files Browse the repository at this point in the history
## Description

RN 0.73 has MainActivity in kotlin not java

## Changes

- Updated README.md

---------

Co-authored-by: Kacper Kafara <[email protected]>
Co-authored-by: Tymoteusz Boba <[email protected]>
  • Loading branch information
3 people authored Nov 16, 2023
1 parent 1868f8e commit 4a44260
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

<details open>
<summary>Java</summary>

```java
import android.os.Bundle;

Expand All @@ -47,6 +50,25 @@ public class MainActivity extends ReactActivity {
}
}
```
</details>

<details>
<summary>Kotlin</summary>

```kotlin
import android.os.Bundle;

class MainActivity: ReactActivity() {

//...code

//react-native-screens override
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(null);
}
}
```
</details>

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).

Expand Down
9 changes: 9 additions & 0 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 4a44260

Please sign in to comment.