Skip to content

Commit ca6008f

Browse files
committed
Fixes after PR
1 parent 95a4ad6 commit ca6008f

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

lib/android/app/src/main/java/com/reactnativenavigation/views/touch/OverlayTouchDelegate.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.reactnativenavigation.views.touch
22

33
import android.view.MotionEvent
4+
import android.view.View
45
import android.view.ViewGroup
56
import androidx.annotation.VisibleForTesting
67
import com.facebook.react.views.debuggingoverlay.DebuggingOverlay
@@ -49,17 +50,14 @@ open class OverlayTouchDelegate(
4950
for (i in 0 until reactViewSurface.childCount) {
5051
val childItem = reactViewSurface.getChildAt(i)
5152

52-
if (childItem is ViewGroup) {
53-
if (childItem.getChildAt(0) is DebuggingOverlay) {
54-
continue
55-
}
56-
}
57-
58-
if (childItem.isVisible && event.coordinatesInsideView(childItem)) {
53+
if (!debuggingOverlay(childItem) && childItem.isVisible && event.coordinatesInsideView(childItem)) {
5954
return true
6055
}
6156
}
6257
return false
6358
}
6459

60+
private fun debuggingOverlay(childItem: View?): Boolean =
61+
childItem is ViewGroup && childItem.getChildAt(0) is DebuggingOverlay
62+
6563
}

lib/android/app/src/test/java/com/reactnativenavigation/views/OverlayTouchDelegateTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import com.reactnativenavigation.views.touch.OverlayTouchDelegate;
1414

1515
import org.junit.Test;
16-
import org.mockito.invocation.InvocationOnMock;
1716
import org.mockito.stubbing.Answer;
1817

1918
import static org.assertj.core.api.Java6Assertions.assertThat;
@@ -36,12 +35,12 @@ public class OverlayTouchDelegateTest extends BaseTest {
3635

3736
@Override
3837
public void beforeEach() {
39-
mockHierarchy();
38+
reactView = mock(ReactView.class);
39+
component = mock(ComponentLayout.class);
4040
uut = spy(new OverlayTouchDelegate(component, reactView));
4141
}
4242

43-
private void mockHierarchy() {
44-
reactView = mock(ReactView.class);
43+
private void mockHierarchyWithDebuggingOverlay() {
4544
// Mock the hierarchy: ReactView -> ReactSurfaceView -> ReactViewGroup(s)
4645
ViewGroup reactSurfaceView = mock(ViewGroup.class);
4746
ViewGroup debuggingOverlayContainer = mock(ViewGroup.class);
@@ -81,12 +80,11 @@ private void mockHierarchy() {
8180
rect.set(new Rect(0, 0, 100, 100));
8281
return null;
8382
}).when(debuggingOverlayContainer).getHitRect(any(Rect.class));
84-
85-
component = mock(ComponentLayout.class);
8683
}
8784

8885
@Test
8986
public void downEventIsHandled() {
87+
mockHierarchyWithDebuggingOverlay();
9088
uut.setInterceptTouchOutside(new Bool(true));
9189
uut.onInterceptTouchEvent(downEvent);
9290
verify(uut, times(1)).handleDown(downEvent);

0 commit comments

Comments
 (0)