mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Implement addUIBlock to allow third party to resolve a view
Summary: This PR follows the work started in #6431 but instead of implementing the snapshot for Android, will just allow that feature to be implemented by a third party library. The missing feature is the ability to resolve a View for a given tag integer. which is now possible with a `addUIBlock` on the `UIManagerModule` method where you give a `UIBlock` instance (a new class) that implements a `execute(NativeViewHierarchyManager)` function. This is already possible in iOS API. a third party can use the `addUIBlock` too. I have kept the name `addUIBlock` so it's the same as in the [iOS' API](https://github.com/facebook/react-native/search?q=addUIBlock&type=Code&utf8=%E2%9C%93). --- With this PR a third party lib can now do... ```java UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { View view = nvhm.resolveView(tag); ...do something with view... like... screenshot t Closes https://github.com/facebook/react-native/pull/8217 Differential Revision: D3469311 Pulled By: astreet fbshipit-source-id: bb56ecc7e8936299337af47ca8114875ee1fd2b0
This commit is contained in:
committed by
Facebook Github Bot 2
parent
4c83237511
commit
af28de5300
@@ -473,4 +473,24 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
||||
public void sendAccessibilityEvent(int tag, int eventType) {
|
||||
mUIImplementation.sendAccessibilityEvent(tag, eventType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a block to be executed on the UI thread. Useful if you need to execute
|
||||
* view logic after all currently queued view updates have completed.
|
||||
*
|
||||
* @param block that contains UI logic you want to execute.
|
||||
*
|
||||
* Usage Example:
|
||||
|
||||
UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class);
|
||||
uiManager.addUIBlock(new UIBlock() {
|
||||
public void execute (NativeViewHierarchyManager nvhm) {
|
||||
View view = nvhm.resolveView(tag);
|
||||
// ...execute your code on View (e.g. snapshot the view)
|
||||
}
|
||||
});
|
||||
*/
|
||||
public void addUIBlock (UIBlock block) {
|
||||
mUIImplementation.addUIBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user