{"action":"created","comment":{"url":"https://api.github.com/repos/hieumai/cura/pulls/comments/73469073","id":73469073,"diff_hunk":"@@ -0,0 +1,229 @@\n+package com.kms.cura.view;\n+\n+import android.app.ActionBar;\n+import android.content.Context;\n+import android.os.Bundle;\n+import android.support.v4.content.ContextCompat;\n+import android.support.v4.widget.NestedScrollView;\n+import android.view.LayoutInflater;\n+import android.view.MotionEvent;\n+import android.view.View;\n+import android.view.ViewGroup;\n+import android.widget.LinearLayout;\n+import android.widget.ScrollView;\n+import android.widget.TextView;\n+\n+import com.kms.cura.R;\n+import com.kms.cura.entity.AppointmentEntity;\n+import com.kms.cura.entity.user.DoctorUserEntity;\n+import com.kms.cura.utils.CurrentUserProfile;\n+\n+import java.sql.Time;\n+import java.text.SimpleDateFormat;\n+import java.util.ArrayList;\n+import java.util.Calendar;\n+import java.util.Date;\n+import java.util.List;\n+import java.util.Locale;\n+\n+/**\n+ * Created by linhtnvo on 8/2/2016.\n+ */\n+public class DoctorApptDayView implements View.OnClickListener{\n+    public static long MILISECOND_OF_DAY = 86400000;\n+    private static long MILISECOND = 60000;\n+    private LinearLayout layoutDayView;\n+    private ScrollView scrollView;\n+    private int green, lightGrey, lightGrey2, grey, yellow, blue;\n+    private int length;\n+    private Context mContext;\n+    private String title;\n+    private Date date;\n+    private float downY = 0;\n+    private float upY = 0;\n+    private List<AppointmentEntity> apptList;\n+    private LayoutInflater inflater;\n+    private String[] timeFrame;\n+    private List<View> viewList;\n+\n+    public DoctorApptDayView(Context mContext, Date date) {\n+        this.mContext = mContext;\n+        this.date = date;\n+    }\n+\n+    public View createView(){\n+        inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n+        final View root = inflater.inflate(R.layout.day_view_layout, null);\n+        layoutDayView = (LinearLayout) root.findViewById(R.id.layoutDayView);\n+        scrollView = (ScrollView) root.findViewById(R.id.scrollview);\n+        getData();\n+        createTimeFrame();\n+        markTheApptTime();\n+        scrollView.removeAllViews();\n+        scrollView.addView(layoutDayView);\n+        return root;\n+    }\n+\n+\n+    public void getData() {\n+        title = getSelectedDate();\n+        apptList = getApptByDate(((DoctorUserEntity)CurrentUserProfile.getInstance().getEntity()).getAppointmentList(),date );\n+    }\n+\n+    public String getSelectedDate() {\n+        Calendar calendar = Calendar.getInstance();\n+        calendar.setTime(date);\n+        String dayOftheWeek = calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault());\n+        SimpleDateFormat month_date = new SimpleDateFormat(\"MMMM\");\n+        String month_name = month_date.format(calendar.getTime());\n+        StringBuilder builder = new StringBuilder();\n+        builder.append(dayOftheWeek);\n+        builder.append(\", \");\n+        builder.append(month_name);\n+        builder.append(\" \");\n+        builder.append(calendar.get(Calendar.DAY_OF_MONTH));\n+        builder.append(\", \");\n+        builder.append(calendar.get(Calendar.YEAR));\n+        return builder.toString();\n+    }\n+\n+\n+    private void createTimeFrame() {\n+        getColor();\n+        getTimeSpan();\n+        viewList = new ArrayList<>();\n+        for (int i = 0; i < length; ++i) {\n+            layoutDayView.addView(createTimeView(i));\n+        }\n+        if (layoutDayView.getParent() != null) {\n+            ((ViewGroup) layoutDayView.getParent()).removeView(layoutDayView);\n+        }\n+    }\n+\n+    private void markTheApptTime(){\n+        List<AppointmentEntity> appointments = ((DoctorUserEntity)CurrentUserProfile.getInstance().getEntity()).getAppointmentList();\n+        for (AppointmentEntity entity : apptList){\n+            Time start = entity.getStartTime();\n+            Time end = entity.getEndTime();\n+            int startPos = getpositionTime(start);\n+            long timeDif = (end.getTime() - start.getTime())/MILISECOND;\n+            int gap = (int) (timeDif/30);\n+            int color = colorTheAppt(entity);\n+            for (int i=0; i<gap; ++i){\n+                View v = viewList.get(i+startPos);\n+                v.setBackgroundColor(color);\n+                v.setTag(appointments.indexOf(entity));\n+                v.setOnClickListener(this);\n+            }\n+            setInfo(gap, startPos, entity);\n+        }\n+    }\n+\n+    private void setInfo(int gap, int startPos, AppointmentEntity entity){\n+        StringBuilder builder = new StringBuilder();\n+        String pName = entity.getPatientUserEntity().getName();\n+        String time = getApptTime(entity.getStartTime(), entity.getEndTime());\n+        TextView patientName = (TextView) viewList.get(startPos);\n+        if (gap == 1) {\n+            builder.append(pName);\n+            builder.append(\"\\n\");\n+            builder.append(time);\n+            patientName.setText(builder.toString());\n+        }\n+        else{\n+            TextView txtTime = (TextView) viewList.get(startPos + 1);\n+            patientName.setText(pName);\n+            txtTime.setText(time);\n+        }\n+\n+    }\n+\n+    private String getApptTime(Time start, Time end){\n+        StringBuilder builder = new StringBuilder();\n+        builder.append(start.toString().substring(0,5));\n+        builder.append(\"-\");\n+        builder.append(end.toString().substring(0,5));\n+        return builder.toString();\n+    }\n+\n+\n+\n+    private Integer colorTheAppt(AppointmentEntity entity){\n+        switch (entity.getStatus()){\n+            case AppointmentEntity.ACCEPTED_STT:\n+                return blue;\n+            case AppointmentEntity.DOCTOR_CANCEL_STT:\n+                return grey;\n+            case AppointmentEntity.INCOMPLETED_STT:\n+                return yellow;\n+            case AppointmentEntity.COMPLETED_STT:\n+                return green;\n+        }\n+        return null;\n+    }\n+\n+    private int getpositionTime(Time src) {\n+        int position = 0;\n+        Calendar calendar = Calendar.getInstance();\n+        calendar.setTime(src);\n+        int hour = calendar.get(Calendar.HOUR_OF_DAY);\n+        int min = calendar.get(Calendar.MINUTE);\n+        position = hour * 2;\n+        if (min == 30) {\n+            position += 1;\n+        } else if (min > 30) {","path":"app/src/main/java/com/kms/cura/view/DoctorApptDayVIew.java","position":174,"original_position":174,"commit_id":"412555b283cab6fc9a6f26768d96e35f50d6b834","original_commit_id":"412555b283cab6fc9a6f26768d96e35f50d6b834","user":{"login":"hieumai","id":13411454,"avatar_url":"https://avatars.githubusercontent.com/u/13411454?v=3","gravatar_id":"","url":"https://api.github.com/users/hieumai","html_url":"https://github.com/hieumai","followers_url":"https://api.github.com/users/hieumai/followers","following_url":"https://api.github.com/users/hieumai/following{/other_user}","gists_url":"https://api.github.com/users/hieumai/gists{/gist_id}","starred_url":"https://api.github.com/users/hieumai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hieumai/subscriptions","organizations_url":"https://api.github.com/users/hieumai/orgs","repos_url":"https://api.github.com/users/hieumai/repos","events_url":"https://api.github.com/users/hieumai/events{/privacy}","received_events_url":"https://api.github.com/users/hieumai/received_events","type":"User","site_admin":false},"body":"What is 30 ? Make it constant","created_at":"2016-08-04T06:41:10Z","updated_at":"2016-08-04T06:41:10Z","html_url":"https://github.com/hieumai/cura/pull/85#discussion_r73469073","pull_request_url":"https://api.github.com/repos/hieumai/cura/pulls/85","_links":{"self":{"href":"https://api.github.com/repos/hieumai/cura/pulls/comments/73469073"},"html":{"href":"https://github.com/hieumai/cura/pull/85#discussion_r73469073"},"pull_request":{"href":"https://api.github.com/repos/hieumai/cura/pulls/85"}}},"pull_request":{"url":"https://api.github.com/repos/hieumai/cura/pulls/85","id":79883513,"html_url":"https://github.com/hieumai/cura/pull/85","diff_url":"https://github.com/hieumai/cura/pull/85.diff","patch_url":"https://github.com/hieumai/cura/pull/85.patch","issue_url":"https://api.github.com/repos/hieumai/cura/issues/85","number":85,"state":"open","locked":false,"title":"KATI_45-Doctor-Appt-Day-View-Feature","user":{"login":"vtnlinh95","id":19550311,"avatar_url":"https://avatars.githubusercontent.com/u/19550311?v=3","gravatar_id":"","url":"https://api.github.com/users/vtnlinh95","html_url":"https://github.com/vtnlinh95","followers_url":"https://api.github.com/users/vtnlinh95/followers","following_url":"https://api.github.com/users/vtnlinh95/following{/other_user}","gists_url":"https://api.github.com/users/vtnlinh95/gists{/gist_id}","starred_url":"https://api.github.com/users/vtnlinh95/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtnlinh95/subscriptions","organizations_url":"https://api.github.com/users/vtnlinh95/orgs","repos_url":"https://api.github.com/users/vtnlinh95/repos","events_url":"https://api.github.com/users/vtnlinh95/events{/privacy}","received_events_url":"https://api.github.com/users/vtnlinh95/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-03T10:34:10Z","updated_at":"2016-08-04T06:41:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf19fdcda79bef9d82dffd434557d4bf0f921f7f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hieumai/cura/pulls/85/commits","review_comments_url":"https://api.github.com/repos/hieumai/cura/pulls/85/comments","review_comment_url":"https://api.github.com/repos/hieumai/cura/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hieumai/cura/issues/85/comments","statuses_url":"https://api.github.com/repos/hieumai/cura/statuses/412555b283cab6fc9a6f26768d96e35f50d6b834","head":{"label":"hieumai:KATI-45_Doctor_Appt-Day_View-Feature","ref":"KATI-45_Doctor_Appt-Day_View-Feature","sha":"412555b283cab6fc9a6f26768d96e35f50d6b834","user":{"login":"hieumai","id":13411454,"avatar_url":"https://avatars.githubusercontent.com/u/13411454?v=3","gravatar_id":"","url":"https://api.github.com/users/hieumai","html_url":"https://github.com/hieumai","followers_url":"https://api.github.com/users/hieumai/followers","following_url":"https://api.github.com/users/hieumai/following{/other_user}","gists_url":"https://api.github.com/users/hieumai/gists{/gist_id}","starred_url":"https://api.github.com/users/hieumai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hieumai/subscriptions","organizations_url":"https://api.github.com/users/hieumai/orgs","repos_url":"https://api.github.com/users/hieumai/repos","events_url":"https://api.github.com/users/hieumai/events{/privacy}","received_events_url":"https://api.github.com/users/hieumai/received_events","type":"User","site_admin":false},"repo":{"id":59467894,"name":"cura","full_name":"hieumai/cura","owner":{"login":"hieumai","id":13411454,"avatar_url":"https://avatars.githubusercontent.com/u/13411454?v=3","gravatar_id":"","url":"https://api.github.com/users/hieumai","html_url":"https://github.com/hieumai","followers_url":"https://api.github.com/users/hieumai/followers","following_url":"https://api.github.com/users/hieumai/following{/other_user}","gists_url":"https://api.github.com/users/hieumai/gists{/gist_id}","starred_url":"https://api.github.com/users/hieumai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hieumai/subscriptions","organizations_url":"https://api.github.com/users/hieumai/orgs","repos_url":"https://api.github.com/users/hieumai/repos","events_url":"https://api.github.com/users/hieumai/events{/privacy}","received_events_url":"https://api.github.com/users/hieumai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hieumai/cura","description":"","fork":false,"url":"https://api.github.com/repos/hieumai/cura","forks_url":"https://api.github.com/repos/hieumai/cura/forks","keys_url":"https://api.github.com/repos/hieumai/cura/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hieumai/cura/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hieumai/cura/teams","hooks_url":"https://api.github.com/repos/hieumai/cura/hooks","issue_events_url":"https://api.github.com/repos/hieumai/cura/issues/events{/number}","events_url":"https://api.github.com/repos/hieumai/cura/events","assignees_url":"https://api.github.com/repos/hieumai/cura/assignees{/user}","branches_url":"https://api.github.com/repos/hieumai/cura/branches{/branch}","tags_url":"https://api.github.com/repos/hieumai/cura/tags","blobs_url":"https://api.github.com/repos/hieumai/cura/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hieumai/cura/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hieumai/cura/git/refs{/sha}","trees_url":"https://api.github.com/repos/hieumai/cura/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hieumai/cura/statuses/{sha}","languages_url":"https://api.github.com/repos/hieumai/cura/languages","stargazers_url":"https://api.github.com/repos/hieumai/cura/stargazers","contributors_url":"https://api.github.com/repos/hieumai/cura/contributors","subscribers_url":"https://api.github.com/repos/hieumai/cura/subscribers","subscription_url":"https://api.github.com/repos/hieumai/cura/subscription","commits_url":"https://api.github.com/repos/hieumai/cura/commits{/sha}","git_commits_url":"https://api.github.com/repos/hieumai/cura/git/commits{/sha}","comments_url":"https://api.github.com/repos/hieumai/cura/comments{/number}","issue_comment_url":"https://api.github.com/repos/hieumai/cura/issues/comments{/number}","contents_url":"https://api.github.com/repos/hieumai/cura/contents/{+path}","compare_url":"https://api.github.com/repos/hieumai/cura/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hieumai/cura/merges","archive_url":"https://api.github.com/repos/hieumai/cura/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hieumai/cura/downloads","issues_url":"https://api.github.com/repos/hieumai/cura/issues{/number}","pulls_url":"https://api.github.com/repos/hieumai/cura/pulls{/number}","milestones_url":"https://api.github.com/repos/hieumai/cura/milestones{/number}","notifications_url":"https://api.github.com/repos/hieumai/cura/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hieumai/cura/labels{/name}","releases_url":"https://api.github.com/repos/hieumai/cura/releases{/id}","deployments_url":"https://api.github.com/repos/hieumai/cura/deployments","created_at":"2016-05-23T09:02:18Z","updated_at":"2016-05-24T04:22:09Z","pushed_at":"2016-08-04T02:59:12Z","git_url":"git://github.com/hieumai/cura.git","ssh_url":"git@github.com:hieumai/cura.git","clone_url":"https://github.com/hieumai/cura.git","svn_url":"https://github.com/hieumai/cura","homepage":null,"size":1242,"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":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"hieumai:master","ref":"master","sha":"1fee5f291a3f28519c7e8207d2619c28330daa80","user":{"login":"hieumai","id":13411454,"avatar_url":"https://avatars.githubusercontent.com/u/13411454?v=3","gravatar_id":"","url":"https://api.github.com/users/hieumai","html_url":"https://github.com/hieumai","followers_url":"https://api.github.com/users/hieumai/followers","following_url":"https://api.github.com/users/hieumai/following{/other_user}","gists_url":"https://api.github.com/users/hieumai/gists{/gist_id}","starred_url":"https://api.github.com/users/hieumai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hieumai/subscriptions","organizations_url":"https://api.github.com/users/hieumai/orgs","repos_url":"https://api.github.com/users/hieumai/repos","events_url":"https://api.github.com/users/hieumai/events{/privacy}","received_events_url":"https://api.github.com/users/hieumai/received_events","type":"User","site_admin":false},"repo":{"id":59467894,"name":"cura","full_name":"hieumai/cura","owner":{"login":"hieumai","id":13411454,"avatar_url":"https://avatars.githubusercontent.com/u/13411454?v=3","gravatar_id":"","url":"https://api.github.com/users/hieumai","html_url":"https://github.com/hieumai","followers_url":"https://api.github.com/users/hieumai/followers","following_url":"https://api.github.com/users/hieumai/following{/other_user}","gists_url":"https://api.github.com/users/hieumai/gists{/gist_id}","starred_url":"https://api.github.com/users/hieumai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hieumai/subscriptions","organizations_url":"https://api.github.com/users/hieumai/orgs","repos_url":"https://api.github.com/users/hieumai/repos","events_url":"https://api.github.com/users/hieumai/events{/privacy}","received_events_url":"https://api.github.com/users/hieumai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hieumai/cura","description":"","fork":false,"url":"https://api.github.com/repos/hieumai/cura","forks_url":"https://api.github.com/repos/hieumai/cura/forks","keys_url":"https://api.github.com/repos/hieumai/cura/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hieumai/cura/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hieumai/cura/teams","hooks_url":"https://api.github.com/repos/hieumai/cura/hooks","issue_events_url":"https://api.github.com/repos/hieumai/cura/issues/events{/number}","events_url":"https://api.github.com/repos/hieumai/cura/events","assignees_url":"https://api.github.com/repos/hieumai/cura/assignees{/user}","branches_url":"https://api.github.com/repos/hieumai/cura/branches{/branch}","tags_url":"https://api.github.com/repos/hieumai/cura/tags","blobs_url":"https://api.github.com/repos/hieumai/cura/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hieumai/cura/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hieumai/cura/git/refs{/sha}","trees_url":"https://api.github.com/repos/hieumai/cura/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hieumai/cura/statuses/{sha}","languages_url":"https://api.github.com/repos/hieumai/cura/languages","stargazers_url":"https://api.github.com/repos/hieumai/cura/stargazers","contributors_url":"https://api.github.com/repos/hieumai/cura/contributors","subscribers_url":"https://api.github.com/repos/hieumai/cura/subscribers","subscription_url":"https://api.github.com/repos/hieumai/cura/subscription","commits_url":"https://api.github.com/repos/hieumai/cura/commits{/sha}","git_commits_url":"https://api.github.com/repos/hieumai/cura/git/commits{/sha}","comments_url":"https://api.github.com/repos/hieumai/cura/comments{/number}","issue_comment_url":"https://api.github.com/repos/hieumai/cura/issues/comments{/number}","contents_url":"https://api.github.com/repos/hieumai/cura/contents/{+path}","compare_url":"https://api.github.com/repos/hieumai/cura/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hieumai/cura/merges","archive_url":"https://api.github.com/repos/hieumai/cura/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hieumai/cura/downloads","issues_url":"https://api.github.com/repos/hieumai/cura/issues{/number}","pulls_url":"https://api.github.com/repos/hieumai/cura/pulls{/number}","milestones_url":"https://api.github.com/repos/hieumai/cura/milestones{/number}","notifications_url":"https://api.github.com/repos/hieumai/cura/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hieumai/cura/labels{/name}","releases_url":"https://api.github.com/repos/hieumai/cura/releases{/id}","deployments_url":"https://api.github.com/repos/hieumai/cura/deployments","created_at":"2016-05-23T09:02:18Z","updated_at":"2016-05-24T04:22:09Z","pushed_at":"2016-08-04T02:59:12Z","git_url":"git://github.com/hieumai/cura.git","ssh_url":"git@github.com:hieumai/cura.git","clone_url":"https://github.com/hieumai/cura.git","svn_url":"https://github.com/hieumai/cura","homepage":null,"size":1242,"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":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hieumai/cura/pulls/85"},"html":{"href":"https://github.com/hieumai/cura/pull/85"},"issue":{"href":"https://api.github.com/repos/hieumai/cura/issues/85"},"comments":{"href":"https://api.github.com/repos/hieumai/cura/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/hieumai/cura/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/hieumai/cura/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hieumai/cura/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/hieumai/cura/statuses/412555b283cab6fc9a6f26768d96e35f50d6b834"}}}}
{"actor":{"display_login":"hieumai"}}