{"action":"created","comment":{"url":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/comments/53938060","id":53938060,"diff_hunk":"@@ -0,0 +1,188 @@\n+package com.example.vitalik.myapplication;\n+\n+import android.content.ContentValues;\n+import android.content.Context;\n+import android.content.Intent;\n+import android.database.Cursor;\n+import android.support.v4.app.LoaderManager;\n+import android.support.v4.content.CursorLoader;\n+import android.support.v4.content.Loader;\n+import android.support.v4.widget.CursorAdapter;\n+import android.database.sqlite.SQLiteDatabase;\n+import android.os.Bundle;\n+import android.support.design.widget.FloatingActionButton;\n+import android.support.v7.app.AppCompatActivity;\n+import android.support.v7.widget.Toolbar;\n+import android.text.Editable;\n+import android.text.TextWatcher;\n+import android.util.Log;\n+import android.view.ContextMenu;\n+import android.view.View;\n+import android.view.Menu;\n+import android.view.MenuItem;\n+import android.widget.AdapterView;\n+import android.widget.EditText;\n+import android.widget.FilterQueryProvider;\n+import android.widget.ListView;\n+import android.widget.SimpleCursorAdapter;\n+import android.widget.TextView;\n+\n+import java.sql.SQLException;\n+\n+public class MainActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> {\n+    public static DatabaseHelper mDatabaseHelper;\n+    public static SQLiteDatabase mSqLiteDatabase;\n+    public static SimpleCursorAdapter mAdapter;\n+    public static ListView lvData;\n+\n+    @Override\n+    protected void onCreate(Bundle savedInstanceState) {\n+        super.onCreate(savedInstanceState);\n+        setContentView(R.layout.activity_main);\n+\n+        mDatabaseHelper = new DatabaseHelper(this, \"mydatabase.db\", null, 1);\n+        mSqLiteDatabase = mDatabaseHelper.getWritableDatabase();\n+\n+        String[] from = new String[]{DatabaseHelper.TITLE_COLUMN};\n+        int[] to = new int[]{R.id.lvText};\n+\n+        mAdapter = new SimpleCursorAdapter(this, R.layout.item, null, from, to, 0);\n+        lvData = (ListView) findViewById(R.id.listView);\n+        lvData.setAdapter(mAdapter);\n+        registerForContextMenu(lvData);\n+        getSupportLoaderManager().initLoader(0, null, this);\n+        lvData.setClickable(true);\n+        lvData.setOnItemClickListener(new AdapterView.OnItemClickListener() {\n+            public void onItemClick(AdapterView<?> parent, View view,\n+                                    int position, long id) {\n+                Intent intent = new Intent(MainActivity.this, ItemShow.class);\n+                Log.w(\"MyLog\", \"\" + mAdapter.getItemId(position));\n+                intent.putExtra(\"id\", \"\" + mAdapter.getItemId(position));\n+                startActivityForResult(intent, 100);\n+            }\n+        });\n+\n+\n+        EditText myFilter = (EditText) findViewById(R.id.editText);\n+        myFilter.addTextChangedListener(new TextWatcher() {\n+\n+            public void afterTextChanged(Editable s) {\n+            }\n+\n+            public void beforeTextChanged(CharSequence s, int start,\n+                                          int count, int after) {\n+            }\n+\n+            public void onTextChanged(CharSequence s, int start,\n+                                      int before, int count) {\n+                mAdapter.getFilter().filter(s.toString());\n+            }\n+        });\n+\n+        mAdapter.setFilterQueryProvider(new FilterQueryProvider() {\n+            @Override\n+            public Cursor runQuery(CharSequence constraint) {\n+                return mDatabaseHelper.searchByName(mSqLiteDatabase, constraint.toString());\n+            }\n+        });\n+\n+\n+        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);\n+        setSupportActionBar(toolbar);\n+\n+        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);\n+        fab.setOnClickListener(new View.OnClickListener() {\n+            @Override\n+            public void onClick(View view) {\n+                Intent intent = new Intent(MainActivity.this, ItemAdd.class);\n+                startActivityForResult(intent, 100);\n+            }\n+        });\n+    }\n+\n+    @Override\n+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {\n+        super.onActivityResult(requestCode, resultCode, data);\n+        if (resultCode == RESULT_OK && requestCode == 100) {\n+            Log.w(\"MyLog\", \"after activity\");\n+            updateCursor();\n+        }\n+    }\n+\n+    public void updateCursor() {\n+        getSupportLoaderManager().getLoader(0).forceLoad();\n+    }\n+\n+    public void onCreateContextMenu(ContextMenu menu, View v,\n+                                    ContextMenu.ContextMenuInfo menuInfo) {\n+        super.onCreateContextMenu(menu, v, menuInfo);\n+        menu.add(0, DatabaseHelper.DELETE_ID, 0, R.string.delete_record);\n+        menu.add(0, DatabaseHelper.EDIT_ID, 0, R.string.edit_record);\n+    }\n+\n+    public boolean onContextItemSelected(MenuItem item) {\n+        if (item.getItemId() == DatabaseHelper.EDIT_ID) {\n+            AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) item\n+                    .getMenuInfo();\n+            Intent intent = new Intent(MainActivity.this, ItemEdit.class);\n+            intent.putExtra(\"id\", \"\" + acmi.id);","path":"app/src/main/java/com/example/vitalik/myapplication/MainActivity.java","position":128,"original_position":128,"commit_id":"80b72f2cf676c35ad9f1af7cfa6cdde49103132e","original_commit_id":"80b72f2cf676c35ad9f1af7cfa6cdde49103132e","user":{"login":"eabatalov","id":623590,"avatar_url":"https://avatars.githubusercontent.com/u/623590?v=3","gravatar_id":"","url":"https://api.github.com/users/eabatalov","html_url":"https://github.com/eabatalov","followers_url":"https://api.github.com/users/eabatalov/followers","following_url":"https://api.github.com/users/eabatalov/following{/other_user}","gists_url":"https://api.github.com/users/eabatalov/gists{/gist_id}","starred_url":"https://api.github.com/users/eabatalov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eabatalov/subscriptions","organizations_url":"https://api.github.com/users/eabatalov/orgs","repos_url":"https://api.github.com/users/eabatalov/repos","events_url":"https://api.github.com/users/eabatalov/events{/privacy}","received_events_url":"https://api.github.com/users/eabatalov/received_events","type":"User","site_admin":false},"body":"use verbose toString() functions for conversion.","created_at":"2016-02-24T13:34:14Z","updated_at":"2016-02-24T13:34:14Z","html_url":"https://github.com/vitalik239/CatalogApp/pull/1#discussion_r53938060","pull_request_url":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/comments/53938060"},"html":{"href":"https://github.com/vitalik239/CatalogApp/pull/1#discussion_r53938060"},"pull_request":{"href":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/1","id":60486017,"html_url":"https://github.com/vitalik239/CatalogApp/pull/1","diff_url":"https://github.com/vitalik239/CatalogApp/pull/1.diff","patch_url":"https://github.com/vitalik239/CatalogApp/pull/1.patch","issue_url":"https://api.github.com/repos/vitalik239/CatalogApp/issues/1","number":1,"state":"open","locked":false,"title":"Code review","user":{"login":"eabatalov","id":623590,"avatar_url":"https://avatars.githubusercontent.com/u/623590?v=3","gravatar_id":"","url":"https://api.github.com/users/eabatalov","html_url":"https://github.com/eabatalov","followers_url":"https://api.github.com/users/eabatalov/followers","following_url":"https://api.github.com/users/eabatalov/following{/other_user}","gists_url":"https://api.github.com/users/eabatalov/gists{/gist_id}","starred_url":"https://api.github.com/users/eabatalov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eabatalov/subscriptions","organizations_url":"https://api.github.com/users/eabatalov/orgs","repos_url":"https://api.github.com/users/eabatalov/repos","events_url":"https://api.github.com/users/eabatalov/events{/privacy}","received_events_url":"https://api.github.com/users/eabatalov/received_events","type":"User","site_admin":false},"body":"Here we would discuss the review","created_at":"2016-02-24T10:21:44Z","updated_at":"2016-02-24T13:34:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34339000870d97898ef88d66ec58e4312cd25c6f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/1/commits","review_comments_url":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/1/comments","review_comment_url":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vitalik239/CatalogApp/issues/1/comments","statuses_url":"https://api.github.com/repos/vitalik239/CatalogApp/statuses/80b72f2cf676c35ad9f1af7cfa6cdde49103132e","head":{"label":"vitalik239:review","ref":"review","sha":"80b72f2cf676c35ad9f1af7cfa6cdde49103132e","user":{"login":"vitalik239","id":11505274,"avatar_url":"https://avatars.githubusercontent.com/u/11505274?v=3","gravatar_id":"","url":"https://api.github.com/users/vitalik239","html_url":"https://github.com/vitalik239","followers_url":"https://api.github.com/users/vitalik239/followers","following_url":"https://api.github.com/users/vitalik239/following{/other_user}","gists_url":"https://api.github.com/users/vitalik239/gists{/gist_id}","starred_url":"https://api.github.com/users/vitalik239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitalik239/subscriptions","organizations_url":"https://api.github.com/users/vitalik239/orgs","repos_url":"https://api.github.com/users/vitalik239/repos","events_url":"https://api.github.com/users/vitalik239/events{/privacy}","received_events_url":"https://api.github.com/users/vitalik239/received_events","type":"User","site_admin":false},"repo":{"id":48068526,"name":"CatalogApp","full_name":"vitalik239/CatalogApp","owner":{"login":"vitalik239","id":11505274,"avatar_url":"https://avatars.githubusercontent.com/u/11505274?v=3","gravatar_id":"","url":"https://api.github.com/users/vitalik239","html_url":"https://github.com/vitalik239","followers_url":"https://api.github.com/users/vitalik239/followers","following_url":"https://api.github.com/users/vitalik239/following{/other_user}","gists_url":"https://api.github.com/users/vitalik239/gists{/gist_id}","starred_url":"https://api.github.com/users/vitalik239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitalik239/subscriptions","organizations_url":"https://api.github.com/users/vitalik239/orgs","repos_url":"https://api.github.com/users/vitalik239/repos","events_url":"https://api.github.com/users/vitalik239/events{/privacy}","received_events_url":"https://api.github.com/users/vitalik239/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vitalik239/CatalogApp","description":"","fork":false,"url":"https://api.github.com/repos/vitalik239/CatalogApp","forks_url":"https://api.github.com/repos/vitalik239/CatalogApp/forks","keys_url":"https://api.github.com/repos/vitalik239/CatalogApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vitalik239/CatalogApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vitalik239/CatalogApp/teams","hooks_url":"https://api.github.com/repos/vitalik239/CatalogApp/hooks","issue_events_url":"https://api.github.com/repos/vitalik239/CatalogApp/issues/events{/number}","events_url":"https://api.github.com/repos/vitalik239/CatalogApp/events","assignees_url":"https://api.github.com/repos/vitalik239/CatalogApp/assignees{/user}","branches_url":"https://api.github.com/repos/vitalik239/CatalogApp/branches{/branch}","tags_url":"https://api.github.com/repos/vitalik239/CatalogApp/tags","blobs_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vitalik239/CatalogApp/statuses/{sha}","languages_url":"https://api.github.com/repos/vitalik239/CatalogApp/languages","stargazers_url":"https://api.github.com/repos/vitalik239/CatalogApp/stargazers","contributors_url":"https://api.github.com/repos/vitalik239/CatalogApp/contributors","subscribers_url":"https://api.github.com/repos/vitalik239/CatalogApp/subscribers","subscription_url":"https://api.github.com/repos/vitalik239/CatalogApp/subscription","commits_url":"https://api.github.com/repos/vitalik239/CatalogApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/vitalik239/CatalogApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/vitalik239/CatalogApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/vitalik239/CatalogApp/contents/{+path}","compare_url":"https://api.github.com/repos/vitalik239/CatalogApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vitalik239/CatalogApp/merges","archive_url":"https://api.github.com/repos/vitalik239/CatalogApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vitalik239/CatalogApp/downloads","issues_url":"https://api.github.com/repos/vitalik239/CatalogApp/issues{/number}","pulls_url":"https://api.github.com/repos/vitalik239/CatalogApp/pulls{/number}","milestones_url":"https://api.github.com/repos/vitalik239/CatalogApp/milestones{/number}","notifications_url":"https://api.github.com/repos/vitalik239/CatalogApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vitalik239/CatalogApp/labels{/name}","releases_url":"https://api.github.com/repos/vitalik239/CatalogApp/releases{/id}","deployments_url":"https://api.github.com/repos/vitalik239/CatalogApp/deployments","created_at":"2015-12-15T20:56:07Z","updated_at":"2015-12-15T20:57:23Z","pushed_at":"2016-02-24T10:21:45Z","git_url":"git://github.com/vitalik239/CatalogApp.git","ssh_url":"git@github.com:vitalik239/CatalogApp.git","clone_url":"https://github.com/vitalik239/CatalogApp.git","svn_url":"https://github.com/vitalik239/CatalogApp","homepage":null,"size":165,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":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":"vitalik239:empty","ref":"empty","sha":"17ea7e17096262c7ae75f5dac2c59899d7e8a91b","user":{"login":"vitalik239","id":11505274,"avatar_url":"https://avatars.githubusercontent.com/u/11505274?v=3","gravatar_id":"","url":"https://api.github.com/users/vitalik239","html_url":"https://github.com/vitalik239","followers_url":"https://api.github.com/users/vitalik239/followers","following_url":"https://api.github.com/users/vitalik239/following{/other_user}","gists_url":"https://api.github.com/users/vitalik239/gists{/gist_id}","starred_url":"https://api.github.com/users/vitalik239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitalik239/subscriptions","organizations_url":"https://api.github.com/users/vitalik239/orgs","repos_url":"https://api.github.com/users/vitalik239/repos","events_url":"https://api.github.com/users/vitalik239/events{/privacy}","received_events_url":"https://api.github.com/users/vitalik239/received_events","type":"User","site_admin":false},"repo":{"id":48068526,"name":"CatalogApp","full_name":"vitalik239/CatalogApp","owner":{"login":"vitalik239","id":11505274,"avatar_url":"https://avatars.githubusercontent.com/u/11505274?v=3","gravatar_id":"","url":"https://api.github.com/users/vitalik239","html_url":"https://github.com/vitalik239","followers_url":"https://api.github.com/users/vitalik239/followers","following_url":"https://api.github.com/users/vitalik239/following{/other_user}","gists_url":"https://api.github.com/users/vitalik239/gists{/gist_id}","starred_url":"https://api.github.com/users/vitalik239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitalik239/subscriptions","organizations_url":"https://api.github.com/users/vitalik239/orgs","repos_url":"https://api.github.com/users/vitalik239/repos","events_url":"https://api.github.com/users/vitalik239/events{/privacy}","received_events_url":"https://api.github.com/users/vitalik239/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vitalik239/CatalogApp","description":"","fork":false,"url":"https://api.github.com/repos/vitalik239/CatalogApp","forks_url":"https://api.github.com/repos/vitalik239/CatalogApp/forks","keys_url":"https://api.github.com/repos/vitalik239/CatalogApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vitalik239/CatalogApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vitalik239/CatalogApp/teams","hooks_url":"https://api.github.com/repos/vitalik239/CatalogApp/hooks","issue_events_url":"https://api.github.com/repos/vitalik239/CatalogApp/issues/events{/number}","events_url":"https://api.github.com/repos/vitalik239/CatalogApp/events","assignees_url":"https://api.github.com/repos/vitalik239/CatalogApp/assignees{/user}","branches_url":"https://api.github.com/repos/vitalik239/CatalogApp/branches{/branch}","tags_url":"https://api.github.com/repos/vitalik239/CatalogApp/tags","blobs_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vitalik239/CatalogApp/statuses/{sha}","languages_url":"https://api.github.com/repos/vitalik239/CatalogApp/languages","stargazers_url":"https://api.github.com/repos/vitalik239/CatalogApp/stargazers","contributors_url":"https://api.github.com/repos/vitalik239/CatalogApp/contributors","subscribers_url":"https://api.github.com/repos/vitalik239/CatalogApp/subscribers","subscription_url":"https://api.github.com/repos/vitalik239/CatalogApp/subscription","commits_url":"https://api.github.com/repos/vitalik239/CatalogApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/vitalik239/CatalogApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/vitalik239/CatalogApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/vitalik239/CatalogApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/vitalik239/CatalogApp/contents/{+path}","compare_url":"https://api.github.com/repos/vitalik239/CatalogApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vitalik239/CatalogApp/merges","archive_url":"https://api.github.com/repos/vitalik239/CatalogApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vitalik239/CatalogApp/downloads","issues_url":"https://api.github.com/repos/vitalik239/CatalogApp/issues{/number}","pulls_url":"https://api.github.com/repos/vitalik239/CatalogApp/pulls{/number}","milestones_url":"https://api.github.com/repos/vitalik239/CatalogApp/milestones{/number}","notifications_url":"https://api.github.com/repos/vitalik239/CatalogApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vitalik239/CatalogApp/labels{/name}","releases_url":"https://api.github.com/repos/vitalik239/CatalogApp/releases{/id}","deployments_url":"https://api.github.com/repos/vitalik239/CatalogApp/deployments","created_at":"2015-12-15T20:56:07Z","updated_at":"2015-12-15T20:57:23Z","pushed_at":"2016-02-24T10:21:45Z","git_url":"git://github.com/vitalik239/CatalogApp.git","ssh_url":"git@github.com:vitalik239/CatalogApp.git","clone_url":"https://github.com/vitalik239/CatalogApp.git","svn_url":"https://github.com/vitalik239/CatalogApp","homepage":null,"size":165,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":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/vitalik239/CatalogApp/pulls/1"},"html":{"href":"https://github.com/vitalik239/CatalogApp/pull/1"},"issue":{"href":"https://api.github.com/repos/vitalik239/CatalogApp/issues/1"},"comments":{"href":"https://api.github.com/repos/vitalik239/CatalogApp/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vitalik239/CatalogApp/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/vitalik239/CatalogApp/statuses/80b72f2cf676c35ad9f1af7cfa6cdde49103132e"}}}}