mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-15 07:28:31 +08:00
Fix a bug, if clipData is null we can not ask getItemCount() from it
Summary: I ran into problems when using Clipboard.getString() in Android. The method seems to work fine when there is *something* in the clipboard, but when it's empty the app crashes. I think I've tracked down the bug to ClipboardModule.java@58. When clipData is null, the promise is resolved with an empty string. However, after that the rest of the block is executed. There should be a return or an 'else if' like in my pr. Screenshot of the error message when clipboard is empty:  Closes https://github.com/facebook/react-native/pull/7527 Differential Revision: D3292232 fbshipit-source-id: d2191286c49ee31233203fab4648449964b9d950
This commit is contained in:
committed by
Facebook Github Bot 3
parent
55c308615a
commit
85d2086321
@@ -54,8 +54,7 @@ public class ClipboardModule extends ReactContextBaseJavaModule {
|
||||
ClipData clipData = clipboard.getPrimaryClip();
|
||||
if (clipData == null) {
|
||||
promise.resolve("");
|
||||
}
|
||||
if (clipData.getItemCount() >= 1) {
|
||||
} else if (clipData.getItemCount() >= 1) {
|
||||
ClipData.Item firstItem = clipboard.getPrimaryClip().getItemAt(0);
|
||||
promise.resolve("" + firstItem.getText());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user