{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/hrm_3/pulls/comments/48404419","id":48404419,"diff_hunk":"@@ -0,0 +1,134 @@\n+package com.nhs3108.fhrm.activites;\n+\n+import android.app.Activity;\n+import android.content.Intent;\n+import android.database.SQLException;\n+import android.os.Bundle;\n+import android.view.View;\n+import android.view.ViewGroup;\n+import android.widget.ArrayAdapter;\n+import android.widget.Button;\n+import android.widget.CheckBox;\n+import android.widget.EditText;\n+import android.widget.LinearLayout;\n+import android.widget.Spinner;\n+import android.widget.Toast;\n+\n+import com.nhs3108.fhrm.R;\n+import com.nhs3108.fhrm.models.Department;\n+import com.nhs3108.fhrm.models.DepartmentHelper;\n+import com.nhs3108.fhrm.models.Staff;\n+import com.nhs3108.fhrm.models.StaffHelper;\n+import com.nhs3108.fhrm.utils.DateUtils;\n+\n+import java.util.ArrayList;\n+\n+/**\n+ * Created by hongson on 24/12/2015.\n+ */\n+public class StaffEditingActivity extends Activity {\n+    private DepartmentHelper departmentHelper = new DepartmentHelper(this);\n+    private StaffHelper staffHelper = new StaffHelper(this);\n+    private EditText editStaffName;\n+    private EditText editStaffBirthday;\n+    private EditText editStaffAddress;\n+    private EditText editStaffPhone;\n+    private EditText editStaffPositon;\n+    private Spinner spinnerDepartment;\n+    private CheckBox checkBoxLeftJob;\n+    private ViewGroup containerEditing;\n+    private Button enableEditingButton;\n+    private Staff staff;\n+    private ArrayList<Department> departments;\n+\n+    public void onCreate(Bundle savedInstanceState) {\n+        super.onCreate(savedInstanceState);\n+        setContentView(R.layout.activity_staff_editing);\n+        containerEditing = (ViewGroup) findViewById(R.id.container_editing_body);\n+        setEnableControls(false, containerEditing);\n+        Intent data = getIntent();\n+        int staffId = data.getIntExtra(\"staffId\", -1);\n+        try {\n+            staff = staffHelper.getById(staffId);\n+            departments = departmentHelper.getAll();\n+        } catch (NullPointerException e) {\n+            Toast.makeText(this, getString(R.string.msg_staff_not_found), Toast.LENGTH_SHORT).show();\n+        } catch (SQLException e) {\n+            Toast.makeText(this, getString(R.string.msg_sql_exception), Toast.LENGTH_SHORT).show();\n+        }\n+\n+        editStaffName = (EditText) findViewById(R.id.edit_staff_name);\n+        editStaffBirthday = (EditText) findViewById(R.id.edit_staff_birthday);\n+        editStaffAddress = (EditText) findViewById(R.id.edit_staff_address);\n+        editStaffPhone = (EditText) findViewById(R.id.edit_staff_phone);\n+        editStaffPositon = (EditText) findViewById(R.id.edit_staff_position);\n+        spinnerDepartment = (Spinner) findViewById(R.id.spinner_staff_department);\n+        checkBoxLeftJob = (CheckBox) findViewById(R.id.checkbox_left_job);\n+        enableEditingButton = (Button) findViewById(R.id.btn_enable_editing);\n+\n+        editStaffName.setText(staff.getName());\n+        editStaffBirthday.setText(DateUtils.convertToString(staff.getDateOfBirth(), \"yyyy-mm-dd\"));\n+        editStaffAddress.setText(staff.getPlaceOfBirth());\n+        editStaffPhone.setText(staff.getPhone());\n+        editStaffPositon.setText(staff.getPosition());\n+        checkBoxLeftJob.setChecked(staff.isLeftJob());\n+        ArrayList<String> list = new ArrayList<String>();\n+        for (Department department : departments) {\n+            list.add(department.getName());\n+        }\n+        ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, list);\n+        spinnerDepartment.setAdapter(adapter);\n+        int spinnerPosition = adapter.getPosition(staff.getDepartment().getName());\n+        spinnerDepartment.setSelection(spinnerPosition);\n+    }\n+\n+    public void enableStaffEditing(View v) {\n+        enableEditingButton.setVisibility(View.GONE);\n+        setEnableControls(true, containerEditing);\n+        final Button saveButton = new Button(this);\n+        saveButton.setText(getString(R.string.label_save));\n+        LinearLayout layout = (LinearLayout) findViewById(R.id.container_action_buttons);\n+        layout.addView(saveButton);\n+\n+        saveButton.setOnClickListener(new View.OnClickListener() {\n+            public void onClick(View v) {\n+                try {\n+                    updateStaffProfile();\n+                    setEnableControls(false, containerEditing);\n+                    saveButton.setVisibility(View.GONE);\n+                    enableEditingButton.setVisibility(View.VISIBLE);\n+                    Toast.makeText(StaffEditingActivity.this, getString(R.string.msg_successfully),\n+                            Toast.LENGTH_SHORT).show();\n+                } catch (SQLException e){\n+                    Toast.makeText(StaffEditingActivity.this, getString(R.string.error_failed),\n+                            Toast.LENGTH_SHORT).show();\n+                }\n+            }\n+        });\n+    }\n+\n+    public void updateStaffProfile() throws SQLException{\n+        ArrayList<Staff> staffsWillBeUpdated = new ArrayList<Staff>();\n+\n+        staff.setName(editStaffName.getText().toString());\n+        staff.setDateOfBirth(DateUtils.convertFromString(editStaffBirthday.getText().toString(), \"yyyy-mm-dd\"));\n+        staff.setPlaceOfBirth(editStaffAddress.getText().toString());\n+        staff.setPhone(editStaffPhone.getText().toString());\n+        staff.setPosition(editStaffPositon.getText().toString());\n+        staff.setLeftJob(checkBoxLeftJob.isChecked());\n+        staff.setDepartment(departments.get(spinnerDepartment.getSelectedItemPosition()));\n+\n+        staffsWillBeUpdated.add(staff);\n+        staffHelper.update(staffsWillBeUpdated);\n+    }\n+\n+    private void setEnableControls(boolean enable, ViewGroup parent) {\n+        for (int i = 0; i < parent.getChildCount(); i++) {","path":"app/src/main/java/com/nhs3108/fhrm/activites/StaffEditingActivity.java","position":126,"original_position":126,"commit_id":"296ad6872d26961ccbc85e2f07d072419043e7bf","original_commit_id":"296ad6872d26961ccbc85e2f07d072419043e7bf","user":{"login":"HungTDO","id":6904924,"avatar_url":"https://avatars.githubusercontent.com/u/6904924?v=3","gravatar_id":"","url":"https://api.github.com/users/HungTDO","html_url":"https://github.com/HungTDO","followers_url":"https://api.github.com/users/HungTDO/followers","following_url":"https://api.github.com/users/HungTDO/following{/other_user}","gists_url":"https://api.github.com/users/HungTDO/gists{/gist_id}","starred_url":"https://api.github.com/users/HungTDO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HungTDO/subscriptions","organizations_url":"https://api.github.com/users/HungTDO/orgs","repos_url":"https://api.github.com/users/HungTDO/repos","events_url":"https://api.github.com/users/HungTDO/events{/privacy}","received_events_url":"https://api.github.com/users/HungTDO/received_events","type":"User","site_admin":false},"body":"Đặt biến size ra ngoài ","created_at":"2015-12-24T09:09:31Z","updated_at":"2015-12-24T09:09:31Z","html_url":"https://github.com/framgia/hrm_3/pull/6#discussion_r48404419","pull_request_url":"https://api.github.com/repos/framgia/hrm_3/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/framgia/hrm_3/pulls/comments/48404419"},"html":{"href":"https://github.com/framgia/hrm_3/pull/6#discussion_r48404419"},"pull_request":{"href":"https://api.github.com/repos/framgia/hrm_3/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/hrm_3/pulls/6","id":54536503,"html_url":"https://github.com/framgia/hrm_3/pull/6","diff_url":"https://github.com/framgia/hrm_3/pull/6.diff","patch_url":"https://github.com/framgia/hrm_3/pull/6.patch","issue_url":"https://api.github.com/repos/framgia/hrm_3/issues/6","number":6,"state":"open","locked":false,"title":"Showing and updating staff profile","user":{"login":"nhs3108","id":10093701,"avatar_url":"https://avatars.githubusercontent.com/u/10093701?v=3","gravatar_id":"","url":"https://api.github.com/users/nhs3108","html_url":"https://github.com/nhs3108","followers_url":"https://api.github.com/users/nhs3108/followers","following_url":"https://api.github.com/users/nhs3108/following{/other_user}","gists_url":"https://api.github.com/users/nhs3108/gists{/gist_id}","starred_url":"https://api.github.com/users/nhs3108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhs3108/subscriptions","organizations_url":"https://api.github.com/users/nhs3108/orgs","repos_url":"https://api.github.com/users/nhs3108/repos","events_url":"https://api.github.com/users/nhs3108/events{/privacy}","received_events_url":"https://api.github.com/users/nhs3108/received_events","type":"User","site_admin":false},"body":"Showing staff's detail\r\nUpdating staff's profile feature","created_at":"2015-12-24T08:43:43Z","updated_at":"2015-12-24T09:09:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09171d8a0dc9d9c65df2af954271a0d72a67691c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/hrm_3/pulls/6/commits","review_comments_url":"https://api.github.com/repos/framgia/hrm_3/pulls/6/comments","review_comment_url":"https://api.github.com/repos/framgia/hrm_3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/hrm_3/issues/6/comments","statuses_url":"https://api.github.com/repos/framgia/hrm_3/statuses/296ad6872d26961ccbc85e2f07d072419043e7bf","head":{"label":"nhs3108:show_update_staff","ref":"show_update_staff","sha":"296ad6872d26961ccbc85e2f07d072419043e7bf","user":{"login":"nhs3108","id":10093701,"avatar_url":"https://avatars.githubusercontent.com/u/10093701?v=3","gravatar_id":"","url":"https://api.github.com/users/nhs3108","html_url":"https://github.com/nhs3108","followers_url":"https://api.github.com/users/nhs3108/followers","following_url":"https://api.github.com/users/nhs3108/following{/other_user}","gists_url":"https://api.github.com/users/nhs3108/gists{/gist_id}","starred_url":"https://api.github.com/users/nhs3108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhs3108/subscriptions","organizations_url":"https://api.github.com/users/nhs3108/orgs","repos_url":"https://api.github.com/users/nhs3108/repos","events_url":"https://api.github.com/users/nhs3108/events{/privacy}","received_events_url":"https://api.github.com/users/nhs3108/received_events","type":"User","site_admin":false},"repo":{"id":48219307,"name":"hrm_3","full_name":"nhs3108/hrm_3","owner":{"login":"nhs3108","id":10093701,"avatar_url":"https://avatars.githubusercontent.com/u/10093701?v=3","gravatar_id":"","url":"https://api.github.com/users/nhs3108","html_url":"https://github.com/nhs3108","followers_url":"https://api.github.com/users/nhs3108/followers","following_url":"https://api.github.com/users/nhs3108/following{/other_user}","gists_url":"https://api.github.com/users/nhs3108/gists{/gist_id}","starred_url":"https://api.github.com/users/nhs3108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhs3108/subscriptions","organizations_url":"https://api.github.com/users/nhs3108/orgs","repos_url":"https://api.github.com/users/nhs3108/repos","events_url":"https://api.github.com/users/nhs3108/events{/privacy}","received_events_url":"https://api.github.com/users/nhs3108/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nhs3108/hrm_3","description":"Framgia Human Rsource Management (training)","fork":true,"url":"https://api.github.com/repos/nhs3108/hrm_3","forks_url":"https://api.github.com/repos/nhs3108/hrm_3/forks","keys_url":"https://api.github.com/repos/nhs3108/hrm_3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nhs3108/hrm_3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nhs3108/hrm_3/teams","hooks_url":"https://api.github.com/repos/nhs3108/hrm_3/hooks","issue_events_url":"https://api.github.com/repos/nhs3108/hrm_3/issues/events{/number}","events_url":"https://api.github.com/repos/nhs3108/hrm_3/events","assignees_url":"https://api.github.com/repos/nhs3108/hrm_3/assignees{/user}","branches_url":"https://api.github.com/repos/nhs3108/hrm_3/branches{/branch}","tags_url":"https://api.github.com/repos/nhs3108/hrm_3/tags","blobs_url":"https://api.github.com/repos/nhs3108/hrm_3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nhs3108/hrm_3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nhs3108/hrm_3/git/refs{/sha}","trees_url":"https://api.github.com/repos/nhs3108/hrm_3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nhs3108/hrm_3/statuses/{sha}","languages_url":"https://api.github.com/repos/nhs3108/hrm_3/languages","stargazers_url":"https://api.github.com/repos/nhs3108/hrm_3/stargazers","contributors_url":"https://api.github.com/repos/nhs3108/hrm_3/contributors","subscribers_url":"https://api.github.com/repos/nhs3108/hrm_3/subscribers","subscription_url":"https://api.github.com/repos/nhs3108/hrm_3/subscription","commits_url":"https://api.github.com/repos/nhs3108/hrm_3/commits{/sha}","git_commits_url":"https://api.github.com/repos/nhs3108/hrm_3/git/commits{/sha}","comments_url":"https://api.github.com/repos/nhs3108/hrm_3/comments{/number}","issue_comment_url":"https://api.github.com/repos/nhs3108/hrm_3/issues/comments{/number}","contents_url":"https://api.github.com/repos/nhs3108/hrm_3/contents/{+path}","compare_url":"https://api.github.com/repos/nhs3108/hrm_3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nhs3108/hrm_3/merges","archive_url":"https://api.github.com/repos/nhs3108/hrm_3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nhs3108/hrm_3/downloads","issues_url":"https://api.github.com/repos/nhs3108/hrm_3/issues{/number}","pulls_url":"https://api.github.com/repos/nhs3108/hrm_3/pulls{/number}","milestones_url":"https://api.github.com/repos/nhs3108/hrm_3/milestones{/number}","notifications_url":"https://api.github.com/repos/nhs3108/hrm_3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nhs3108/hrm_3/labels{/name}","releases_url":"https://api.github.com/repos/nhs3108/hrm_3/releases{/id}","created_at":"2015-12-18T06:46:54Z","updated_at":"2015-12-18T03:18:14Z","pushed_at":"2015-12-24T08:50:21Z","git_url":"git://github.com/nhs3108/hrm_3.git","ssh_url":"git@github.com:nhs3108/hrm_3.git","clone_url":"https://github.com/nhs3108/hrm_3.git","svn_url":"https://github.com/nhs3108/hrm_3","homepage":null,"size":132,"stargazers_count":0,"watchers_count":0,"language":null,"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":"framgia:master","ref":"master","sha":"23f22b63fbc807972a6bde8fc15a8350dbe6157d","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":48211939,"name":"hrm_3","full_name":"framgia/hrm_3","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/hrm_3","description":"Framgia Human Rsource Management (training)","fork":false,"url":"https://api.github.com/repos/framgia/hrm_3","forks_url":"https://api.github.com/repos/framgia/hrm_3/forks","keys_url":"https://api.github.com/repos/framgia/hrm_3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/hrm_3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/hrm_3/teams","hooks_url":"https://api.github.com/repos/framgia/hrm_3/hooks","issue_events_url":"https://api.github.com/repos/framgia/hrm_3/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/hrm_3/events","assignees_url":"https://api.github.com/repos/framgia/hrm_3/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/hrm_3/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/hrm_3/tags","blobs_url":"https://api.github.com/repos/framgia/hrm_3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/hrm_3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/hrm_3/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/hrm_3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/hrm_3/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/hrm_3/languages","stargazers_url":"https://api.github.com/repos/framgia/hrm_3/stargazers","contributors_url":"https://api.github.com/repos/framgia/hrm_3/contributors","subscribers_url":"https://api.github.com/repos/framgia/hrm_3/subscribers","subscription_url":"https://api.github.com/repos/framgia/hrm_3/subscription","commits_url":"https://api.github.com/repos/framgia/hrm_3/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/hrm_3/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/hrm_3/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/hrm_3/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/hrm_3/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/hrm_3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/hrm_3/merges","archive_url":"https://api.github.com/repos/framgia/hrm_3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/hrm_3/downloads","issues_url":"https://api.github.com/repos/framgia/hrm_3/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/hrm_3/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/hrm_3/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/hrm_3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/hrm_3/labels{/name}","releases_url":"https://api.github.com/repos/framgia/hrm_3/releases{/id}","created_at":"2015-12-18T03:18:14Z","updated_at":"2015-12-18T07:34:02Z","pushed_at":"2015-12-24T08:50:21Z","git_url":"git://github.com/framgia/hrm_3.git","ssh_url":"git@github.com:framgia/hrm_3.git","clone_url":"https://github.com/framgia/hrm_3.git","svn_url":"https://github.com/framgia/hrm_3","homepage":null,"size":122,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/hrm_3/pulls/6"},"html":{"href":"https://github.com/framgia/hrm_3/pull/6"},"issue":{"href":"https://api.github.com/repos/framgia/hrm_3/issues/6"},"comments":{"href":"https://api.github.com/repos/framgia/hrm_3/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/hrm_3/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/hrm_3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/hrm_3/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/hrm_3/statuses/296ad6872d26961ccbc85e2f07d072419043e7bf"}}}}