-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #652 from wix/RetryFailedInvocation
Android: Support RN50-51 changes
- Loading branch information
Showing
9 changed files
with
129 additions
and
77 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
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
42 changes: 42 additions & 0 deletions
42
detox/android/detox/src/main/java/com/wix/detox/ReactNativeCompat.java
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,42 @@ | ||
package com.wix.detox; | ||
|
||
import org.joor.Reflect; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ReactNativeCompat { | ||
static Map<String, Object> VERSION; | ||
|
||
static { | ||
try { | ||
Class reactNativeVersion = Class.forName("com.facebook.react.modules.systeminfo.ReactNativeVersion"); | ||
VERSION = Reflect.on(reactNativeVersion).field("VERSION").get(); | ||
} catch (ClassNotFoundException e) { | ||
//ReactNativeVersion was introduced in RN50, default to latest previous version. | ||
VERSION = new HashMap<>(); | ||
VERSION.put("major", 0); | ||
VERSION.put("minor", 49); | ||
VERSION.put("patch", 0); | ||
} | ||
|
||
} | ||
|
||
public static int getMinor() { | ||
return (Integer) VERSION.get("minor"); | ||
} | ||
|
||
public static void waitForReactNativeLoad(Object reactNativeHostHolder) { | ||
if (getMinor() >= 50) { | ||
ReactNativeSupport.waitForReactNativeLoad(reactNativeHostHolder); | ||
try { | ||
//TODO- Temp hack to make Detox usable for RN>=50 till we find a better sync solution. | ||
Thread.sleep(1000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} else { | ||
ReactNativeSupport.waitForReactNativeLoad(reactNativeHostHolder); | ||
} | ||
} | ||
} |
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
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
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
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
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
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