{"action":"created","comment":{"url":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/comments/134090473","pull_request_review_id":57349003,"id":134090473,"diff_hunk":"@@ -42,4 +53,50 @@ public void onComplete(@NonNull Task<Void> task) {\n                     }\n                 });\n     }\n+\n+    public static void createUserIfDoesntExist() {\n+        final DatabaseReference currentUserReference = getCurrentUserReference();\n+        currentUserReference.addListenerForSingleValueEvent(new ValueEventListener() {\n+            @Override\n+            public void onDataChange(DataSnapshot dataSnapshot) {\n+                Log.v(LOG_TAG, \"onDataChange\");\n+                if (dataSnapshot.getValue() == null) {\n+                    Log.v(LOG_TAG, \"User does not exist, creating...\");\n+                    User user = new User();\n+                    FirebaseUser firebaseUser = getFirebaseUser();\n+                    user.setEmail(firebaseUser.getEmail());\n+                    user.setId(firebaseUser.getUid());\n+                    currentUserReference.setValue(user);\n+                } else {\n+                    User currentUser = dataSnapshot.getValue(User.class);\n+                    Log.v(LOG_TAG, \"User exists: \" + currentUser);\n+                }\n+            }\n+\n+            @Override\n+            public void onCancelled(DatabaseError databaseError) {\n+                Log.v(LOG_TAG, \"onCancelled\");\n+            }\n+        });\n+    }\n+\n+    private static DatabaseReference getCurrentUserReference() {\n+        final FirebaseDatabase database = FirebaseDatabase.getInstance();\n+        // get reference to \"user\" list","path":"app/src/main/java/eu/laramartin/medsreminder/firebase/FirebaseUtility.java","position":66,"original_position":66,"commit_id":"78d81d995163ced295c61806a3583438d81bbb22","original_commit_id":"78d81d995163ced295c61806a3583438d81bbb22","user":{"login":"laramartin","id":13904500,"avatar_url":"https://avatars1.githubusercontent.com/u/13904500?v=4","gravatar_id":"","url":"https://api.github.com/users/laramartin","html_url":"https://github.com/laramartin","followers_url":"https://api.github.com/users/laramartin/followers","following_url":"https://api.github.com/users/laramartin/following{/other_user}","gists_url":"https://api.github.com/users/laramartin/gists{/gist_id}","starred_url":"https://api.github.com/users/laramartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laramartin/subscriptions","organizations_url":"https://api.github.com/users/laramartin/orgs","repos_url":"https://api.github.com/users/laramartin/repos","events_url":"https://api.github.com/users/laramartin/events{/privacy}","received_events_url":"https://api.github.com/users/laramartin/received_events","type":"User","site_admin":false},"body":"remove","created_at":"2017-08-19T12:15:38Z","updated_at":"2017-08-19T12:17:24Z","html_url":"https://github.com/laramartin/android_meds_reminder/pull/1#discussion_r134090473","pull_request_url":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/comments/134090473"},"html":{"href":"https://github.com/laramartin/android_meds_reminder/pull/1#discussion_r134090473"},"pull_request":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/1","id":136605071,"html_url":"https://github.com/laramartin/android_meds_reminder/pull/1","diff_url":"https://github.com/laramartin/android_meds_reminder/pull/1.diff","patch_url":"https://github.com/laramartin/android_meds_reminder/pull/1.patch","issue_url":"https://api.github.com/repos/laramartin/android_meds_reminder/issues/1","number":1,"state":"open","locked":false,"title":"Integrate database","user":{"login":"laramartin","id":13904500,"avatar_url":"https://avatars1.githubusercontent.com/u/13904500?v=4","gravatar_id":"","url":"https://api.github.com/users/laramartin","html_url":"https://github.com/laramartin","followers_url":"https://api.github.com/users/laramartin/followers","following_url":"https://api.github.com/users/laramartin/following{/other_user}","gists_url":"https://api.github.com/users/laramartin/gists{/gist_id}","starred_url":"https://api.github.com/users/laramartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laramartin/subscriptions","organizations_url":"https://api.github.com/users/laramartin/orgs","repos_url":"https://api.github.com/users/laramartin/repos","events_url":"https://api.github.com/users/laramartin/events{/privacy}","received_events_url":"https://api.github.com/users/laramartin/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-19T12:13:57Z","updated_at":"2017-08-19T12:17:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1a51415efca46ac92d491473629fe7674ff5b13e","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/1/commits","review_comments_url":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/1/comments","review_comment_url":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/laramartin/android_meds_reminder/issues/1/comments","statuses_url":"https://api.github.com/repos/laramartin/android_meds_reminder/statuses/78d81d995163ced295c61806a3583438d81bbb22","head":{"label":"laramartin:experiment_database","ref":"experiment_database","sha":"78d81d995163ced295c61806a3583438d81bbb22","user":{"login":"laramartin","id":13904500,"avatar_url":"https://avatars1.githubusercontent.com/u/13904500?v=4","gravatar_id":"","url":"https://api.github.com/users/laramartin","html_url":"https://github.com/laramartin","followers_url":"https://api.github.com/users/laramartin/followers","following_url":"https://api.github.com/users/laramartin/following{/other_user}","gists_url":"https://api.github.com/users/laramartin/gists{/gist_id}","starred_url":"https://api.github.com/users/laramartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laramartin/subscriptions","organizations_url":"https://api.github.com/users/laramartin/orgs","repos_url":"https://api.github.com/users/laramartin/repos","events_url":"https://api.github.com/users/laramartin/events{/privacy}","received_events_url":"https://api.github.com/users/laramartin/received_events","type":"User","site_admin":false},"repo":{"id":99438071,"name":"android_meds_reminder","full_name":"laramartin/android_meds_reminder","owner":{"login":"laramartin","id":13904500,"avatar_url":"https://avatars1.githubusercontent.com/u/13904500?v=4","gravatar_id":"","url":"https://api.github.com/users/laramartin","html_url":"https://github.com/laramartin","followers_url":"https://api.github.com/users/laramartin/followers","following_url":"https://api.github.com/users/laramartin/following{/other_user}","gists_url":"https://api.github.com/users/laramartin/gists{/gist_id}","starred_url":"https://api.github.com/users/laramartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laramartin/subscriptions","organizations_url":"https://api.github.com/users/laramartin/orgs","repos_url":"https://api.github.com/users/laramartin/repos","events_url":"https://api.github.com/users/laramartin/events{/privacy}","received_events_url":"https://api.github.com/users/laramartin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/laramartin/android_meds_reminder","description":null,"fork":false,"url":"https://api.github.com/repos/laramartin/android_meds_reminder","forks_url":"https://api.github.com/repos/laramartin/android_meds_reminder/forks","keys_url":"https://api.github.com/repos/laramartin/android_meds_reminder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laramartin/android_meds_reminder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laramartin/android_meds_reminder/teams","hooks_url":"https://api.github.com/repos/laramartin/android_meds_reminder/hooks","issue_events_url":"https://api.github.com/repos/laramartin/android_meds_reminder/issues/events{/number}","events_url":"https://api.github.com/repos/laramartin/android_meds_reminder/events","assignees_url":"https://api.github.com/repos/laramartin/android_meds_reminder/assignees{/user}","branches_url":"https://api.github.com/repos/laramartin/android_meds_reminder/branches{/branch}","tags_url":"https://api.github.com/repos/laramartin/android_meds_reminder/tags","blobs_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/refs{/sha}","trees_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laramartin/android_meds_reminder/statuses/{sha}","languages_url":"https://api.github.com/repos/laramartin/android_meds_reminder/languages","stargazers_url":"https://api.github.com/repos/laramartin/android_meds_reminder/stargazers","contributors_url":"https://api.github.com/repos/laramartin/android_meds_reminder/contributors","subscribers_url":"https://api.github.com/repos/laramartin/android_meds_reminder/subscribers","subscription_url":"https://api.github.com/repos/laramartin/android_meds_reminder/subscription","commits_url":"https://api.github.com/repos/laramartin/android_meds_reminder/commits{/sha}","git_commits_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/commits{/sha}","comments_url":"https://api.github.com/repos/laramartin/android_meds_reminder/comments{/number}","issue_comment_url":"https://api.github.com/repos/laramartin/android_meds_reminder/issues/comments{/number}","contents_url":"https://api.github.com/repos/laramartin/android_meds_reminder/contents/{+path}","compare_url":"https://api.github.com/repos/laramartin/android_meds_reminder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laramartin/android_meds_reminder/merges","archive_url":"https://api.github.com/repos/laramartin/android_meds_reminder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laramartin/android_meds_reminder/downloads","issues_url":"https://api.github.com/repos/laramartin/android_meds_reminder/issues{/number}","pulls_url":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls{/number}","milestones_url":"https://api.github.com/repos/laramartin/android_meds_reminder/milestones{/number}","notifications_url":"https://api.github.com/repos/laramartin/android_meds_reminder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laramartin/android_meds_reminder/labels{/name}","releases_url":"https://api.github.com/repos/laramartin/android_meds_reminder/releases{/id}","deployments_url":"https://api.github.com/repos/laramartin/android_meds_reminder/deployments","created_at":"2017-08-05T17:35:23Z","updated_at":"2017-08-05T18:41:04Z","pushed_at":"2017-08-19T12:13:58Z","git_url":"git://github.com/laramartin/android_meds_reminder.git","ssh_url":"git@github.com:laramartin/android_meds_reminder.git","clone_url":"https://github.com/laramartin/android_meds_reminder.git","svn_url":"https://github.com/laramartin/android_meds_reminder","homepage":null,"size":309,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"laramartin:master","ref":"master","sha":"5a609797535f89b743a09e340fed4d370b193140","user":{"login":"laramartin","id":13904500,"avatar_url":"https://avatars1.githubusercontent.com/u/13904500?v=4","gravatar_id":"","url":"https://api.github.com/users/laramartin","html_url":"https://github.com/laramartin","followers_url":"https://api.github.com/users/laramartin/followers","following_url":"https://api.github.com/users/laramartin/following{/other_user}","gists_url":"https://api.github.com/users/laramartin/gists{/gist_id}","starred_url":"https://api.github.com/users/laramartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laramartin/subscriptions","organizations_url":"https://api.github.com/users/laramartin/orgs","repos_url":"https://api.github.com/users/laramartin/repos","events_url":"https://api.github.com/users/laramartin/events{/privacy}","received_events_url":"https://api.github.com/users/laramartin/received_events","type":"User","site_admin":false},"repo":{"id":99438071,"name":"android_meds_reminder","full_name":"laramartin/android_meds_reminder","owner":{"login":"laramartin","id":13904500,"avatar_url":"https://avatars1.githubusercontent.com/u/13904500?v=4","gravatar_id":"","url":"https://api.github.com/users/laramartin","html_url":"https://github.com/laramartin","followers_url":"https://api.github.com/users/laramartin/followers","following_url":"https://api.github.com/users/laramartin/following{/other_user}","gists_url":"https://api.github.com/users/laramartin/gists{/gist_id}","starred_url":"https://api.github.com/users/laramartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laramartin/subscriptions","organizations_url":"https://api.github.com/users/laramartin/orgs","repos_url":"https://api.github.com/users/laramartin/repos","events_url":"https://api.github.com/users/laramartin/events{/privacy}","received_events_url":"https://api.github.com/users/laramartin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/laramartin/android_meds_reminder","description":null,"fork":false,"url":"https://api.github.com/repos/laramartin/android_meds_reminder","forks_url":"https://api.github.com/repos/laramartin/android_meds_reminder/forks","keys_url":"https://api.github.com/repos/laramartin/android_meds_reminder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/laramartin/android_meds_reminder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/laramartin/android_meds_reminder/teams","hooks_url":"https://api.github.com/repos/laramartin/android_meds_reminder/hooks","issue_events_url":"https://api.github.com/repos/laramartin/android_meds_reminder/issues/events{/number}","events_url":"https://api.github.com/repos/laramartin/android_meds_reminder/events","assignees_url":"https://api.github.com/repos/laramartin/android_meds_reminder/assignees{/user}","branches_url":"https://api.github.com/repos/laramartin/android_meds_reminder/branches{/branch}","tags_url":"https://api.github.com/repos/laramartin/android_meds_reminder/tags","blobs_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/refs{/sha}","trees_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/laramartin/android_meds_reminder/statuses/{sha}","languages_url":"https://api.github.com/repos/laramartin/android_meds_reminder/languages","stargazers_url":"https://api.github.com/repos/laramartin/android_meds_reminder/stargazers","contributors_url":"https://api.github.com/repos/laramartin/android_meds_reminder/contributors","subscribers_url":"https://api.github.com/repos/laramartin/android_meds_reminder/subscribers","subscription_url":"https://api.github.com/repos/laramartin/android_meds_reminder/subscription","commits_url":"https://api.github.com/repos/laramartin/android_meds_reminder/commits{/sha}","git_commits_url":"https://api.github.com/repos/laramartin/android_meds_reminder/git/commits{/sha}","comments_url":"https://api.github.com/repos/laramartin/android_meds_reminder/comments{/number}","issue_comment_url":"https://api.github.com/repos/laramartin/android_meds_reminder/issues/comments{/number}","contents_url":"https://api.github.com/repos/laramartin/android_meds_reminder/contents/{+path}","compare_url":"https://api.github.com/repos/laramartin/android_meds_reminder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/laramartin/android_meds_reminder/merges","archive_url":"https://api.github.com/repos/laramartin/android_meds_reminder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/laramartin/android_meds_reminder/downloads","issues_url":"https://api.github.com/repos/laramartin/android_meds_reminder/issues{/number}","pulls_url":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls{/number}","milestones_url":"https://api.github.com/repos/laramartin/android_meds_reminder/milestones{/number}","notifications_url":"https://api.github.com/repos/laramartin/android_meds_reminder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/laramartin/android_meds_reminder/labels{/name}","releases_url":"https://api.github.com/repos/laramartin/android_meds_reminder/releases{/id}","deployments_url":"https://api.github.com/repos/laramartin/android_meds_reminder/deployments","created_at":"2017-08-05T17:35:23Z","updated_at":"2017-08-05T18:41:04Z","pushed_at":"2017-08-19T12:13:58Z","git_url":"git://github.com/laramartin/android_meds_reminder.git","ssh_url":"git@github.com:laramartin/android_meds_reminder.git","clone_url":"https://github.com/laramartin/android_meds_reminder.git","svn_url":"https://github.com/laramartin/android_meds_reminder","homepage":null,"size":309,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/1"},"html":{"href":"https://github.com/laramartin/android_meds_reminder/pull/1"},"issue":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/issues/1"},"comments":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/laramartin/android_meds_reminder/statuses/78d81d995163ced295c61806a3583438d81bbb22"}}}}
{"actor":{"display_login":"laramartin"}}