{"action":"created","comment":{"url":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/comments/78280899","id":78280899,"diff_hunk":"@@ -56,84 +56,78 @@\n     private int toDay;\n     private int toMonth;\n     private int toYear;\n-    private DatabaseHandler dB;\n-    private MainActivity activity;\n-\n-    public ExportPresenter(MainActivity exportActivity, DatabaseHandler dbHandler) {\n-        this.activity = exportActivity;\n-        dB = dbHandler;\n-    }\n \n-    public void onExportClicked(final Boolean all) {\n-        final List<GlucoseReading> readings;\n+    private Activity mActivity;\n+    private ExportView mExportView;\n+    private DatabaseHandler dB;\n \n-        if (all) {\n-            readings = dB.getGlucoseReadings();\n+    public ExportPresenter(Activity activity) {\n+        mActivity = activity;\n+        if (activity instanceof ExportView) {\n+            mExportView = (ExportView) activity;\n         } else {\n-            Calendar fromDate = Calendar.getInstance();\n-            fromDate.set(Calendar.YEAR, fromYear);\n-            fromDate.set(Calendar.MONTH, fromMonth);\n-            fromDate.set(Calendar.DAY_OF_MONTH, fromDay);\n-\n-            Calendar toDate = Calendar.getInstance();\n-            toDate.set(Calendar.YEAR, toYear);\n-            toDate.set(Calendar.MONTH, toMonth);\n-            toDate.set(Calendar.DAY_OF_MONTH, toDay);\n-            readings = dB.getGlucoseReadings(fromDate.getTime(), toDate.getTime());\n+            throw new RuntimeException(\"ExportPresenter Activity must implement ExportView interface\");\n         }\n+        dB = GlucosioApplication.getInstance().getDBHandler();","path":"app/src/main/java/org/glucosio/android/presenter/ExportPresenter.java","position":53,"original_position":53,"commit_id":"545af91a460f74c37b7f0786718535df36cfe6d4","original_commit_id":"545af91a460f74c37b7f0786718535df36cfe6d4","user":{"login":"JoaquimLey","id":6922748,"avatar_url":"https://avatars.githubusercontent.com/u/6922748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoaquimLey","html_url":"https://github.com/JoaquimLey","followers_url":"https://api.github.com/users/JoaquimLey/followers","following_url":"https://api.github.com/users/JoaquimLey/following{/other_user}","gists_url":"https://api.github.com/users/JoaquimLey/gists{/gist_id}","starred_url":"https://api.github.com/users/JoaquimLey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoaquimLey/subscriptions","organizations_url":"https://api.github.com/users/JoaquimLey/orgs","repos_url":"https://api.github.com/users/JoaquimLey/repos","events_url":"https://api.github.com/users/JoaquimLey/events{/privacy}","received_events_url":"https://api.github.com/users/JoaquimLey/received_events","type":"User","site_admin":false},"body":"This way you don't have to pass the databaseHandler as a parameter since you are always using the one residing in the application context anyway. Using a singleton you ensure you are accessing the same reference.","created_at":"2016-09-10T17:38:28Z","updated_at":"2016-09-10T17:38:28Z","html_url":"https://github.com/Glucosio/glucosio-android/pull/295#discussion_r78280899","pull_request_url":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/295","_links":{"self":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/comments/78280899"},"html":{"href":"https://github.com/Glucosio/glucosio-android/pull/295#discussion_r78280899"},"pull_request":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/295"}}},"pull_request":{"url":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/295","id":84755144,"html_url":"https://github.com/Glucosio/glucosio-android/pull/295","diff_url":"https://github.com/Glucosio/glucosio-android/pull/295.diff","patch_url":"https://github.com/Glucosio/glucosio-android/pull/295.patch","issue_url":"https://api.github.com/repos/Glucosio/glucosio-android/issues/295","number":295,"state":"open","locked":false,"title":"Fix #285","user":{"login":"JoaquimLey","id":6922748,"avatar_url":"https://avatars.githubusercontent.com/u/6922748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoaquimLey","html_url":"https://github.com/JoaquimLey","followers_url":"https://api.github.com/users/JoaquimLey/followers","following_url":"https://api.github.com/users/JoaquimLey/following{/other_user}","gists_url":"https://api.github.com/users/JoaquimLey/gists{/gist_id}","starred_url":"https://api.github.com/users/JoaquimLey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoaquimLey/subscriptions","organizations_url":"https://api.github.com/users/JoaquimLey/orgs","repos_url":"https://api.github.com/users/JoaquimLey/repos","events_url":"https://api.github.com/users/JoaquimLey/events{/privacy}","received_events_url":"https://api.github.com/users/JoaquimLey/received_events","type":"User","site_admin":false},"body":"- Fix Reading note exporting\r\n- Abstract to a pseudo MVP architecture (ExportPresenter/ExportPresenterView)\r\n- Improvements on export algorithm\r\n- Simple unit tests\r\n- Update gradle version","created_at":"2016-09-10T13:13:06Z","updated_at":"2016-09-10T17:38:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"16126cc09ae5d3644b1a40e63fd858d1148771dd","assignee":{"login":"emartynov","id":295424,"avatar_url":"https://avatars.githubusercontent.com/u/295424?v=3","gravatar_id":"","url":"https://api.github.com/users/emartynov","html_url":"https://github.com/emartynov","followers_url":"https://api.github.com/users/emartynov/followers","following_url":"https://api.github.com/users/emartynov/following{/other_user}","gists_url":"https://api.github.com/users/emartynov/gists{/gist_id}","starred_url":"https://api.github.com/users/emartynov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emartynov/subscriptions","organizations_url":"https://api.github.com/users/emartynov/orgs","repos_url":"https://api.github.com/users/emartynov/repos","events_url":"https://api.github.com/users/emartynov/events{/privacy}","received_events_url":"https://api.github.com/users/emartynov/received_events","type":"User","site_admin":false},"assignees":[{"login":"emartynov","id":295424,"avatar_url":"https://avatars.githubusercontent.com/u/295424?v=3","gravatar_id":"","url":"https://api.github.com/users/emartynov","html_url":"https://github.com/emartynov","followers_url":"https://api.github.com/users/emartynov/followers","following_url":"https://api.github.com/users/emartynov/following{/other_user}","gists_url":"https://api.github.com/users/emartynov/gists{/gist_id}","starred_url":"https://api.github.com/users/emartynov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emartynov/subscriptions","organizations_url":"https://api.github.com/users/emartynov/orgs","repos_url":"https://api.github.com/users/emartynov/repos","events_url":"https://api.github.com/users/emartynov/events{/privacy}","received_events_url":"https://api.github.com/users/emartynov/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/295/commits","review_comments_url":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/295/comments","review_comment_url":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Glucosio/glucosio-android/issues/295/comments","statuses_url":"https://api.github.com/repos/Glucosio/glucosio-android/statuses/545af91a460f74c37b7f0786718535df36cfe6d4","head":{"label":"JoaquimLey:develop","ref":"develop","sha":"545af91a460f74c37b7f0786718535df36cfe6d4","user":{"login":"JoaquimLey","id":6922748,"avatar_url":"https://avatars.githubusercontent.com/u/6922748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoaquimLey","html_url":"https://github.com/JoaquimLey","followers_url":"https://api.github.com/users/JoaquimLey/followers","following_url":"https://api.github.com/users/JoaquimLey/following{/other_user}","gists_url":"https://api.github.com/users/JoaquimLey/gists{/gist_id}","starred_url":"https://api.github.com/users/JoaquimLey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoaquimLey/subscriptions","organizations_url":"https://api.github.com/users/JoaquimLey/orgs","repos_url":"https://api.github.com/users/JoaquimLey/repos","events_url":"https://api.github.com/users/JoaquimLey/events{/privacy}","received_events_url":"https://api.github.com/users/JoaquimLey/received_events","type":"User","site_admin":false},"repo":{"id":67639786,"name":"glucosio-android","full_name":"JoaquimLey/glucosio-android","owner":{"login":"JoaquimLey","id":6922748,"avatar_url":"https://avatars.githubusercontent.com/u/6922748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoaquimLey","html_url":"https://github.com/JoaquimLey","followers_url":"https://api.github.com/users/JoaquimLey/followers","following_url":"https://api.github.com/users/JoaquimLey/following{/other_user}","gists_url":"https://api.github.com/users/JoaquimLey/gists{/gist_id}","starred_url":"https://api.github.com/users/JoaquimLey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoaquimLey/subscriptions","organizations_url":"https://api.github.com/users/JoaquimLey/orgs","repos_url":"https://api.github.com/users/JoaquimLey/repos","events_url":"https://api.github.com/users/JoaquimLey/events{/privacy}","received_events_url":"https://api.github.com/users/JoaquimLey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JoaquimLey/glucosio-android","description":"Glucosio Android App","fork":true,"url":"https://api.github.com/repos/JoaquimLey/glucosio-android","forks_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/forks","keys_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/teams","hooks_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/hooks","issue_events_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/issues/events{/number}","events_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/events","assignees_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/assignees{/user}","branches_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/branches{/branch}","tags_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/tags","blobs_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/statuses/{sha}","languages_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/languages","stargazers_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/stargazers","contributors_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/contributors","subscribers_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/subscribers","subscription_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/subscription","commits_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/contents/{+path}","compare_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/merges","archive_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/downloads","issues_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/issues{/number}","pulls_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/pulls{/number}","milestones_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/milestones{/number}","notifications_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/labels{/name}","releases_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/releases{/id}","deployments_url":"https://api.github.com/repos/JoaquimLey/glucosio-android/deployments","created_at":"2016-09-07T20:09:32Z","updated_at":"2016-09-07T20:09:36Z","pushed_at":"2016-09-10T13:58:44Z","git_url":"git://github.com/JoaquimLey/glucosio-android.git","ssh_url":"git@github.com:JoaquimLey/glucosio-android.git","clone_url":"https://github.com/JoaquimLey/glucosio-android.git","svn_url":"https://github.com/JoaquimLey/glucosio-android","homepage":"","size":21018,"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":"develop"}},"base":{"label":"Glucosio:develop","ref":"develop","sha":"5114f8a580f2154c91645db6636d8cc01324c46b","user":{"login":"Glucosio","id":12890580,"avatar_url":"https://avatars.githubusercontent.com/u/12890580?v=3","gravatar_id":"","url":"https://api.github.com/users/Glucosio","html_url":"https://github.com/Glucosio","followers_url":"https://api.github.com/users/Glucosio/followers","following_url":"https://api.github.com/users/Glucosio/following{/other_user}","gists_url":"https://api.github.com/users/Glucosio/gists{/gist_id}","starred_url":"https://api.github.com/users/Glucosio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Glucosio/subscriptions","organizations_url":"https://api.github.com/users/Glucosio/orgs","repos_url":"https://api.github.com/users/Glucosio/repos","events_url":"https://api.github.com/users/Glucosio/events{/privacy}","received_events_url":"https://api.github.com/users/Glucosio/received_events","type":"Organization","site_admin":false},"repo":{"id":37447498,"name":"glucosio-android","full_name":"Glucosio/glucosio-android","owner":{"login":"Glucosio","id":12890580,"avatar_url":"https://avatars.githubusercontent.com/u/12890580?v=3","gravatar_id":"","url":"https://api.github.com/users/Glucosio","html_url":"https://github.com/Glucosio","followers_url":"https://api.github.com/users/Glucosio/followers","following_url":"https://api.github.com/users/Glucosio/following{/other_user}","gists_url":"https://api.github.com/users/Glucosio/gists{/gist_id}","starred_url":"https://api.github.com/users/Glucosio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Glucosio/subscriptions","organizations_url":"https://api.github.com/users/Glucosio/orgs","repos_url":"https://api.github.com/users/Glucosio/repos","events_url":"https://api.github.com/users/Glucosio/events{/privacy}","received_events_url":"https://api.github.com/users/Glucosio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Glucosio/glucosio-android","description":"Glucosio Android App","fork":false,"url":"https://api.github.com/repos/Glucosio/glucosio-android","forks_url":"https://api.github.com/repos/Glucosio/glucosio-android/forks","keys_url":"https://api.github.com/repos/Glucosio/glucosio-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Glucosio/glucosio-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Glucosio/glucosio-android/teams","hooks_url":"https://api.github.com/repos/Glucosio/glucosio-android/hooks","issue_events_url":"https://api.github.com/repos/Glucosio/glucosio-android/issues/events{/number}","events_url":"https://api.github.com/repos/Glucosio/glucosio-android/events","assignees_url":"https://api.github.com/repos/Glucosio/glucosio-android/assignees{/user}","branches_url":"https://api.github.com/repos/Glucosio/glucosio-android/branches{/branch}","tags_url":"https://api.github.com/repos/Glucosio/glucosio-android/tags","blobs_url":"https://api.github.com/repos/Glucosio/glucosio-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Glucosio/glucosio-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Glucosio/glucosio-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/Glucosio/glucosio-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Glucosio/glucosio-android/statuses/{sha}","languages_url":"https://api.github.com/repos/Glucosio/glucosio-android/languages","stargazers_url":"https://api.github.com/repos/Glucosio/glucosio-android/stargazers","contributors_url":"https://api.github.com/repos/Glucosio/glucosio-android/contributors","subscribers_url":"https://api.github.com/repos/Glucosio/glucosio-android/subscribers","subscription_url":"https://api.github.com/repos/Glucosio/glucosio-android/subscription","commits_url":"https://api.github.com/repos/Glucosio/glucosio-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/Glucosio/glucosio-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/Glucosio/glucosio-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/Glucosio/glucosio-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/Glucosio/glucosio-android/contents/{+path}","compare_url":"https://api.github.com/repos/Glucosio/glucosio-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Glucosio/glucosio-android/merges","archive_url":"https://api.github.com/repos/Glucosio/glucosio-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Glucosio/glucosio-android/downloads","issues_url":"https://api.github.com/repos/Glucosio/glucosio-android/issues{/number}","pulls_url":"https://api.github.com/repos/Glucosio/glucosio-android/pulls{/number}","milestones_url":"https://api.github.com/repos/Glucosio/glucosio-android/milestones{/number}","notifications_url":"https://api.github.com/repos/Glucosio/glucosio-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Glucosio/glucosio-android/labels{/name}","releases_url":"https://api.github.com/repos/Glucosio/glucosio-android/releases{/id}","deployments_url":"https://api.github.com/repos/Glucosio/glucosio-android/deployments","created_at":"2015-06-15T06:28:27Z","updated_at":"2016-09-07T20:09:31Z","pushed_at":"2016-09-10T16:28:45Z","git_url":"git://github.com/Glucosio/glucosio-android.git","ssh_url":"git@github.com:Glucosio/glucosio-android.git","clone_url":"https://github.com/Glucosio/glucosio-android.git","svn_url":"https://github.com/Glucosio/glucosio-android","homepage":"","size":21491,"stargazers_count":171,"watchers_count":171,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":79,"mirror_url":null,"open_issues_count":41,"forks":79,"open_issues":41,"watchers":171,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/295"},"html":{"href":"https://github.com/Glucosio/glucosio-android/pull/295"},"issue":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/issues/295"},"comments":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/issues/295/comments"},"review_comments":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/295/comments"},"review_comment":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/pulls/295/commits"},"statuses":{"href":"https://api.github.com/repos/Glucosio/glucosio-android/statuses/545af91a460f74c37b7f0786718535df36cfe6d4"}}}}
{"actor":{"display_login":"JoaquimLey"}}