{"action":"created","comment":{"url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/comments/26439621","id":26439621,"diff_hunk":"@@ -0,0 +1,379 @@\n+/***************************************************************************************\n+ *                                                                                      *\n+ * Copyright (c) 2015 Frank Oltmanns <frank.oltmanns@gmail.com>                         *\n+ *                                                                                      *\n+ * This program is free software; you can redistribute it and/or modify it under        *\n+ * the terms of the GNU General Public License as published by the Free Software        *\n+ * Foundation; either version 3 of the License, or (at your option) any later           *\n+ * version.                                                                             *\n+ *                                                                                      *\n+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *\n+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *\n+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *\n+ *                                                                                      *\n+ * You should have received a copy of the GNU General Public License along with         *\n+ * this program.  If not, see <http://www.gnu.org/licenses/>.                           *\n+ ****************************************************************************************/\n+\n+package com.ichi2.anki.tests;\n+\n+import android.content.ContentResolver;\n+import android.content.ContentValues;\n+import android.database.Cursor;\n+import android.net.Uri;\n+import android.test.AndroidTestCase;\n+import android.util.Log;\n+import com.ichi2.anki.AnkiDroidApp;\n+import com.ichi2.anki.provider.FlashCardsContract;\n+import com.ichi2.libanki.Collection;\n+\n+import java.util.List;\n+\n+/**\n+ * Test cases for {@link com.ichi2.anki.provider.CardContentProvider}.\n+ * <p/>\n+ * These tests should cover all supported operations for each URI.\n+ */\n+public class ContentProviderTest extends AndroidTestCase {\n+\n+    private static final String TEST_FIELD_VALUE = \"test field value\";\n+    private static final String TEST_TAG = \"aldskfhewjklhfczmxkjshf\";\n+    private static final String TEST_DECK = \"glekrjterglknsdfflkgj\";\n+    private int mCreatedNotes;\n+\n+    /**\n+     * Initially create one note for each model.\n+     */\n+    @Override\n+    protected void setUp() throws Exception {\n+        super.setUp();\n+        Log.i(AnkiDroidApp.TAG, \"setUp()\");\n+        final ContentResolver cr = getContext().getContentResolver();\n+        // Query all available models\n+        final Cursor cursor = cr.query(FlashCardsContract.Model.CONTENT_URI, null, null, null, null);\n+        assertNotNull(cursor);\n+        int runs = 0;\n+        int idColumnIndex = cursor.getColumnIndexOrThrow(FlashCardsContract.Model._ID);\n+        ContentValues values = new ContentValues();\n+        try {\n+            while (cursor.moveToNext()) {\n+                long modelId = cursor.getLong(idColumnIndex);\n+                values.put(FlashCardsContract.Note.MID, modelId);","path":"AnkiDroid/src/androidTest/java/com.ichi2.anki.tests/ContentProviderTest.java","position":61,"original_position":61,"commit_id":"bc128168d1ba6c465f998bacb80ba8db94cc8f18","original_commit_id":"bc128168d1ba6c465f998bacb80ba8db94cc8f18","user":{"login":"flerda","id":42196,"avatar_url":"https://avatars.githubusercontent.com/u/42196?v=3","gravatar_id":"","url":"https://api.github.com/users/flerda","html_url":"https://github.com/flerda","followers_url":"https://api.github.com/users/flerda/followers","following_url":"https://api.github.com/users/flerda/following{/other_user}","gists_url":"https://api.github.com/users/flerda/gists{/gist_id}","starred_url":"https://api.github.com/users/flerda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flerda/subscriptions","organizations_url":"https://api.github.com/users/flerda/orgs","repos_url":"https://api.github.com/users/flerda/repos","events_url":"https://api.github.com/users/flerda/events{/privacy}","received_events_url":"https://api.github.com/users/flerda/received_events","type":"User","site_admin":false},"body":"You need a ```values.clear()``` either at the debugging or end of the while loop's body.","created_at":"2015-03-14T17:18:02Z","updated_at":"2015-03-14T17:18:02Z","html_url":"https://github.com/ankidroid/Anki-Android/pull/725#discussion_r26439621","pull_request_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/725","_links":{"self":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/comments/26439621"},"html":{"href":"https://github.com/ankidroid/Anki-Android/pull/725#discussion_r26439621"},"pull_request":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/725"}}},"pull_request":{"url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/725","id":28531848,"html_url":"https://github.com/ankidroid/Anki-Android/pull/725","diff_url":"https://github.com/ankidroid/Anki-Android/pull/725.diff","patch_url":"https://github.com/ankidroid/Anki-Android/pull/725.patch","issue_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/725","number":725,"state":"open","locked":false,"title":"Contentprovider","user":{"login":"federvieh","id":5159306,"avatar_url":"https://avatars.githubusercontent.com/u/5159306?v=3","gravatar_id":"","url":"https://api.github.com/users/federvieh","html_url":"https://github.com/federvieh","followers_url":"https://api.github.com/users/federvieh/followers","following_url":"https://api.github.com/users/federvieh/following{/other_user}","gists_url":"https://api.github.com/users/federvieh/gists{/gist_id}","starred_url":"https://api.github.com/users/federvieh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/federvieh/subscriptions","organizations_url":"https://api.github.com/users/federvieh/orgs","repos_url":"https://api.github.com/users/federvieh/repos","events_url":"https://api.github.com/users/federvieh/events{/privacy}","received_events_url":"https://api.github.com/users/federvieh/received_events","type":"User","site_admin":false},"body":"This is a pull request for a content provider as discussed here:\r\nhttps://groups.google.com/forum/#!msg/anki-android/SitMpj7J6fw/swqcuJKcld8J\r\n\r\nIt currently supports getting the unprocessed data from the Anki DB using the following URI:\r\ncontent://com.ichi2.anki.flashcard/flashcards\r\n\r\nand fields and cards/decks using\r\n\r\ncontent://com.ichi2.anki.flashcard/flashcards/<note_id>/data\r\n\r\nThe contract is described in FlashCardsContract.java. I release this file into the public domain so that it can be used by any third party software without any attribution or royalty. I.e. this file (and this file only) is not licensed under GPL.\r\n\r\nThe content provider currently only supports notes/cards, but not models.\r\n\r\nIt also only supports the query() function, no insert() or update() yet.\r\n\r\nFor update() on fields I intended to use the same mechanism as NoteEditor, but there is some kind of check that prevents updates from any other Thread than the main thread.\r\n\r\nThe first intention of this PR is to discuss if the proposed data structure is acceptable/understandable for the AnkiDroid developers and to discuss implementation details such as the above (concerning the main thread problem). Of course, I hope that it will later merged into the main branch.","created_at":"2015-02-03T07:27:12Z","updated_at":"2015-03-14T17:18:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fad7a1a5f0dc736c1cdda0fc3f970843bd3e9497","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/725/commits","review_comments_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/725/comments","review_comment_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/725/comments","statuses_url":"https://api.github.com/repos/ankidroid/Anki-Android/statuses/bc128168d1ba6c465f998bacb80ba8db94cc8f18","head":{"label":"federvieh:contentprovider","ref":"contentprovider","sha":"bc128168d1ba6c465f998bacb80ba8db94cc8f18","user":{"login":"federvieh","id":5159306,"avatar_url":"https://avatars.githubusercontent.com/u/5159306?v=3","gravatar_id":"","url":"https://api.github.com/users/federvieh","html_url":"https://github.com/federvieh","followers_url":"https://api.github.com/users/federvieh/followers","following_url":"https://api.github.com/users/federvieh/following{/other_user}","gists_url":"https://api.github.com/users/federvieh/gists{/gist_id}","starred_url":"https://api.github.com/users/federvieh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/federvieh/subscriptions","organizations_url":"https://api.github.com/users/federvieh/orgs","repos_url":"https://api.github.com/users/federvieh/repos","events_url":"https://api.github.com/users/federvieh/events{/privacy}","received_events_url":"https://api.github.com/users/federvieh/received_events","type":"User","site_admin":false},"repo":{"id":28517534,"name":"Anki-Android","full_name":"federvieh/Anki-Android","owner":{"login":"federvieh","id":5159306,"avatar_url":"https://avatars.githubusercontent.com/u/5159306?v=3","gravatar_id":"","url":"https://api.github.com/users/federvieh","html_url":"https://github.com/federvieh","followers_url":"https://api.github.com/users/federvieh/followers","following_url":"https://api.github.com/users/federvieh/following{/other_user}","gists_url":"https://api.github.com/users/federvieh/gists{/gist_id}","starred_url":"https://api.github.com/users/federvieh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/federvieh/subscriptions","organizations_url":"https://api.github.com/users/federvieh/orgs","repos_url":"https://api.github.com/users/federvieh/repos","events_url":"https://api.github.com/users/federvieh/events{/privacy}","received_events_url":"https://api.github.com/users/federvieh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/federvieh/Anki-Android","description":"Anki on Android","fork":true,"url":"https://api.github.com/repos/federvieh/Anki-Android","forks_url":"https://api.github.com/repos/federvieh/Anki-Android/forks","keys_url":"https://api.github.com/repos/federvieh/Anki-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/federvieh/Anki-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/federvieh/Anki-Android/teams","hooks_url":"https://api.github.com/repos/federvieh/Anki-Android/hooks","issue_events_url":"https://api.github.com/repos/federvieh/Anki-Android/issues/events{/number}","events_url":"https://api.github.com/repos/federvieh/Anki-Android/events","assignees_url":"https://api.github.com/repos/federvieh/Anki-Android/assignees{/user}","branches_url":"https://api.github.com/repos/federvieh/Anki-Android/branches{/branch}","tags_url":"https://api.github.com/repos/federvieh/Anki-Android/tags","blobs_url":"https://api.github.com/repos/federvieh/Anki-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/federvieh/Anki-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/federvieh/Anki-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/federvieh/Anki-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/federvieh/Anki-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/federvieh/Anki-Android/languages","stargazers_url":"https://api.github.com/repos/federvieh/Anki-Android/stargazers","contributors_url":"https://api.github.com/repos/federvieh/Anki-Android/contributors","subscribers_url":"https://api.github.com/repos/federvieh/Anki-Android/subscribers","subscription_url":"https://api.github.com/repos/federvieh/Anki-Android/subscription","commits_url":"https://api.github.com/repos/federvieh/Anki-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/federvieh/Anki-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/federvieh/Anki-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/federvieh/Anki-Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/federvieh/Anki-Android/contents/{+path}","compare_url":"https://api.github.com/repos/federvieh/Anki-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/federvieh/Anki-Android/merges","archive_url":"https://api.github.com/repos/federvieh/Anki-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/federvieh/Anki-Android/downloads","issues_url":"https://api.github.com/repos/federvieh/Anki-Android/issues{/number}","pulls_url":"https://api.github.com/repos/federvieh/Anki-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/federvieh/Anki-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/federvieh/Anki-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/federvieh/Anki-Android/labels{/name}","releases_url":"https://api.github.com/repos/federvieh/Anki-Android/releases{/id}","created_at":"2014-12-26T18:03:13Z","updated_at":"2015-03-04T20:24:25Z","pushed_at":"2015-03-13T07:01:28Z","git_url":"git://github.com/federvieh/Anki-Android.git","ssh_url":"git@github.com:federvieh/Anki-Android.git","clone_url":"https://github.com/federvieh/Anki-Android.git","svn_url":"https://github.com/federvieh/Anki-Android","homepage":"https://code.google.com/p/ankidroid/","size":64851,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"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":"ankidroid:develop","ref":"develop","sha":"e953662de9c57d919f0c3d1569d76cd9143f48c7","user":{"login":"ankidroid","id":3320903,"avatar_url":"https://avatars.githubusercontent.com/u/3320903?v=3","gravatar_id":"","url":"https://api.github.com/users/ankidroid","html_url":"https://github.com/ankidroid","followers_url":"https://api.github.com/users/ankidroid/followers","following_url":"https://api.github.com/users/ankidroid/following{/other_user}","gists_url":"https://api.github.com/users/ankidroid/gists{/gist_id}","starred_url":"https://api.github.com/users/ankidroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankidroid/subscriptions","organizations_url":"https://api.github.com/users/ankidroid/orgs","repos_url":"https://api.github.com/users/ankidroid/repos","events_url":"https://api.github.com/users/ankidroid/events{/privacy}","received_events_url":"https://api.github.com/users/ankidroid/received_events","type":"Organization","site_admin":false},"repo":{"id":7716883,"name":"Anki-Android","full_name":"ankidroid/Anki-Android","owner":{"login":"ankidroid","id":3320903,"avatar_url":"https://avatars.githubusercontent.com/u/3320903?v=3","gravatar_id":"","url":"https://api.github.com/users/ankidroid","html_url":"https://github.com/ankidroid","followers_url":"https://api.github.com/users/ankidroid/followers","following_url":"https://api.github.com/users/ankidroid/following{/other_user}","gists_url":"https://api.github.com/users/ankidroid/gists{/gist_id}","starred_url":"https://api.github.com/users/ankidroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankidroid/subscriptions","organizations_url":"https://api.github.com/users/ankidroid/orgs","repos_url":"https://api.github.com/users/ankidroid/repos","events_url":"https://api.github.com/users/ankidroid/events{/privacy}","received_events_url":"https://api.github.com/users/ankidroid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ankidroid/Anki-Android","description":"Anki on Android","fork":true,"url":"https://api.github.com/repos/ankidroid/Anki-Android","forks_url":"https://api.github.com/repos/ankidroid/Anki-Android/forks","keys_url":"https://api.github.com/repos/ankidroid/Anki-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ankidroid/Anki-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ankidroid/Anki-Android/teams","hooks_url":"https://api.github.com/repos/ankidroid/Anki-Android/hooks","issue_events_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/events{/number}","events_url":"https://api.github.com/repos/ankidroid/Anki-Android/events","assignees_url":"https://api.github.com/repos/ankidroid/Anki-Android/assignees{/user}","branches_url":"https://api.github.com/repos/ankidroid/Anki-Android/branches{/branch}","tags_url":"https://api.github.com/repos/ankidroid/Anki-Android/tags","blobs_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ankidroid/Anki-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/ankidroid/Anki-Android/languages","stargazers_url":"https://api.github.com/repos/ankidroid/Anki-Android/stargazers","contributors_url":"https://api.github.com/repos/ankidroid/Anki-Android/contributors","subscribers_url":"https://api.github.com/repos/ankidroid/Anki-Android/subscribers","subscription_url":"https://api.github.com/repos/ankidroid/Anki-Android/subscription","commits_url":"https://api.github.com/repos/ankidroid/Anki-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/ankidroid/Anki-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/ankidroid/Anki-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/ankidroid/Anki-Android/contents/{+path}","compare_url":"https://api.github.com/repos/ankidroid/Anki-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ankidroid/Anki-Android/merges","archive_url":"https://api.github.com/repos/ankidroid/Anki-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ankidroid/Anki-Android/downloads","issues_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues{/number}","pulls_url":"https://api.github.com/repos/ankidroid/Anki-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/ankidroid/Anki-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/ankidroid/Anki-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ankidroid/Anki-Android/labels{/name}","releases_url":"https://api.github.com/repos/ankidroid/Anki-Android/releases{/id}","created_at":"2013-01-20T13:55:53Z","updated_at":"2015-03-13T16:05:59Z","pushed_at":"2015-03-14T06:05:00Z","git_url":"git://github.com/ankidroid/Anki-Android.git","ssh_url":"git@github.com:ankidroid/Anki-Android.git","clone_url":"https://github.com/ankidroid/Anki-Android.git","svn_url":"https://github.com/ankidroid/Anki-Android","homepage":"https://code.google.com/p/ankidroid/","size":125202,"stargazers_count":237,"watchers_count":237,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":297,"mirror_url":null,"open_issues_count":12,"forks":297,"open_issues":12,"watchers":237,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/725"},"html":{"href":"https://github.com/ankidroid/Anki-Android/pull/725"},"issue":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/issues/725"},"comments":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/issues/725/comments"},"review_comments":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/725/comments"},"review_comment":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/pulls/725/commits"},"statuses":{"href":"https://api.github.com/repos/ankidroid/Anki-Android/statuses/bc128168d1ba6c465f998bacb80ba8db94cc8f18"}}}}