The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | diff --git a/android/src/main/java/expo/modules/kotlin/views/ExpoView.kt b/android/src/main/java/expo/modules/kotlin/views/ExpoView.kt |
| 2 | index c732ab4..2e3f40e 100644 |
| 3 | --- a/android/src/main/java/expo/modules/kotlin/views/ExpoView.kt |
| 4 | +++ b/android/src/main/java/expo/modules/kotlin/views/ExpoView.kt |
| 5 | @@ -3,6 +3,7 @@ package expo.modules.kotlin.views |
| 6 | import android.content.Context |
| 7 | import android.graphics.Canvas |
| 8 | import android.widget.LinearLayout |
| 9 | +import androidx.core.view.OneShotPreDrawListener |
| 10 | import androidx.annotation.UiThread |
| 11 | import com.facebook.react.uimanager.BackgroundStyleApplicator |
| 12 | import com.facebook.react.uimanager.StateWrapper |
| 13 | @@ -47,12 +48,27 @@ abstract class ExpoView( |
| 14 | layout(left, top, right, bottom) |
| 15 | } |
| 16 | |
| 17 | + private var isLayoutScheduled = false |
| 18 | + |
| 19 | override fun requestLayout() { |
| 20 | super.requestLayout() |
| 21 | - if (shouldUseAndroidLayout) { |
| 22 | + if (shouldUseAndroidLayout && !isLayoutScheduled) { |
| 23 | // We need to force measure and layout, because React Native doesn't do it for us. |
| 24 | - post { measureAndLayout() } |
| 25 | + // A posted layout runs after the frame being prepared is drawn, so a view that changes in a |
| 26 | + // mount would show unlaid-out content for a frame. The pre-draw listener lays it out before |
| 27 | + // that frame instead; the post covers a request that no frame follows. |
| 28 | + isLayoutScheduled = true |
| 29 | + OneShotPreDrawListener.add(this) { runScheduledLayout() } |
| 30 | + post { runScheduledLayout() } |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + private fun runScheduledLayout() { |
| 35 | + if (!isLayoutScheduled) { |
| 36 | + return |
| 37 | } |
| 38 | + isLayoutScheduled = false |
| 39 | + measureAndLayout() |
| 40 | } |
| 41 | |
| 42 | override fun forceLayout() { |