{"action":"created","comment":{"url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/comments/88779925","pull_request_review_id":9345874,"id":88779925,"diff_hunk":"@@ -0,0 +1,136 @@\n+package rss.feed.reader.managers;\n+\n+import android.content.Context;\n+import android.content.SharedPreferences;\n+import android.preference.PreferenceManager;\n+import android.support.annotation.MainThread;\n+import android.support.annotation.Nullable;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import rss.feed.reader.api.model.News;\n+import rss.feed.reader.api.model.RssChannel;\n+import rss.feed.reader.api.model.RssFeed;\n+import rss.feed.reader.api.model.RssImage;\n+import rss.feed.reader.api.model.RssItem;\n+import rss.feed.reader.api.retrofit.RssFeedProvider;\n+import rss.feed.reader.api.retrofit.Callback;\n+import rss.feed.reader.api.retrofit.Error;\n+import rss.feed.reader.utils.TimeUtils;\n+\n+/**\n+ * Created by Andriy Ksenych on 01.11.2016.\n+ * Manager for managing News, making network requests for news\n+ */\n+\n+public class NewsManager {\n+    private static final String PREF_KEY_STARTUP_NEWS = \"startup_news_selector\";\n+    private static final String PREF_ALL_NEWS = \"All news\";\n+    private static final String PREF_FIRST_RSS = \"First rss\";\n+\n+    private static final String EMPTY_VALUE = \"\";\n+\n+    private RssFeedProvider mRssFeedProvider;\n+    private ChannelManager mChannelManager;\n+    private Context mContext;\n+\n+    public NewsManager(RssFeedProvider rssFeedProvider, ChannelManager channelManager, Context context) {\n+        mRssFeedProvider = rssFeedProvider;\n+        mChannelManager = channelManager;\n+        mContext = context;\n+    }\n+\n+    /**\n+     * Get list of {@link News} from {@link RssFeed}\n+     *\n+     * @param rssFeed - model of RSS feed\n+     * @return list of news\n+     */\n+    @MainThread\n+    private static List<News> getNewsListFromRssFeed(@Nullable RssFeed rssFeed) {\n+\n+        List<News> newsList = new ArrayList<>();\n+\n+        if (rssFeed == null || rssFeed.getChannel() == null || rssFeed.getChannel().getItemsList() == null) {\n+            return newsList;\n+        }\n+\n+        RssChannel rssChannel = rssFeed.getChannel();\n+        RssImage rssImage = rssChannel.getImage();\n+\n+        String siteTitle = rssImage.getTitle();\n+        String siteLogo = rssImage.getUrl();\n+\n+        for (RssItem item : rssChannel.getItemsList()) {\n+            News news = new News(\n+                    item.getLink() != null ? item.getLink() : EMPTY_VALUE,","path":"app/src/main/java/rss/feed/reader/managers/NewsManager.java","position":67,"original_position":67,"commit_id":"c79f35d603e8a432ff9d98d6a59b88761fdf82e5","original_commit_id":"c79f35d603e8a432ff9d98d6a59b88761fdf82e5","user":{"login":"qUser13","id":9804385,"avatar_url":"https://avatars.githubusercontent.com/u/9804385?v=3","gravatar_id":"","url":"https://api.github.com/users/qUser13","html_url":"https://github.com/qUser13","followers_url":"https://api.github.com/users/qUser13/followers","following_url":"https://api.github.com/users/qUser13/following{/other_user}","gists_url":"https://api.github.com/users/qUser13/gists{/gist_id}","starred_url":"https://api.github.com/users/qUser13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qUser13/subscriptions","organizations_url":"https://api.github.com/users/qUser13/orgs","repos_url":"https://api.github.com/users/qUser13/repos","events_url":"https://api.github.com/users/qUser13/events{/privacy}","received_events_url":"https://api.github.com/users/qUser13/received_events","type":"User","site_admin":false},"body":"You can create a 'safe' getters that give you a EMPTY_VALUE instead of null. How do you feel about it?","created_at":"2016-11-19T13:55:06Z","updated_at":"2016-11-19T13:55:25Z","html_url":"https://github.com/Vovchyk/android-rss-feed-reader/pull/46#discussion_r88779925","pull_request_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/comments/88779925"},"html":{"href":"https://github.com/Vovchyk/android-rss-feed-reader/pull/46#discussion_r88779925"},"pull_request":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/46","id":93741005,"html_url":"https://github.com/Vovchyk/android-rss-feed-reader/pull/46","diff_url":"https://github.com/Vovchyk/android-rss-feed-reader/pull/46.diff","patch_url":"https://github.com/Vovchyk/android-rss-feed-reader/pull/46.patch","issue_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues/46","number":46,"state":"open","locked":false,"title":"rfr-16 Add Channel Items page.","user":{"login":"Andruhin","id":16490167,"avatar_url":"https://avatars.githubusercontent.com/u/16490167?v=3","gravatar_id":"","url":"https://api.github.com/users/Andruhin","html_url":"https://github.com/Andruhin","followers_url":"https://api.github.com/users/Andruhin/followers","following_url":"https://api.github.com/users/Andruhin/following{/other_user}","gists_url":"https://api.github.com/users/Andruhin/gists{/gist_id}","starred_url":"https://api.github.com/users/Andruhin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andruhin/subscriptions","organizations_url":"https://api.github.com/users/Andruhin/orgs","repos_url":"https://api.github.com/users/Andruhin/repos","events_url":"https://api.github.com/users/Andruhin/events{/privacy}","received_events_url":"https://api.github.com/users/Andruhin/received_events","type":"User","site_admin":false},"body":"Added functionality for calling RSS feeds, transform them to News lists and showing them on MainActivity. Added WebActivity, but it'll be fully implemented in another task.","created_at":"2016-11-15T10:43:38Z","updated_at":"2016-11-19T14:02:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/46/commits","review_comments_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/46/comments","review_comment_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues/46/comments","statuses_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/statuses/c79f35d603e8a432ff9d98d6a59b88761fdf82e5","head":{"label":"Vovchyk:rfr-16","ref":"rfr-16","sha":"c79f35d603e8a432ff9d98d6a59b88761fdf82e5","user":{"login":"Vovchyk","id":3499344,"avatar_url":"https://avatars.githubusercontent.com/u/3499344?v=3","gravatar_id":"","url":"https://api.github.com/users/Vovchyk","html_url":"https://github.com/Vovchyk","followers_url":"https://api.github.com/users/Vovchyk/followers","following_url":"https://api.github.com/users/Vovchyk/following{/other_user}","gists_url":"https://api.github.com/users/Vovchyk/gists{/gist_id}","starred_url":"https://api.github.com/users/Vovchyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vovchyk/subscriptions","organizations_url":"https://api.github.com/users/Vovchyk/orgs","repos_url":"https://api.github.com/users/Vovchyk/repos","events_url":"https://api.github.com/users/Vovchyk/events{/privacy}","received_events_url":"https://api.github.com/users/Vovchyk/received_events","type":"User","site_admin":false},"repo":{"id":66552015,"name":"android-rss-feed-reader","full_name":"Vovchyk/android-rss-feed-reader","owner":{"login":"Vovchyk","id":3499344,"avatar_url":"https://avatars.githubusercontent.com/u/3499344?v=3","gravatar_id":"","url":"https://api.github.com/users/Vovchyk","html_url":"https://github.com/Vovchyk","followers_url":"https://api.github.com/users/Vovchyk/followers","following_url":"https://api.github.com/users/Vovchyk/following{/other_user}","gists_url":"https://api.github.com/users/Vovchyk/gists{/gist_id}","starred_url":"https://api.github.com/users/Vovchyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vovchyk/subscriptions","organizations_url":"https://api.github.com/users/Vovchyk/orgs","repos_url":"https://api.github.com/users/Vovchyk/repos","events_url":"https://api.github.com/users/Vovchyk/events{/privacy}","received_events_url":"https://api.github.com/users/Vovchyk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Vovchyk/android-rss-feed-reader","description":"Android app that allows to fetch and display rss news feeds","fork":false,"url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader","forks_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/forks","keys_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/teams","hooks_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/hooks","issue_events_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues/events{/number}","events_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/events","assignees_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/assignees{/user}","branches_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/branches{/branch}","tags_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/tags","blobs_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/statuses/{sha}","languages_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/languages","stargazers_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/stargazers","contributors_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/contributors","subscribers_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/subscribers","subscription_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/subscription","commits_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/contents/{+path}","compare_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/merges","archive_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/downloads","issues_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues{/number}","pulls_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls{/number}","milestones_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/milestones{/number}","notifications_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/labels{/name}","releases_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/releases{/id}","deployments_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/deployments","created_at":"2016-08-25T11:25:57Z","updated_at":"2016-10-26T09:03:04Z","pushed_at":"2016-11-18T15:46:09Z","git_url":"git://github.com/Vovchyk/android-rss-feed-reader.git","ssh_url":"git@github.com:Vovchyk/android-rss-feed-reader.git","clone_url":"https://github.com/Vovchyk/android-rss-feed-reader.git","svn_url":"https://github.com/Vovchyk/android-rss-feed-reader","homepage":null,"size":273,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":2,"default_branch":"master"}},"base":{"label":"Vovchyk:master","ref":"master","sha":"f1f7bb7873dc0bc201b50665a70c6daba8ea5017","user":{"login":"Vovchyk","id":3499344,"avatar_url":"https://avatars.githubusercontent.com/u/3499344?v=3","gravatar_id":"","url":"https://api.github.com/users/Vovchyk","html_url":"https://github.com/Vovchyk","followers_url":"https://api.github.com/users/Vovchyk/followers","following_url":"https://api.github.com/users/Vovchyk/following{/other_user}","gists_url":"https://api.github.com/users/Vovchyk/gists{/gist_id}","starred_url":"https://api.github.com/users/Vovchyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vovchyk/subscriptions","organizations_url":"https://api.github.com/users/Vovchyk/orgs","repos_url":"https://api.github.com/users/Vovchyk/repos","events_url":"https://api.github.com/users/Vovchyk/events{/privacy}","received_events_url":"https://api.github.com/users/Vovchyk/received_events","type":"User","site_admin":false},"repo":{"id":66552015,"name":"android-rss-feed-reader","full_name":"Vovchyk/android-rss-feed-reader","owner":{"login":"Vovchyk","id":3499344,"avatar_url":"https://avatars.githubusercontent.com/u/3499344?v=3","gravatar_id":"","url":"https://api.github.com/users/Vovchyk","html_url":"https://github.com/Vovchyk","followers_url":"https://api.github.com/users/Vovchyk/followers","following_url":"https://api.github.com/users/Vovchyk/following{/other_user}","gists_url":"https://api.github.com/users/Vovchyk/gists{/gist_id}","starred_url":"https://api.github.com/users/Vovchyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vovchyk/subscriptions","organizations_url":"https://api.github.com/users/Vovchyk/orgs","repos_url":"https://api.github.com/users/Vovchyk/repos","events_url":"https://api.github.com/users/Vovchyk/events{/privacy}","received_events_url":"https://api.github.com/users/Vovchyk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Vovchyk/android-rss-feed-reader","description":"Android app that allows to fetch and display rss news feeds","fork":false,"url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader","forks_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/forks","keys_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/teams","hooks_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/hooks","issue_events_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues/events{/number}","events_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/events","assignees_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/assignees{/user}","branches_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/branches{/branch}","tags_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/tags","blobs_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/statuses/{sha}","languages_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/languages","stargazers_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/stargazers","contributors_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/contributors","subscribers_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/subscribers","subscription_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/subscription","commits_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/contents/{+path}","compare_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/merges","archive_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/downloads","issues_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues{/number}","pulls_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls{/number}","milestones_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/milestones{/number}","notifications_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/labels{/name}","releases_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/releases{/id}","deployments_url":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/deployments","created_at":"2016-08-25T11:25:57Z","updated_at":"2016-10-26T09:03:04Z","pushed_at":"2016-11-18T15:46:09Z","git_url":"git://github.com/Vovchyk/android-rss-feed-reader.git","ssh_url":"git@github.com:Vovchyk/android-rss-feed-reader.git","clone_url":"https://github.com/Vovchyk/android-rss-feed-reader.git","svn_url":"https://github.com/Vovchyk/android-rss-feed-reader","homepage":null,"size":273,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/46"},"html":{"href":"https://github.com/Vovchyk/android-rss-feed-reader/pull/46"},"issue":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues/46"},"comments":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/Vovchyk/android-rss-feed-reader/statuses/c79f35d603e8a432ff9d98d6a59b88761fdf82e5"}}}}
{"actor":{"display_login":"qUser13"}}