{"action":"created","comment":{"url":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/comments/42173025","id":42173025,"diff_hunk":"@@ -0,0 +1,122 @@\n+package com.example.zghadyali.googlegram;\n+\n+import android.os.Bundle;\n+import android.support.v4.app.Fragment;\n+import android.view.LayoutInflater;\n+import android.view.View;\n+import android.view.ViewGroup;\n+import android.webkit.WebView;\n+import android.widget.Button;\n+\n+import java.util.ArrayList;\n+\n+/**\n+ * The FeedFragment reads any of the links stored in the SQLite database on the user's phone and\n+ * loads them for the user to see and scroll through. The user can delete images from their feed and\n+ * can switch back to the searchGoogle fragment to search for more images\n+ */\n+public class FeedFragment extends Fragment {\n+\n+    public Button switchGoogle;\n+    public Button nextImage;\n+    public Button prevImage;\n+    public Button delete;\n+    public ArrayList<String> imagesLink = new ArrayList<String>();\n+    public WebView web;\n+    public int image_index;\n+    public FeedReaderDbHelper DbHelper;\n+\n+    @Override\n+    public void onCreate(Bundle savedInstanceState) {\n+        super.onCreate(savedInstanceState);\n+    }\n+\n+    @Override\n+    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {\n+        //initializes the DbHelper to read from a SQLite database on the user's phone and load the\n+        //saved images in the feed\n+        DbHelper = new FeedReaderDbHelper(getContext());\n+        //initializes the WebView and read the links stored in the database and returns them as an\n+        //ArrayList of strings and loads the first link in the list. If the ArrayList has nothing in\n+        // it, loads an empty WebView\n+        View rootView = inflater.inflate(R.layout.feed, container, false);\n+        web = (WebView) rootView.findViewById(R.id.rendered_image);\n+        imagesLink = DbHelper.readItemsfromDB();\n+        image_index = 0;\n+        if (imagesLink.size() > 0) {\n+            web.loadUrl(imagesLink.get(image_index));\n+        }\n+        else{\n+            web.loadUrl(\"about:blank\");\n+        }\n+        //when the user clicks the next or previous button, loops through the array of image links\n+        //to show the user the next/previous saved image, wraps around to the first image when the\n+        //user reaches the end of the array\n+        nextImage = (Button) rootView.findViewById(R.id.next);\n+        nextImage.setOnClickListener(new View.OnClickListener() {\n+            @Override\n+            public void onClick(View v) {\n+                if (imagesLink.size() > 0) {\n+                    image_index = image_index + 1;\n+                    if (image_index >= imagesLink.size()) {\n+                        image_index = 0;\n+                    }\n+                    web.loadUrl(imagesLink.get(image_index));\n+                }\n+            }\n+        });\n+        prevImage = (Button) rootView.findViewById(R.id.previous);\n+        prevImage.setOnClickListener(new View.OnClickListener() {\n+            @Override\n+            public void onClick(View v) {\n+                if (imagesLink.size() > 0) {\n+                    image_index = image_index - 1;\n+                    if (image_index < 0) {\n+                        image_index = imagesLink.size() - 1;\n+                    }\n+                    web.loadUrl(imagesLink.get(image_index));\n+                }\n+            }\n+            });\n+        //when the user clicks on the delete button, loads the WebView with the next image if there\n+        //is one to see and deletes the link to the previous image from the database and the\n+        //ArrayList\n+        delete = (Button) rootView.findViewById(R.id.delete);\n+        delete.setOnClickListener(new View.OnClickListener() {\n+            @Override\n+            public void onClick(View v) {\n+                if (imagesLink.size() > 1) {\n+                    String link = imagesLink.get(image_index);\n+                    DbHelper.deleteItemtoDB(link);\n+                    imagesLink.remove(link);\n+                    web.loadUrl(imagesLink.get(image_index));\n+\n+                }\n+                else if (imagesLink.size() == 0){   //loads a blank WebView if deleted all images in\n+                // feed\n+                    web.loadUrl(\"about:blank\");\n+                }\n+                else{   //deletes the only image in the ArrayList and loads a blank WebView\n+                    image_index = 0;\n+                    String link = imagesLink.get(image_index);\n+                    DbHelper.deleteItemtoDB(link);\n+                    imagesLink.remove(link);\n+                    web.loadUrl(\"about:blank\");\n+                }\n+            }\n+        });","path":"GoogleGram/app/src/main/java/com/example/zghadyali/googlegram/FeedFragment.java","position":107,"original_position":107,"commit_id":"0b9044b90d80d89955caddffe19002b16d1fa1ae","original_commit_id":"0b9044b90d80d89955caddffe19002b16d1fa1ae","user":{"login":"dcelik","id":5778626,"avatar_url":"https://avatars.githubusercontent.com/u/5778626?v=3","gravatar_id":"","url":"https://api.github.com/users/dcelik","html_url":"https://github.com/dcelik","followers_url":"https://api.github.com/users/dcelik/followers","following_url":"https://api.github.com/users/dcelik/following{/other_user}","gists_url":"https://api.github.com/users/dcelik/gists{/gist_id}","starred_url":"https://api.github.com/users/dcelik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcelik/subscriptions","organizations_url":"https://api.github.com/users/dcelik/orgs","repos_url":"https://api.github.com/users/dcelik/repos","events_url":"https://api.github.com/users/dcelik/events{/privacy}","received_events_url":"https://api.github.com/users/dcelik/received_events","type":"User","site_admin":false},"body":"Same comment as above.","created_at":"2015-10-15T20:05:11Z","updated_at":"2015-10-15T20:05:11Z","html_url":"https://github.com/OlinMobileProto/Lab2/pull/6#discussion_r42173025","pull_request_url":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/comments/42173025"},"html":{"href":"https://github.com/OlinMobileProto/Lab2/pull/6#discussion_r42173025"},"pull_request":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/6","id":46697765,"html_url":"https://github.com/OlinMobileProto/Lab2/pull/6","diff_url":"https://github.com/OlinMobileProto/Lab2/pull/6.diff","patch_url":"https://github.com/OlinMobileProto/Lab2/pull/6.patch","issue_url":"https://api.github.com/repos/OlinMobileProto/Lab2/issues/6","number":6,"state":"open","locked":false,"title":"Zoher: Commenting on Lab 2","user":{"login":"dcelik","id":5778626,"avatar_url":"https://avatars.githubusercontent.com/u/5778626?v=3","gravatar_id":"","url":"https://api.github.com/users/dcelik","html_url":"https://github.com/dcelik","followers_url":"https://api.github.com/users/dcelik/followers","following_url":"https://api.github.com/users/dcelik/following{/other_user}","gists_url":"https://api.github.com/users/dcelik/gists{/gist_id}","starred_url":"https://api.github.com/users/dcelik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcelik/subscriptions","organizations_url":"https://api.github.com/users/dcelik/orgs","repos_url":"https://api.github.com/users/dcelik/repos","events_url":"https://api.github.com/users/dcelik/events{/privacy}","received_events_url":"https://api.github.com/users/dcelik/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-03T02:16:01Z","updated_at":"2015-10-15T20:05:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5fd93d93ee4f4fc27e28e72b8d2a00b73b63675","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/6/commits","review_comments_url":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/6/comments","review_comment_url":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OlinMobileProto/Lab2/issues/6/comments","statuses_url":"https://api.github.com/repos/OlinMobileProto/Lab2/statuses/0b9044b90d80d89955caddffe19002b16d1fa1ae","head":{"label":"dinopants174:master","ref":"master","sha":"0b9044b90d80d89955caddffe19002b16d1fa1ae","user":{"login":"dinopants174","id":5992372,"avatar_url":"https://avatars.githubusercontent.com/u/5992372?v=3","gravatar_id":"","url":"https://api.github.com/users/dinopants174","html_url":"https://github.com/dinopants174","followers_url":"https://api.github.com/users/dinopants174/followers","following_url":"https://api.github.com/users/dinopants174/following{/other_user}","gists_url":"https://api.github.com/users/dinopants174/gists{/gist_id}","starred_url":"https://api.github.com/users/dinopants174/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dinopants174/subscriptions","organizations_url":"https://api.github.com/users/dinopants174/orgs","repos_url":"https://api.github.com/users/dinopants174/repos","events_url":"https://api.github.com/users/dinopants174/events{/privacy}","received_events_url":"https://api.github.com/users/dinopants174/received_events","type":"User","site_admin":false},"repo":{"id":42552860,"name":"Lab2","full_name":"dinopants174/Lab2","owner":{"login":"dinopants174","id":5992372,"avatar_url":"https://avatars.githubusercontent.com/u/5992372?v=3","gravatar_id":"","url":"https://api.github.com/users/dinopants174","html_url":"https://github.com/dinopants174","followers_url":"https://api.github.com/users/dinopants174/followers","following_url":"https://api.github.com/users/dinopants174/following{/other_user}","gists_url":"https://api.github.com/users/dinopants174/gists{/gist_id}","starred_url":"https://api.github.com/users/dinopants174/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dinopants174/subscriptions","organizations_url":"https://api.github.com/users/dinopants174/orgs","repos_url":"https://api.github.com/users/dinopants174/repos","events_url":"https://api.github.com/users/dinopants174/events{/privacy}","received_events_url":"https://api.github.com/users/dinopants174/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dinopants174/Lab2","description":"Lab for photo stream app for Mobile Proto","fork":true,"url":"https://api.github.com/repos/dinopants174/Lab2","forks_url":"https://api.github.com/repos/dinopants174/Lab2/forks","keys_url":"https://api.github.com/repos/dinopants174/Lab2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dinopants174/Lab2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dinopants174/Lab2/teams","hooks_url":"https://api.github.com/repos/dinopants174/Lab2/hooks","issue_events_url":"https://api.github.com/repos/dinopants174/Lab2/issues/events{/number}","events_url":"https://api.github.com/repos/dinopants174/Lab2/events","assignees_url":"https://api.github.com/repos/dinopants174/Lab2/assignees{/user}","branches_url":"https://api.github.com/repos/dinopants174/Lab2/branches{/branch}","tags_url":"https://api.github.com/repos/dinopants174/Lab2/tags","blobs_url":"https://api.github.com/repos/dinopants174/Lab2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dinopants174/Lab2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dinopants174/Lab2/git/refs{/sha}","trees_url":"https://api.github.com/repos/dinopants174/Lab2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dinopants174/Lab2/statuses/{sha}","languages_url":"https://api.github.com/repos/dinopants174/Lab2/languages","stargazers_url":"https://api.github.com/repos/dinopants174/Lab2/stargazers","contributors_url":"https://api.github.com/repos/dinopants174/Lab2/contributors","subscribers_url":"https://api.github.com/repos/dinopants174/Lab2/subscribers","subscription_url":"https://api.github.com/repos/dinopants174/Lab2/subscription","commits_url":"https://api.github.com/repos/dinopants174/Lab2/commits{/sha}","git_commits_url":"https://api.github.com/repos/dinopants174/Lab2/git/commits{/sha}","comments_url":"https://api.github.com/repos/dinopants174/Lab2/comments{/number}","issue_comment_url":"https://api.github.com/repos/dinopants174/Lab2/issues/comments{/number}","contents_url":"https://api.github.com/repos/dinopants174/Lab2/contents/{+path}","compare_url":"https://api.github.com/repos/dinopants174/Lab2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dinopants174/Lab2/merges","archive_url":"https://api.github.com/repos/dinopants174/Lab2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dinopants174/Lab2/downloads","issues_url":"https://api.github.com/repos/dinopants174/Lab2/issues{/number}","pulls_url":"https://api.github.com/repos/dinopants174/Lab2/pulls{/number}","milestones_url":"https://api.github.com/repos/dinopants174/Lab2/milestones{/number}","notifications_url":"https://api.github.com/repos/dinopants174/Lab2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dinopants174/Lab2/labels{/name}","releases_url":"https://api.github.com/repos/dinopants174/Lab2/releases{/id}","created_at":"2015-09-15T23:30:16Z","updated_at":"2015-10-01T21:40:07Z","pushed_at":"2015-10-01T21:40:06Z","git_url":"git://github.com/dinopants174/Lab2.git","ssh_url":"git@github.com:dinopants174/Lab2.git","clone_url":"https://github.com/dinopants174/Lab2.git","svn_url":"https://github.com/dinopants174/Lab2","homepage":null,"size":166,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"OlinMobileProto:master","ref":"master","sha":"18926a0030b655e3c7ba0c9d20daf56b95e33ec0","user":{"login":"OlinMobileProto","id":11400546,"avatar_url":"https://avatars.githubusercontent.com/u/11400546?v=3","gravatar_id":"","url":"https://api.github.com/users/OlinMobileProto","html_url":"https://github.com/OlinMobileProto","followers_url":"https://api.github.com/users/OlinMobileProto/followers","following_url":"https://api.github.com/users/OlinMobileProto/following{/other_user}","gists_url":"https://api.github.com/users/OlinMobileProto/gists{/gist_id}","starred_url":"https://api.github.com/users/OlinMobileProto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlinMobileProto/subscriptions","organizations_url":"https://api.github.com/users/OlinMobileProto/orgs","repos_url":"https://api.github.com/users/OlinMobileProto/repos","events_url":"https://api.github.com/users/OlinMobileProto/events{/privacy}","received_events_url":"https://api.github.com/users/OlinMobileProto/received_events","type":"Organization","site_admin":false},"repo":{"id":42400545,"name":"Lab2","full_name":"OlinMobileProto/Lab2","owner":{"login":"OlinMobileProto","id":11400546,"avatar_url":"https://avatars.githubusercontent.com/u/11400546?v=3","gravatar_id":"","url":"https://api.github.com/users/OlinMobileProto","html_url":"https://github.com/OlinMobileProto","followers_url":"https://api.github.com/users/OlinMobileProto/followers","following_url":"https://api.github.com/users/OlinMobileProto/following{/other_user}","gists_url":"https://api.github.com/users/OlinMobileProto/gists{/gist_id}","starred_url":"https://api.github.com/users/OlinMobileProto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlinMobileProto/subscriptions","organizations_url":"https://api.github.com/users/OlinMobileProto/orgs","repos_url":"https://api.github.com/users/OlinMobileProto/repos","events_url":"https://api.github.com/users/OlinMobileProto/events{/privacy}","received_events_url":"https://api.github.com/users/OlinMobileProto/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OlinMobileProto/Lab2","description":"Lab for photo stream app for Mobile Proto","fork":false,"url":"https://api.github.com/repos/OlinMobileProto/Lab2","forks_url":"https://api.github.com/repos/OlinMobileProto/Lab2/forks","keys_url":"https://api.github.com/repos/OlinMobileProto/Lab2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OlinMobileProto/Lab2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OlinMobileProto/Lab2/teams","hooks_url":"https://api.github.com/repos/OlinMobileProto/Lab2/hooks","issue_events_url":"https://api.github.com/repos/OlinMobileProto/Lab2/issues/events{/number}","events_url":"https://api.github.com/repos/OlinMobileProto/Lab2/events","assignees_url":"https://api.github.com/repos/OlinMobileProto/Lab2/assignees{/user}","branches_url":"https://api.github.com/repos/OlinMobileProto/Lab2/branches{/branch}","tags_url":"https://api.github.com/repos/OlinMobileProto/Lab2/tags","blobs_url":"https://api.github.com/repos/OlinMobileProto/Lab2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OlinMobileProto/Lab2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OlinMobileProto/Lab2/git/refs{/sha}","trees_url":"https://api.github.com/repos/OlinMobileProto/Lab2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OlinMobileProto/Lab2/statuses/{sha}","languages_url":"https://api.github.com/repos/OlinMobileProto/Lab2/languages","stargazers_url":"https://api.github.com/repos/OlinMobileProto/Lab2/stargazers","contributors_url":"https://api.github.com/repos/OlinMobileProto/Lab2/contributors","subscribers_url":"https://api.github.com/repos/OlinMobileProto/Lab2/subscribers","subscription_url":"https://api.github.com/repos/OlinMobileProto/Lab2/subscription","commits_url":"https://api.github.com/repos/OlinMobileProto/Lab2/commits{/sha}","git_commits_url":"https://api.github.com/repos/OlinMobileProto/Lab2/git/commits{/sha}","comments_url":"https://api.github.com/repos/OlinMobileProto/Lab2/comments{/number}","issue_comment_url":"https://api.github.com/repos/OlinMobileProto/Lab2/issues/comments{/number}","contents_url":"https://api.github.com/repos/OlinMobileProto/Lab2/contents/{+path}","compare_url":"https://api.github.com/repos/OlinMobileProto/Lab2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OlinMobileProto/Lab2/merges","archive_url":"https://api.github.com/repos/OlinMobileProto/Lab2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OlinMobileProto/Lab2/downloads","issues_url":"https://api.github.com/repos/OlinMobileProto/Lab2/issues{/number}","pulls_url":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls{/number}","milestones_url":"https://api.github.com/repos/OlinMobileProto/Lab2/milestones{/number}","notifications_url":"https://api.github.com/repos/OlinMobileProto/Lab2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OlinMobileProto/Lab2/labels{/name}","releases_url":"https://api.github.com/repos/OlinMobileProto/Lab2/releases{/id}","created_at":"2015-09-13T15:12:26Z","updated_at":"2015-09-13T15:12:26Z","pushed_at":"2015-10-04T21:53:38Z","git_url":"git://github.com/OlinMobileProto/Lab2.git","ssh_url":"git@github.com:OlinMobileProto/Lab2.git","clone_url":"https://github.com/OlinMobileProto/Lab2.git","svn_url":"https://github.com/OlinMobileProto/Lab2","homepage":null,"size":878,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":16,"forks":17,"open_issues":16,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/6"},"html":{"href":"https://github.com/OlinMobileProto/Lab2/pull/6"},"issue":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/issues/6"},"comments":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/OlinMobileProto/Lab2/statuses/0b9044b90d80d89955caddffe19002b16d1fa1ae"}}}}