{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/react-native/pulls/comments/50176586","id":50176586,"diff_hunk":"@@ -43,28 +44,42 @@ public String getName() {\n   }\n \n   private ClipboardManager getClipboardService() {\n-    ReactApplicationContext reactContext = getReactApplicationContext(); \n+    ReactApplicationContext reactContext = getReactApplicationContext();\n     return (ClipboardManager) reactContext.getSystemService(reactContext.CLIPBOARD_SERVICE);\n   }\n \n+  private String getStringInternal(){\n+    ClipboardManager clipboard = getClipboardService();\n+    ClipData clipData = clipboard.getPrimaryClip();\n+    if (clipData == null) {\n+      return \"\";\n+    }\n+    if (clipData.getItemCount() >= 1) {\n+      ClipData.Item firstItem = clipboard.getPrimaryClip().getItemAt(0);\n+      return \"\" + firstItem.getText();\n+    } else {\n+      return \"\";\n+    }\n+  }\n+\n   @ReactMethod\n   public void getString(Callback cb) {\n     try {\n-      ClipboardManager clipboard = getClipboardService();\n-      ClipData clipData = clipboard.getPrimaryClip();\n-      if (clipData == null) {\n-        cb.invoke(\"\");\n-        return;\n-      }\n-      if (clipData.getItemCount() >= 1) {\n-        ClipData.Item firstItem = clipboard.getPrimaryClip().getItemAt(0);\n-        String text = \"\" + firstItem.getText();\n-        cb.invoke(text);\n-      } else {\n-        cb.invoke(\"\");\n-      }\n+      String ret = this.getStringInternal();\n+      cb.invoke(ret);\n+    } catch(Exception e) {\n+      FLog.w(ReactConstants.TAG, \"Cannot get clipboard contents: \" + e.getMessage());\n+    }\n+  }\n+\n+  @ReactMethod\n+  public void getStringSync(Promise promise){\n+    try {\n+      String ret = this.getStringInternal();\n+      promise.resolve(ret);\n     } catch(Exception e) {\n       FLog.w(ReactConstants.TAG, \"Cannot get clipboard contents: \" + e.getMessage());","path":"ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.java","position":60,"original_position":60,"commit_id":"93f215a6274fcc997c109750c46fcb9e648f9ecc","original_commit_id":"93f215a6274fcc997c109750c46fcb9e648f9ecc","user":{"login":"satya164","id":1174278,"avatar_url":"https://avatars.githubusercontent.com/u/1174278?v=3","gravatar_id":"","url":"https://api.github.com/users/satya164","html_url":"https://github.com/satya164","followers_url":"https://api.github.com/users/satya164/followers","following_url":"https://api.github.com/users/satya164/following{/other_user}","gists_url":"https://api.github.com/users/satya164/gists{/gist_id}","starred_url":"https://api.github.com/users/satya164/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/satya164/subscriptions","organizations_url":"https://api.github.com/users/satya164/orgs","repos_url":"https://api.github.com/users/satya164/repos","events_url":"https://api.github.com/users/satya164/events{/privacy}","received_events_url":"https://api.github.com/users/satya164/received_events","type":"User","site_admin":false},"body":"We prolly don't need a log here since we're passing the exception to JavaScript anyways.","created_at":"2016-01-19T21:17:00Z","updated_at":"2016-01-19T21:17:00Z","html_url":"https://github.com/facebook/react-native/pull/4792#discussion_r50176586","pull_request_url":"https://api.github.com/repos/facebook/react-native/pulls/4792","_links":{"self":{"href":"https://api.github.com/repos/facebook/react-native/pulls/comments/50176586"},"html":{"href":"https://github.com/facebook/react-native/pull/4792#discussion_r50176586"},"pull_request":{"href":"https://api.github.com/repos/facebook/react-native/pulls/4792"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/react-native/pulls/4792","id":53713886,"html_url":"https://github.com/facebook/react-native/pull/4792","diff_url":"https://github.com/facebook/react-native/pull/4792.diff","patch_url":"https://github.com/facebook/react-native/pull/4792.patch","issue_url":"https://api.github.com/repos/facebook/react-native/issues/4792","number":4792,"state":"open","locked":false,"title":"android clipboard add error callback","user":{"login":"TanTan-TT","id":10612133,"avatar_url":"https://avatars.githubusercontent.com/u/10612133?v=3","gravatar_id":"","url":"https://api.github.com/users/TanTan-TT","html_url":"https://github.com/TanTan-TT","followers_url":"https://api.github.com/users/TanTan-TT/followers","following_url":"https://api.github.com/users/TanTan-TT/following{/other_user}","gists_url":"https://api.github.com/users/TanTan-TT/gists{/gist_id}","starred_url":"https://api.github.com/users/TanTan-TT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TanTan-TT/subscriptions","organizations_url":"https://api.github.com/users/TanTan-TT/orgs","repos_url":"https://api.github.com/users/TanTan-TT/repos","events_url":"https://api.github.com/users/TanTan-TT/events{/privacy}","received_events_url":"https://api.github.com/users/TanTan-TT/received_events","type":"User","site_admin":false},"body":"For clipboard, add error callback in Android. Code like\r\n```javascript\r\nClipboard.getString((content)=>{\r\n    //do something\r\n},(error)=>{\r\n   //do something for error\r\n})\r\n```","created_at":"2015-12-15T15:01:11Z","updated_at":"2016-01-19T21:17:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbb53c1223199c8afc7e8a43f1b26d2ed2a56f86","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/facebook/react-native/pulls/4792/commits","review_comments_url":"https://api.github.com/repos/facebook/react-native/pulls/4792/comments","review_comment_url":"https://api.github.com/repos/facebook/react-native/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/4792/comments","statuses_url":"https://api.github.com/repos/facebook/react-native/statuses/93f215a6274fcc997c109750c46fcb9e648f9ecc","head":{"label":"TanTan-TT:clipboard-android-error-callback","ref":"clipboard-android-error-callback","sha":"93f215a6274fcc997c109750c46fcb9e648f9ecc","user":{"login":"TanTan-TT","id":10612133,"avatar_url":"https://avatars.githubusercontent.com/u/10612133?v=3","gravatar_id":"","url":"https://api.github.com/users/TanTan-TT","html_url":"https://github.com/TanTan-TT","followers_url":"https://api.github.com/users/TanTan-TT/followers","following_url":"https://api.github.com/users/TanTan-TT/following{/other_user}","gists_url":"https://api.github.com/users/TanTan-TT/gists{/gist_id}","starred_url":"https://api.github.com/users/TanTan-TT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TanTan-TT/subscriptions","organizations_url":"https://api.github.com/users/TanTan-TT/orgs","repos_url":"https://api.github.com/users/TanTan-TT/repos","events_url":"https://api.github.com/users/TanTan-TT/events{/privacy}","received_events_url":"https://api.github.com/users/TanTan-TT/received_events","type":"User","site_admin":false},"repo":{"id":46960906,"name":"react-native","full_name":"TanTan-TT/react-native","owner":{"login":"TanTan-TT","id":10612133,"avatar_url":"https://avatars.githubusercontent.com/u/10612133?v=3","gravatar_id":"","url":"https://api.github.com/users/TanTan-TT","html_url":"https://github.com/TanTan-TT","followers_url":"https://api.github.com/users/TanTan-TT/followers","following_url":"https://api.github.com/users/TanTan-TT/following{/other_user}","gists_url":"https://api.github.com/users/TanTan-TT/gists{/gist_id}","starred_url":"https://api.github.com/users/TanTan-TT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TanTan-TT/subscriptions","organizations_url":"https://api.github.com/users/TanTan-TT/orgs","repos_url":"https://api.github.com/users/TanTan-TT/repos","events_url":"https://api.github.com/users/TanTan-TT/events{/privacy}","received_events_url":"https://api.github.com/users/TanTan-TT/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TanTan-TT/react-native","description":"A framework for building native apps with React.","fork":true,"url":"https://api.github.com/repos/TanTan-TT/react-native","forks_url":"https://api.github.com/repos/TanTan-TT/react-native/forks","keys_url":"https://api.github.com/repos/TanTan-TT/react-native/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TanTan-TT/react-native/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TanTan-TT/react-native/teams","hooks_url":"https://api.github.com/repos/TanTan-TT/react-native/hooks","issue_events_url":"https://api.github.com/repos/TanTan-TT/react-native/issues/events{/number}","events_url":"https://api.github.com/repos/TanTan-TT/react-native/events","assignees_url":"https://api.github.com/repos/TanTan-TT/react-native/assignees{/user}","branches_url":"https://api.github.com/repos/TanTan-TT/react-native/branches{/branch}","tags_url":"https://api.github.com/repos/TanTan-TT/react-native/tags","blobs_url":"https://api.github.com/repos/TanTan-TT/react-native/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TanTan-TT/react-native/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TanTan-TT/react-native/git/refs{/sha}","trees_url":"https://api.github.com/repos/TanTan-TT/react-native/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TanTan-TT/react-native/statuses/{sha}","languages_url":"https://api.github.com/repos/TanTan-TT/react-native/languages","stargazers_url":"https://api.github.com/repos/TanTan-TT/react-native/stargazers","contributors_url":"https://api.github.com/repos/TanTan-TT/react-native/contributors","subscribers_url":"https://api.github.com/repos/TanTan-TT/react-native/subscribers","subscription_url":"https://api.github.com/repos/TanTan-TT/react-native/subscription","commits_url":"https://api.github.com/repos/TanTan-TT/react-native/commits{/sha}","git_commits_url":"https://api.github.com/repos/TanTan-TT/react-native/git/commits{/sha}","comments_url":"https://api.github.com/repos/TanTan-TT/react-native/comments{/number}","issue_comment_url":"https://api.github.com/repos/TanTan-TT/react-native/issues/comments{/number}","contents_url":"https://api.github.com/repos/TanTan-TT/react-native/contents/{+path}","compare_url":"https://api.github.com/repos/TanTan-TT/react-native/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TanTan-TT/react-native/merges","archive_url":"https://api.github.com/repos/TanTan-TT/react-native/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TanTan-TT/react-native/downloads","issues_url":"https://api.github.com/repos/TanTan-TT/react-native/issues{/number}","pulls_url":"https://api.github.com/repos/TanTan-TT/react-native/pulls{/number}","milestones_url":"https://api.github.com/repos/TanTan-TT/react-native/milestones{/number}","notifications_url":"https://api.github.com/repos/TanTan-TT/react-native/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TanTan-TT/react-native/labels{/name}","releases_url":"https://api.github.com/repos/TanTan-TT/react-native/releases{/id}","created_at":"2015-11-27T05:13:09Z","updated_at":"2015-11-27T05:13:15Z","pushed_at":"2016-01-19T10:30:03Z","git_url":"git://github.com/TanTan-TT/react-native.git","ssh_url":"git@github.com:TanTan-TT/react-native.git","clone_url":"https://github.com/TanTan-TT/react-native.git","svn_url":"https://github.com/TanTan-TT/react-native","homepage":"http://facebook.github.io/react-native/","size":37968,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"1f501a9431a56a357987dcf42520c0626b713b50","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":29028775,"name":"react-native","full_name":"facebook/react-native","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/react-native","description":"A framework for building native apps with React.","fork":false,"url":"https://api.github.com/repos/facebook/react-native","forks_url":"https://api.github.com/repos/facebook/react-native/forks","keys_url":"https://api.github.com/repos/facebook/react-native/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/react-native/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/react-native/teams","hooks_url":"https://api.github.com/repos/facebook/react-native/hooks","issue_events_url":"https://api.github.com/repos/facebook/react-native/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/react-native/events","assignees_url":"https://api.github.com/repos/facebook/react-native/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/react-native/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/react-native/tags","blobs_url":"https://api.github.com/repos/facebook/react-native/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/react-native/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/react-native/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/react-native/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/react-native/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/react-native/languages","stargazers_url":"https://api.github.com/repos/facebook/react-native/stargazers","contributors_url":"https://api.github.com/repos/facebook/react-native/contributors","subscribers_url":"https://api.github.com/repos/facebook/react-native/subscribers","subscription_url":"https://api.github.com/repos/facebook/react-native/subscription","commits_url":"https://api.github.com/repos/facebook/react-native/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/react-native/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/react-native/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/react-native/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/react-native/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/react-native/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/react-native/merges","archive_url":"https://api.github.com/repos/facebook/react-native/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/react-native/downloads","issues_url":"https://api.github.com/repos/facebook/react-native/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/react-native/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/react-native/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/react-native/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/react-native/labels{/name}","releases_url":"https://api.github.com/repos/facebook/react-native/releases{/id}","created_at":"2015-01-09T18:10:16Z","updated_at":"2016-01-19T21:14:33Z","pushed_at":"2016-01-19T20:20:41Z","git_url":"git://github.com/facebook/react-native.git","ssh_url":"git@github.com:facebook/react-native.git","clone_url":"https://github.com/facebook/react-native.git","svn_url":"https://github.com/facebook/react-native","homepage":"http://facebook.github.io/react-native/","size":71844,"stargazers_count":25974,"watchers_count":25974,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4543,"mirror_url":null,"open_issues_count":983,"forks":4543,"open_issues":983,"watchers":25974,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/react-native/pulls/4792"},"html":{"href":"https://github.com/facebook/react-native/pull/4792"},"issue":{"href":"https://api.github.com/repos/facebook/react-native/issues/4792"},"comments":{"href":"https://api.github.com/repos/facebook/react-native/issues/4792/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/react-native/pulls/4792/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/react-native/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/react-native/pulls/4792/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/react-native/statuses/93f215a6274fcc997c109750c46fcb9e648f9ecc"}}}}