|
@@ -27,6 +27,8 @@ import android.widget.TextView;
|
|
|
|
|
|
|
|
|
import com.dbs.mplus.knuh.R;
|
|
|
+import com.dbs.mplus.knuh.customView.CustomAlertDialog;
|
|
|
+import com.dbs.mplus.knuh.util.ConsentConfig;
|
|
|
import com.dbs.mplus.knuh.util.Util;
|
|
|
|
|
|
|
|
@@ -36,7 +38,9 @@ public class HistoryFragment extends Fragment {
|
|
|
private AppCompatActivity mActiyivy;
|
|
|
private Context mContext;
|
|
|
|
|
|
- private DatePickerDialog dateDialog;
|
|
|
+ private DatePickerDialog leftDateDialog;
|
|
|
+ private DatePickerDialog rightDateDialog;
|
|
|
+ private CustomAlertDialog csAlert;
|
|
|
|
|
|
private LinearLayout typePatient;
|
|
|
private LinearLayout patientLeftRound;
|
|
@@ -81,6 +85,8 @@ public class HistoryFragment extends Fragment {
|
|
|
|
|
|
View view = (View) inflater.inflate(R.layout.activity_history_fragment, container, false);
|
|
|
|
|
|
+ csAlert = new CustomAlertDialog(mContext);
|
|
|
+
|
|
|
typePatient = (LinearLayout) view.findViewById(R.id.typePatient);
|
|
|
patientLeftRound = (LinearLayout) view.findViewById(R.id.patientLeftRound);
|
|
|
ivPatient = (ImageView) view.findViewById(R.id.ivPatient);
|
|
@@ -136,17 +142,74 @@ public class HistoryFragment extends Fragment {
|
|
|
int month = Integer.parseInt(Util.plusZero(Util.toDayDate()[1] - 1));
|
|
|
int day = Integer.parseInt(Util.plusZero(Util.toDayDate()[2]));
|
|
|
|
|
|
- dateDialog = new DatePickerDialog(mContext, R.style.DatePickerDialogTheme ,onDateSetListener, year, month, day);
|
|
|
+
|
|
|
+ String rightDate = Util.toDayDate()[0] + "/" + Util.plusZero(Util.toDayDate()[1]) + "/" + Util.plusZero(Util.toDayDate()[2]);
|
|
|
+ String leftDate = Util.addDate(rightDate, "yyyy/MM/dd", 0, 0, -7, 0, 0);
|
|
|
+ tvRightDate.setText(rightDate);
|
|
|
+ tvLeftDate.setText(leftDate);
|
|
|
+
|
|
|
+ leftDateDialog = new DatePickerDialog(mContext, R.style.DatePickerDialogTheme , leftDateListener, year, month, day - 7);
|
|
|
+ rightDateDialog = new DatePickerDialog(mContext, R.style.DatePickerDialogTheme , rightDateListener, year, month, day);
|
|
|
}
|
|
|
|
|
|
- private DatePickerDialog.OnDateSetListener onDateSetListener = new DatePickerDialog.OnDateSetListener() {
|
|
|
+ private DatePickerDialog.OnDateSetListener rightDateListener = new DatePickerDialog.OnDateSetListener() {
|
|
|
@Override
|
|
|
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
|
|
|
+ String m = Util.plusZero(month + 1);
|
|
|
+ String d = Util.plusZero(dayOfMonth);
|
|
|
+ String selectedDate = year + "/" + m + "/" + d;
|
|
|
+ String ymd = year + m + d; // 선택한 날짜
|
|
|
+ String leftDate = getLeftDate(); // 왼쪽 날짜
|
|
|
+ leftDate = Util.removeSlashStr(leftDate);
|
|
|
+
|
|
|
+ int ymdInt = Integer.parseInt(ymd);
|
|
|
+ int leftDateInt = Integer.parseInt(leftDate);
|
|
|
+
|
|
|
+ if (leftDateInt <= ymdInt) {
|
|
|
+ setRightDate(selectedDate);
|
|
|
+ } else {
|
|
|
+ csAlert.show();
|
|
|
+ csAlert.setContent("조회 마지막일 보다 지난 날짜로 지정될 수 없습니다.", ConsentConfig.ALERT_BTN_TYPE);
|
|
|
+ csAlert.btnConfirm2.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ csAlert.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
+ private DatePickerDialog.OnDateSetListener leftDateListener = new DatePickerDialog.OnDateSetListener() {
|
|
|
+ @Override
|
|
|
+ public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
|
|
|
+ String m = Util.plusZero(month + 1);
|
|
|
+ String d = Util.plusZero(dayOfMonth);
|
|
|
+ String selectedDate = year + "/" + m + "/" + d;
|
|
|
+ String ymd = year + m + d;
|
|
|
+ String rightDate = getRightDate();
|
|
|
+ rightDate = Util.removeSlashStr(rightDate);
|
|
|
+
|
|
|
+ int ymdInt = Integer.parseInt(ymd);
|
|
|
+ int rightDateInt = Integer.parseInt(rightDate);
|
|
|
+
|
|
|
+ if (rightDateInt >= ymdInt) {
|
|
|
+ setLeftDate(selectedDate);
|
|
|
+ } else {
|
|
|
+ csAlert.show();
|
|
|
+ csAlert.setContent("조회 시작일 보다 이전 날짜로 지정될 수 없습니다.", ConsentConfig.ALERT_BTN_TYPE);
|
|
|
+ csAlert.btnConfirm2.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ csAlert.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
+
|
|
|
private View.OnClickListener onClickListener = new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
@@ -155,8 +218,8 @@ public class HistoryFragment extends Fragment {
|
|
|
GradientDrawable writerLeftBg = (GradientDrawable) writerLeftRound.getBackground();
|
|
|
GradientDrawable writerRightBg = (GradientDrawable) writerRightRound.getBackground();
|
|
|
|
|
|
+ /** 환자별 및 작성자별 색상 변경 **/
|
|
|
if (v == typePatient) {
|
|
|
- Log.e(TAG, "v -- > " + v);
|
|
|
patientLeftBg.setColorFilter(ContextCompat.getColor(mContext, R.color.typeLeftColor), PorterDuff.Mode.SRC_ATOP);
|
|
|
patientRightBg.setColorFilter(ContextCompat.getColor(mContext, R.color.typeRightColor), PorterDuff.Mode.SRC_ATOP);
|
|
|
ivPatient.setColorFilter(ContextCompat.getColor(mContext, R.color.white), PorterDuff.Mode.SRC_ATOP);
|
|
@@ -166,8 +229,8 @@ public class HistoryFragment extends Fragment {
|
|
|
writerRightBg.setColorFilter(ContextCompat.getColor(mContext, R.color.departmentBtnColor), PorterDuff.Mode.SRC_ATOP);
|
|
|
ivWriter.setColorFilter(ContextCompat.getColor(mContext, R.color.black), PorterDuff.Mode.SRC_ATOP);
|
|
|
tvWriter.setTextColor(ContextCompat.getColor(mContext, R.color.black));
|
|
|
+
|
|
|
} else if (v == typeWriter) {
|
|
|
- Log.e(TAG, "v -- > " + v);
|
|
|
patientLeftBg.setColorFilter(ContextCompat.getColor(mContext, R.color.historyTypeColor), PorterDuff.Mode.SRC_ATOP);
|
|
|
patientRightBg.setColorFilter(ContextCompat.getColor(mContext, R.color.departmentBtnColor), PorterDuff.Mode.SRC_ATOP);
|
|
|
ivPatient.setColorFilter(ContextCompat.getColor(mContext, R.color.black), PorterDuff.Mode.SRC_ATOP);
|
|
@@ -177,11 +240,16 @@ public class HistoryFragment extends Fragment {
|
|
|
writerRightBg.setColorFilter(ContextCompat.getColor(mContext, R.color.typeRightColor), PorterDuff.Mode.SRC_ATOP);
|
|
|
ivWriter.setColorFilter(ContextCompat.getColor(mContext, R.color.white), PorterDuff.Mode.SRC_ATOP);
|
|
|
tvWriter.setTextColor(ContextCompat.getColor(mContext, R.color.white));
|
|
|
+ /** 환자별 및 작성자별 색상 변경 **/
|
|
|
+
|
|
|
+ /** DatePickerDialog **/
|
|
|
} else if (v == leftDateLayout) {
|
|
|
- dateDialog.show();
|
|
|
- } else if (v == rightDateLayout) {
|
|
|
- dateDialog.show();
|
|
|
+ leftDateDialog.show();
|
|
|
}
|
|
|
+ else if (v == rightDateLayout) {
|
|
|
+ rightDateDialog.show();
|
|
|
+
|
|
|
+ } /** DatePickerDialog **/
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -222,4 +290,22 @@ public class HistoryFragment extends Fragment {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+ private String getLeftDate() {
|
|
|
+ return tvLeftDate.getText().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setLeftDate(String date) {
|
|
|
+ tvLeftDate.setText(date);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRightDate() {
|
|
|
+ return tvRightDate.getText().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setRightDate(String date) {
|
|
|
+ tvRightDate.setText(date);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|