{"action":"created","comment":{"url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/comments/210217207","pull_request_review_id":146384077,"id":210217207,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDIxNzIwNw==","diff_hunk":"@@ -37,51 +62,215 @@\n     private Button addDogButton;\n     private Owner owner;\n     private Dog dog;\n+    private DogKind dogKind;\n+    private ImageView photoDogImageView;\n+    private File photoFile;\n+    private String photoFilePathString;\n+    private boolean hasPhoto;\n+    private View rootLayout;\n \n     @Override\n     protected void onCreate(Bundle savedInstanceState) {\n         super.onCreate(savedInstanceState);\n         setContentView(R.layout.activity_new_dog_form);\n-\n         Toolbar toolbar = DogToolBar.init(this, R.string.toolbar_title_add_dog);\n         setSupportActionBar(toolbar);\n \n+        hasPhoto = false;\n         owner = getIntent().getParcelableExtra(EXTRA_NEW_OWNER);\n \n         initViews();\n         testingFillEditText();\n-        createDogModelFromInputDatas();\n+        createDogModelWithInputDatas();\n \n         dogKindEditText.setFocusable(false);\n         dogKindEditText.setClickable(true);\n-        dogKindEditText.setOnClickListener(view -> startDogsKindsListActivity());\n+        dogKindEditText.setOnClickListener(view -> startDogsKindsListActivity(dog));\n \n         addDogButton.setOnClickListener(view -> {\n-            // если порода собаки еще не установлена, то отправляемся в DogsKindsListActivity\n+            // если порода собаки еще не установлена, то переход в список пород\n             if (dog.getDogKind() == null) {\n-                startDogsKindsListActivity();\n+                startDogsKindsListActivity(dog);\n             } else {\n+                // добавляем собачку в БД и возвращаем её уже с сгенерированным dogId в модель dog\n                 dog = DataRepository.get().addDog(dog);\n                 owner.addDog(dog);\n                 backToDogListActivity();\n             }\n         });\n+\n+        photoDogImageView.setOnClickListener(view -> checkPermissions());\n     }\n \n-    private void createDogModelFromInputDatas() {\n-        String dogName = dogNameEditText.getText().toString();\n-        int dogAge = Integer.parseInt(dogAgeEditText.getText().toString());\n-        int dogTall = Integer.parseInt(dogTallEditText.getText().toString());\n-        int dogWeight = Integer.parseInt(dogWeightEditText.getText().toString());\n-        // вытащили owner'a из EXTRA и добавляем его с остальными данными в модель\n-        dog = new Dog(dogName, owner, dogAge, dogTall, dogWeight);\n+    private void checkPermissions() {\n+        // если все ок запускаем камеру\n+        if (hasPermission(Manifest.permission.CAMERA)\n+                && hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {\n+            startCameraOrPreview(photoFilePathString);\n+        } // если отсутствуют оба разрешения\n+        else if (!(hasPermission(Manifest.permission.CAMERA)\n+                || hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE))) {\n+            requestPermission(new String[]{Manifest.permission.CAMERA,\n+                    Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST);\n+        } else if (!hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {\n+            requestPermissionWithRationale(Manifest.permission.READ_EXTERNAL_STORAGE,\n+                    R.string.need_storage_access_snackbar,\n+                    STORAGE_PERMISSIONS, PERMISSION_STORAGE_REQUEST);\n+        } else if (!hasPermission(Manifest.permission.CAMERA)) {\n+            requestPermissionWithRationale(Manifest.permission.CAMERA,\n+                    R.string.need_camera_access_snackbar,\n+                    CAMERA_PERMISSIONS, PERMISSION_CAMERA_REQUEST);\n+        }\n+    }\n+\n+    private boolean hasPermission(String permission) {\n+        return (ContextCompat.checkSelfPermission(this, permission)","path":"app/src/main/java/com/andersen/dogsapp/dogs/ui/dogs/NewDogFormActivity.java","position":147,"original_position":147,"commit_id":"878c12a400507819a812c523490323dd92842615","original_commit_id":"878c12a400507819a812c523490323dd92842615","user":{"login":"dmitrybubnovsky","id":28919980,"node_id":"MDQ6VXNlcjI4OTE5OTgw","avatar_url":"https://avatars2.githubusercontent.com/u/28919980?v=4","gravatar_id":"","url":"https://api.github.com/users/dmitrybubnovsky","html_url":"https://github.com/dmitrybubnovsky","followers_url":"https://api.github.com/users/dmitrybubnovsky/followers","following_url":"https://api.github.com/users/dmitrybubnovsky/following{/other_user}","gists_url":"https://api.github.com/users/dmitrybubnovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrybubnovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrybubnovsky/subscriptions","organizations_url":"https://api.github.com/users/dmitrybubnovsky/orgs","repos_url":"https://api.github.com/users/dmitrybubnovsky/repos","events_url":"https://api.github.com/users/dmitrybubnovsky/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrybubnovsky/received_events","type":"User","site_admin":false},"body":"зачем тут скобки внешние?","created_at":"2018-08-15T09:33:39Z","updated_at":"2018-08-15T09:33:39Z","html_url":"https://github.com/dmitrybubnovsky/DogsApp/pull/15#discussion_r210217207","pull_request_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/15","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/comments/210217207"},"html":{"href":"https://github.com/dmitrybubnovsky/DogsApp/pull/15#discussion_r210217207"},"pull_request":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/15","id":206350962,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2MzUwOTYy","html_url":"https://github.com/dmitrybubnovsky/DogsApp/pull/15","diff_url":"https://github.com/dmitrybubnovsky/DogsApp/pull/15.diff","patch_url":"https://github.com/dmitrybubnovsky/DogsApp/pull/15.patch","issue_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues/15","number":15,"state":"open","locked":false,"title":"FAT-1836","user":{"login":"StanlyT","id":26867741,"node_id":"MDQ6VXNlcjI2ODY3NzQx","avatar_url":"https://avatars3.githubusercontent.com/u/26867741?v=4","gravatar_id":"","url":"https://api.github.com/users/StanlyT","html_url":"https://github.com/StanlyT","followers_url":"https://api.github.com/users/StanlyT/followers","following_url":"https://api.github.com/users/StanlyT/following{/other_user}","gists_url":"https://api.github.com/users/StanlyT/gists{/gist_id}","starred_url":"https://api.github.com/users/StanlyT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StanlyT/subscriptions","organizations_url":"https://api.github.com/users/StanlyT/orgs","repos_url":"https://api.github.com/users/StanlyT/repos","events_url":"https://api.github.com/users/StanlyT/events{/privacy}","received_events_url":"https://api.github.com/users/StanlyT/received_events","type":"User","site_admin":false},"body":"\tДобавлено: \n\t- активити DogPhotoPreviewActivity, в которую происходит переход при клике по уже сделанной фото в NewDogFormActivity; \n\t- класс PuctureUtils который обрабатывает полученное bitmap изображение;\n\t- во избежании повторения кода по инициализации ImageView в DogsAdapter и DogsInfoActivity добавлен класс DogImageView со статическим методом для setDogImage","created_at":"2018-08-06T10:12:24Z","updated_at":"2018-08-15T09:33:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f7536bfe6a9ef22e9b316e9d8abaf814897709d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/15/commits","review_comments_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/15/comments","review_comment_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues/15/comments","statuses_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/statuses/878c12a400507819a812c523490323dd92842615","head":{"label":"dmitrybubnovsky:FAT-1836","ref":"FAT-1836","sha":"878c12a400507819a812c523490323dd92842615","user":{"login":"dmitrybubnovsky","id":28919980,"node_id":"MDQ6VXNlcjI4OTE5OTgw","avatar_url":"https://avatars2.githubusercontent.com/u/28919980?v=4","gravatar_id":"","url":"https://api.github.com/users/dmitrybubnovsky","html_url":"https://github.com/dmitrybubnovsky","followers_url":"https://api.github.com/users/dmitrybubnovsky/followers","following_url":"https://api.github.com/users/dmitrybubnovsky/following{/other_user}","gists_url":"https://api.github.com/users/dmitrybubnovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrybubnovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrybubnovsky/subscriptions","organizations_url":"https://api.github.com/users/dmitrybubnovsky/orgs","repos_url":"https://api.github.com/users/dmitrybubnovsky/repos","events_url":"https://api.github.com/users/dmitrybubnovsky/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrybubnovsky/received_events","type":"User","site_admin":false},"repo":{"id":139421960,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk0MjE5NjA=","name":"DogsApp","full_name":"dmitrybubnovsky/DogsApp","owner":{"login":"dmitrybubnovsky","id":28919980,"node_id":"MDQ6VXNlcjI4OTE5OTgw","avatar_url":"https://avatars2.githubusercontent.com/u/28919980?v=4","gravatar_id":"","url":"https://api.github.com/users/dmitrybubnovsky","html_url":"https://github.com/dmitrybubnovsky","followers_url":"https://api.github.com/users/dmitrybubnovsky/followers","following_url":"https://api.github.com/users/dmitrybubnovsky/following{/other_user}","gists_url":"https://api.github.com/users/dmitrybubnovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrybubnovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrybubnovsky/subscriptions","organizations_url":"https://api.github.com/users/dmitrybubnovsky/orgs","repos_url":"https://api.github.com/users/dmitrybubnovsky/repos","events_url":"https://api.github.com/users/dmitrybubnovsky/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrybubnovsky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmitrybubnovsky/DogsApp","description":null,"fork":false,"url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp","forks_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/forks","keys_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/teams","hooks_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/hooks","issue_events_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues/events{/number}","events_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/events","assignees_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/assignees{/user}","branches_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/branches{/branch}","tags_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/tags","blobs_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/statuses/{sha}","languages_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/languages","stargazers_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/stargazers","contributors_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/contributors","subscribers_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/subscribers","subscription_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/subscription","commits_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/contents/{+path}","compare_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/merges","archive_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/downloads","issues_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues{/number}","pulls_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls{/number}","milestones_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/milestones{/number}","notifications_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/labels{/name}","releases_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/releases{/id}","deployments_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/deployments","created_at":"2018-07-02T09:33:57Z","updated_at":"2018-08-06T08:21:04Z","pushed_at":"2018-08-15T08:33:50Z","git_url":"git://github.com/dmitrybubnovsky/DogsApp.git","ssh_url":"git@github.com:dmitrybubnovsky/DogsApp.git","clone_url":"https://github.com/dmitrybubnovsky/DogsApp.git","svn_url":"https://github.com/dmitrybubnovsky/DogsApp","homepage":null,"size":1991,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"dmitrybubnovsky:master","ref":"master","sha":"a3d5f0910c686b4c46a0942736dac966d6e21874","user":{"login":"dmitrybubnovsky","id":28919980,"node_id":"MDQ6VXNlcjI4OTE5OTgw","avatar_url":"https://avatars2.githubusercontent.com/u/28919980?v=4","gravatar_id":"","url":"https://api.github.com/users/dmitrybubnovsky","html_url":"https://github.com/dmitrybubnovsky","followers_url":"https://api.github.com/users/dmitrybubnovsky/followers","following_url":"https://api.github.com/users/dmitrybubnovsky/following{/other_user}","gists_url":"https://api.github.com/users/dmitrybubnovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrybubnovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrybubnovsky/subscriptions","organizations_url":"https://api.github.com/users/dmitrybubnovsky/orgs","repos_url":"https://api.github.com/users/dmitrybubnovsky/repos","events_url":"https://api.github.com/users/dmitrybubnovsky/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrybubnovsky/received_events","type":"User","site_admin":false},"repo":{"id":139421960,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk0MjE5NjA=","name":"DogsApp","full_name":"dmitrybubnovsky/DogsApp","owner":{"login":"dmitrybubnovsky","id":28919980,"node_id":"MDQ6VXNlcjI4OTE5OTgw","avatar_url":"https://avatars2.githubusercontent.com/u/28919980?v=4","gravatar_id":"","url":"https://api.github.com/users/dmitrybubnovsky","html_url":"https://github.com/dmitrybubnovsky","followers_url":"https://api.github.com/users/dmitrybubnovsky/followers","following_url":"https://api.github.com/users/dmitrybubnovsky/following{/other_user}","gists_url":"https://api.github.com/users/dmitrybubnovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrybubnovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrybubnovsky/subscriptions","organizations_url":"https://api.github.com/users/dmitrybubnovsky/orgs","repos_url":"https://api.github.com/users/dmitrybubnovsky/repos","events_url":"https://api.github.com/users/dmitrybubnovsky/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrybubnovsky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmitrybubnovsky/DogsApp","description":null,"fork":false,"url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp","forks_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/forks","keys_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/teams","hooks_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/hooks","issue_events_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues/events{/number}","events_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/events","assignees_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/assignees{/user}","branches_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/branches{/branch}","tags_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/tags","blobs_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/statuses/{sha}","languages_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/languages","stargazers_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/stargazers","contributors_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/contributors","subscribers_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/subscribers","subscription_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/subscription","commits_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/contents/{+path}","compare_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/merges","archive_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/downloads","issues_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues{/number}","pulls_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls{/number}","milestones_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/milestones{/number}","notifications_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/labels{/name}","releases_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/releases{/id}","deployments_url":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/deployments","created_at":"2018-07-02T09:33:57Z","updated_at":"2018-08-06T08:21:04Z","pushed_at":"2018-08-15T08:33:50Z","git_url":"git://github.com/dmitrybubnovsky/DogsApp.git","ssh_url":"git@github.com:dmitrybubnovsky/DogsApp.git","clone_url":"https://github.com/dmitrybubnovsky/DogsApp.git","svn_url":"https://github.com/dmitrybubnovsky/DogsApp","homepage":null,"size":1991,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/15"},"html":{"href":"https://github.com/dmitrybubnovsky/DogsApp/pull/15"},"issue":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues/15"},"comments":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/dmitrybubnovsky/DogsApp/statuses/878c12a400507819a812c523490323dd92842615"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"dmitrybubnovsky"}}