{"action":"created","comment":{"url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/comments/45869964","id":45869964,"diff_hunk":"@@ -0,0 +1,155 @@\n+package com.example.home.myapplication;\n+\n+import android.os.Bundle;\n+import android.support.v7.app.AppCompatActivity;\n+import android.view.View;\n+import android.widget.Button;\n+import android.widget.TextView;\n+\n+import java.math.BigDecimal;\n+import java.math.RoundingMode;\n+\n+public class MainActivity extends AppCompatActivity {\n+    BigDecimal result = new BigDecimal(0);\n+    StringBuilder buffer = new StringBuilder(\"0\");\n+    String action = \"+\";\n+    boolean validbuff = true;\n+    boolean error = false;\n+\n+    @Override\n+    protected void onCreate(Bundle savedInstanceState) {\n+        super.onCreate(savedInstanceState);\n+        setContentView(R.layout.activity_main);\n+\n+    }\n+\n+    public void completeaction(View view) {\n+        Button button = (Button) view;\n+        if (validbuff)\n+            switch (action) {\n+                case (\"\"):\n+                    break;\n+                case (\"+\"): {\n+                    result = result.add(new BigDecimal(buffer.toString()));\n+                    break;\n+                }\n+                case (\"-\"): {\n+                    result = result.subtract(new BigDecimal(buffer.toString()));\n+                    break;\n+                }\n+                case (\"*\"): {\n+                    result = result.multiply(new BigDecimal(buffer.toString())).setScale(7, BigDecimal.ROUND_HALF_EVEN);\n+                    break;\n+                }\n+                case (\"/\"): {\n+                    boolean zero = true;\n+                    for (int i = 0; i < buffer.length(); i++)\n+                        if (buffer.charAt(i) != '-' && buffer.charAt(i) != '0' && buffer.charAt(i) != '.') {\n+                            zero = false;\n+                            break;\n+                        }\n+                    if (zero) {\n+                        error = true;\n+                        ((TextView) findViewById(R.id.textTempBuffer)).setText(\"Divide by zero\");\n+                        return;\n+                    }\n+                    result = result.divide(new BigDecimal(buffer.toString()), 9, BigDecimal.ROUND_HALF_UP);\n+                    break;\n+                }\n+            }\n+        shownumber(false);\n+        if (String.valueOf(button.getText()).compareTo(\"=\") != 0)\n+            action = button.getText().toString();\n+        System.out.println(action);\n+        validbuff = false;\n+    }\n+\n+    public void clearbuff() {\n+        buffer = new StringBuilder(\"0\");\n+        validbuff = true;\n+    }\n+\n+    public void updatebuff(View v) {\n+        Button button = (Button) v;\n+        if (!validbuff) {\n+            clearbuff();\n+        }\n+        validbuff = true;\n+        if (buffer.toString().compareTo(\"0\") == 0 || buffer.toString().compareTo(\"-0\") == 0) {\n+            if (String.valueOf(button.getText()).compareTo(\".\") == 0) {\n+                buffer.append(\".\");\n+            } else\n+                buffer = new StringBuilder(button.getText());\n+        } else if (!(buffer.toString().contains(\".\") && (button.getText() == \".\")))\n+            buffer.append(button.getText());\n+        shownumber(true);\n+    }\n+\n+    public void shownumber(boolean isbuff) {\n+        StringBuilder i = (isbuff ? buffer : new StringBuilder(result.toString()));","path":"app/src/main/java/com/example/home/myapplication/MainActivity.java","position":89,"original_position":89,"commit_id":"4d92f8e724a49e8678f921ca85ae62c02186ae19","original_commit_id":"4d92f8e724a49e8678f921ca85ae62c02186ae19","user":{"login":"HighFlyer13","id":2953187,"avatar_url":"https://avatars.githubusercontent.com/u/2953187?v=3","gravatar_id":"","url":"https://api.github.com/users/HighFlyer13","html_url":"https://github.com/HighFlyer13","followers_url":"https://api.github.com/users/HighFlyer13/followers","following_url":"https://api.github.com/users/HighFlyer13/following{/other_user}","gists_url":"https://api.github.com/users/HighFlyer13/gists{/gist_id}","starred_url":"https://api.github.com/users/HighFlyer13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HighFlyer13/subscriptions","organizations_url":"https://api.github.com/users/HighFlyer13/orgs","repos_url":"https://api.github.com/users/HighFlyer13/repos","events_url":"https://api.github.com/users/HighFlyer13/events{/privacy}","received_events_url":"https://api.github.com/users/HighFlyer13/received_events","type":"User","site_admin":false},"body":"i - хорошее название для StringBuilder-а.","created_at":"2015-11-25T14:09:46Z","updated_at":"2015-11-25T14:09:46Z","html_url":"https://github.com/IFMO-Android-2015/homework1/pull/34#discussion_r45869964","pull_request_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/comments/45869964"},"html":{"href":"https://github.com/IFMO-Android-2015/homework1/pull/34#discussion_r45869964"},"pull_request":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/34","id":50159445,"html_url":"https://github.com/IFMO-Android-2015/homework1/pull/34","diff_url":"https://github.com/IFMO-Android-2015/homework1/pull/34.diff","patch_url":"https://github.com/IFMO-Android-2015/homework1/pull/34.patch","issue_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/34","number":34,"state":"open","locked":false,"title":"hw1 done","user":{"login":"kohanov","id":15210688,"avatar_url":"https://avatars.githubusercontent.com/u/15210688?v=3","gravatar_id":"","url":"https://api.github.com/users/kohanov","html_url":"https://github.com/kohanov","followers_url":"https://api.github.com/users/kohanov/followers","following_url":"https://api.github.com/users/kohanov/following{/other_user}","gists_url":"https://api.github.com/users/kohanov/gists{/gist_id}","starred_url":"https://api.github.com/users/kohanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohanov/subscriptions","organizations_url":"https://api.github.com/users/kohanov/orgs","repos_url":"https://api.github.com/users/kohanov/repos","events_url":"https://api.github.com/users/kohanov/events{/privacy}","received_events_url":"https://api.github.com/users/kohanov/received_events","type":"User","site_admin":false},"body":"Коханов Алексей M3238","created_at":"2015-11-09T18:34:27Z","updated_at":"2015-11-25T14:09:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"94493dfd59babcfd220d00f5fa0325f02d12b195","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/34/commits","review_comments_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/34/comments","review_comment_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/34/comments","statuses_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/statuses/4d92f8e724a49e8678f921ca85ae62c02186ae19","head":{"label":"kohanov:master","ref":"master","sha":"4d92f8e724a49e8678f921ca85ae62c02186ae19","user":{"login":"kohanov","id":15210688,"avatar_url":"https://avatars.githubusercontent.com/u/15210688?v=3","gravatar_id":"","url":"https://api.github.com/users/kohanov","html_url":"https://github.com/kohanov","followers_url":"https://api.github.com/users/kohanov/followers","following_url":"https://api.github.com/users/kohanov/following{/other_user}","gists_url":"https://api.github.com/users/kohanov/gists{/gist_id}","starred_url":"https://api.github.com/users/kohanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohanov/subscriptions","organizations_url":"https://api.github.com/users/kohanov/orgs","repos_url":"https://api.github.com/users/kohanov/repos","events_url":"https://api.github.com/users/kohanov/events{/privacy}","received_events_url":"https://api.github.com/users/kohanov/received_events","type":"User","site_admin":false},"repo":{"id":45729986,"name":"homework1","full_name":"kohanov/homework1","owner":{"login":"kohanov","id":15210688,"avatar_url":"https://avatars.githubusercontent.com/u/15210688?v=3","gravatar_id":"","url":"https://api.github.com/users/kohanov","html_url":"https://github.com/kohanov","followers_url":"https://api.github.com/users/kohanov/followers","following_url":"https://api.github.com/users/kohanov/following{/other_user}","gists_url":"https://api.github.com/users/kohanov/gists{/gist_id}","starred_url":"https://api.github.com/users/kohanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohanov/subscriptions","organizations_url":"https://api.github.com/users/kohanov/orgs","repos_url":"https://api.github.com/users/kohanov/repos","events_url":"https://api.github.com/users/kohanov/events{/privacy}","received_events_url":"https://api.github.com/users/kohanov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kohanov/homework1","description":"","fork":true,"url":"https://api.github.com/repos/kohanov/homework1","forks_url":"https://api.github.com/repos/kohanov/homework1/forks","keys_url":"https://api.github.com/repos/kohanov/homework1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kohanov/homework1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kohanov/homework1/teams","hooks_url":"https://api.github.com/repos/kohanov/homework1/hooks","issue_events_url":"https://api.github.com/repos/kohanov/homework1/issues/events{/number}","events_url":"https://api.github.com/repos/kohanov/homework1/events","assignees_url":"https://api.github.com/repos/kohanov/homework1/assignees{/user}","branches_url":"https://api.github.com/repos/kohanov/homework1/branches{/branch}","tags_url":"https://api.github.com/repos/kohanov/homework1/tags","blobs_url":"https://api.github.com/repos/kohanov/homework1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kohanov/homework1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kohanov/homework1/git/refs{/sha}","trees_url":"https://api.github.com/repos/kohanov/homework1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kohanov/homework1/statuses/{sha}","languages_url":"https://api.github.com/repos/kohanov/homework1/languages","stargazers_url":"https://api.github.com/repos/kohanov/homework1/stargazers","contributors_url":"https://api.github.com/repos/kohanov/homework1/contributors","subscribers_url":"https://api.github.com/repos/kohanov/homework1/subscribers","subscription_url":"https://api.github.com/repos/kohanov/homework1/subscription","commits_url":"https://api.github.com/repos/kohanov/homework1/commits{/sha}","git_commits_url":"https://api.github.com/repos/kohanov/homework1/git/commits{/sha}","comments_url":"https://api.github.com/repos/kohanov/homework1/comments{/number}","issue_comment_url":"https://api.github.com/repos/kohanov/homework1/issues/comments{/number}","contents_url":"https://api.github.com/repos/kohanov/homework1/contents/{+path}","compare_url":"https://api.github.com/repos/kohanov/homework1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kohanov/homework1/merges","archive_url":"https://api.github.com/repos/kohanov/homework1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kohanov/homework1/downloads","issues_url":"https://api.github.com/repos/kohanov/homework1/issues{/number}","pulls_url":"https://api.github.com/repos/kohanov/homework1/pulls{/number}","milestones_url":"https://api.github.com/repos/kohanov/homework1/milestones{/number}","notifications_url":"https://api.github.com/repos/kohanov/homework1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kohanov/homework1/labels{/name}","releases_url":"https://api.github.com/repos/kohanov/homework1/releases{/id}","created_at":"2015-11-07T09:17:43Z","updated_at":"2015-11-09T18:24:05Z","pushed_at":"2015-11-09T19:04:20Z","git_url":"git://github.com/kohanov/homework1.git","ssh_url":"git@github.com:kohanov/homework1.git","clone_url":"https://github.com/kohanov/homework1.git","svn_url":"https://github.com/kohanov/homework1","homepage":null,"size":122,"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":"IFMO-Android-2015:master","ref":"master","sha":"cdba00f6819b33da0471f8c16e24aa4849063ef0","user":{"login":"IFMO-Android-2015","id":15182437,"avatar_url":"https://avatars.githubusercontent.com/u/15182437?v=3","gravatar_id":"","url":"https://api.github.com/users/IFMO-Android-2015","html_url":"https://github.com/IFMO-Android-2015","followers_url":"https://api.github.com/users/IFMO-Android-2015/followers","following_url":"https://api.github.com/users/IFMO-Android-2015/following{/other_user}","gists_url":"https://api.github.com/users/IFMO-Android-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/IFMO-Android-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IFMO-Android-2015/subscriptions","organizations_url":"https://api.github.com/users/IFMO-Android-2015/orgs","repos_url":"https://api.github.com/users/IFMO-Android-2015/repos","events_url":"https://api.github.com/users/IFMO-Android-2015/events{/privacy}","received_events_url":"https://api.github.com/users/IFMO-Android-2015/received_events","type":"User","site_admin":false},"repo":{"id":45344078,"name":"homework1","full_name":"IFMO-Android-2015/homework1","owner":{"login":"IFMO-Android-2015","id":15182437,"avatar_url":"https://avatars.githubusercontent.com/u/15182437?v=3","gravatar_id":"","url":"https://api.github.com/users/IFMO-Android-2015","html_url":"https://github.com/IFMO-Android-2015","followers_url":"https://api.github.com/users/IFMO-Android-2015/followers","following_url":"https://api.github.com/users/IFMO-Android-2015/following{/other_user}","gists_url":"https://api.github.com/users/IFMO-Android-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/IFMO-Android-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IFMO-Android-2015/subscriptions","organizations_url":"https://api.github.com/users/IFMO-Android-2015/orgs","repos_url":"https://api.github.com/users/IFMO-Android-2015/repos","events_url":"https://api.github.com/users/IFMO-Android-2015/events{/privacy}","received_events_url":"https://api.github.com/users/IFMO-Android-2015/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/IFMO-Android-2015/homework1","description":"","fork":false,"url":"https://api.github.com/repos/IFMO-Android-2015/homework1","forks_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/forks","keys_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/teams","hooks_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/hooks","issue_events_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/events{/number}","events_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/events","assignees_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/assignees{/user}","branches_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/branches{/branch}","tags_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/tags","blobs_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/refs{/sha}","trees_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/statuses/{sha}","languages_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/languages","stargazers_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/stargazers","contributors_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/contributors","subscribers_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/subscribers","subscription_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/subscription","commits_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/commits{/sha}","git_commits_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/commits{/sha}","comments_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/comments{/number}","issue_comment_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/comments{/number}","contents_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/contents/{+path}","compare_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/merges","archive_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/downloads","issues_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues{/number}","pulls_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls{/number}","milestones_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/milestones{/number}","notifications_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/labels{/name}","releases_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/releases{/id}","created_at":"2015-11-01T14:43:27Z","updated_at":"2015-11-01T14:43:27Z","pushed_at":"2015-11-24T18:00:53Z","git_url":"git://github.com/IFMO-Android-2015/homework1.git","ssh_url":"git@github.com:IFMO-Android-2015/homework1.git","clone_url":"https://github.com/IFMO-Android-2015/homework1.git","svn_url":"https://github.com/IFMO-Android-2015/homework1","homepage":null,"size":1499,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":49,"forks":59,"open_issues":49,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/34"},"html":{"href":"https://github.com/IFMO-Android-2015/homework1/pull/34"},"issue":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/34"},"comments":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/statuses/4d92f8e724a49e8678f921ca85ae62c02186ae19"}}}}