|
@@ -0,0 +1,196 @@
|
|
|
+package com.dbs.mplus.knuh.adapter;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.graphics.drawable.GradientDrawable;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.CheckBox;
|
|
|
+import android.widget.CompoundButton;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import androidx.annotation.NonNull;
|
|
|
+import androidx.appcompat.app.AppCompatActivity;
|
|
|
+import androidx.core.content.ContextCompat;
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
+
|
|
|
+import com.dbs.mplus.knuh.R;
|
|
|
+import com.dbs.mplus.knuh.activity.ConsentActivity;
|
|
|
+import com.dbs.mplus.knuh.consent.ConsentCreateParam;
|
|
|
+import com.dbs.mplus.knuh.consent.ConsentEvent;
|
|
|
+import com.dbs.mplus.knuh.model.ConsentFormListVO;
|
|
|
+import com.dbs.mplus.knuh.util.ConsentConfig;
|
|
|
+import com.dbs.mplus.knuh.util.Util;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
+public class ConsentTempAdapter extends RecyclerView.Adapter<ConsentTempAdapter.ViewHolder> {
|
|
|
+ private static final String TAG = "ConsentTempAdapter";
|
|
|
+ private AppCompatActivity mActivity;
|
|
|
+ private Context mContext;
|
|
|
+ private ConsentActivity instance;
|
|
|
+ public ArrayList<ConsentFormListVO> arrayList;
|
|
|
+ private ConsentEvent consentEvent;
|
|
|
+ private String userId = "";
|
|
|
+
|
|
|
+ private HashMap<Integer, Object> checkMap;
|
|
|
+
|
|
|
+ public ConsentTempAdapter(AppCompatActivity mActivity, Context mContext, ArrayList<ConsentFormListVO> arrayList) {
|
|
|
+ this.mActivity = mActivity;
|
|
|
+ this.mContext = mContext;
|
|
|
+ this.instance = (ConsentActivity) this.mContext;
|
|
|
+ this.arrayList = arrayList;
|
|
|
+ this.userId = Util.getStringPreference(mContext, "userInfo", "userId");
|
|
|
+ this.checkMap = new HashMap<Integer, Object>();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getItemCount() {
|
|
|
+ return arrayList.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ViewHolder extends RecyclerView.ViewHolder {
|
|
|
+ public RelativeLayout listLayer;
|
|
|
+ public CheckBox chkConsent;
|
|
|
+ public TextView tvConsentName;
|
|
|
+ public TextView tvPatientName;
|
|
|
+ public TextView tvTemp;
|
|
|
+ public TextView tvSubText;
|
|
|
+
|
|
|
+ public int position = 0;
|
|
|
+
|
|
|
+ public ViewHolder(@NonNull View itemView) {
|
|
|
+ super(itemView);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @NonNull
|
|
|
+ @Override
|
|
|
+ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
|
+ View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.consent_list_item, parent, false);
|
|
|
+ ViewHolder holder = new ViewHolder(view);
|
|
|
+
|
|
|
+ holder.listLayer = (RelativeLayout) view.findViewById(R.id.listLayer);
|
|
|
+ holder.chkConsent = (CheckBox) view.findViewById(R.id.chkConsent);
|
|
|
+ holder.tvConsentName = (TextView) view.findViewById(R.id.tvConsentName);
|
|
|
+ holder.tvPatientName = (TextView) view.findViewById(R.id.tvPatientName);
|
|
|
+ holder.tvTemp = (TextView) view.findViewById(R.id.tvTemp);
|
|
|
+ holder.tvSubText = (TextView) view.findViewById(R.id.tvSubText);
|
|
|
+
|
|
|
+ holder.listLayer.setTag(holder);
|
|
|
+ holder.tvSubText.setTag(holder);
|
|
|
+ holder.chkConsent.setTag(holder);
|
|
|
+ return holder;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
|
|
+ ConsentFormListVO consentFormListVO = arrayList.get(position);
|
|
|
+ String formName = consentFormListVO.getFormName();
|
|
|
+ String consentState = consentFormListVO.getConsentState();
|
|
|
+ String consentStateEng = consentFormListVO.getConsentStateEng();
|
|
|
+ String createUserId = consentFormListVO.getCreateUserId();
|
|
|
+
|
|
|
+ holder.chkConsent.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
+ GradientDrawable tvTempBg = (GradientDrawable) holder.tvTemp.getBackground().getCurrent();
|
|
|
+ GradientDrawable tvSubBg = (GradientDrawable) holder.tvSubText.getBackground().getCurrent();
|
|
|
+
|
|
|
+ if (consentStateEng.equals(ConsentConfig.TEMP)) {
|
|
|
+ tvTempBg.setColor(ContextCompat.getColor(mContext, R.color.tempColor));
|
|
|
+ tvSubBg.setColor(ContextCompat.getColor(mContext, R.color.tempColor));
|
|
|
+ } else if (consentStateEng.equals(ConsentConfig.UNFINISHED)) {
|
|
|
+ tvTempBg.setColor(ContextCompat.getColor(mContext, R.color.tempColor));
|
|
|
+ tvSubBg.setColor(ContextCompat.getColor(mContext, R.color.tempColor));
|
|
|
+ }else if (consentStateEng.equals(ConsentConfig.ELECTR_CMP)) {
|
|
|
+ tvTempBg.setColor(ContextCompat.getColor(mContext, R.color.typeRightColor));
|
|
|
+ tvSubBg.setColor(ContextCompat.getColor(mContext, R.color.typeRightColor));
|
|
|
+ }
|
|
|
+
|
|
|
+ holder.tvPatientName.setVisibility(View.GONE);
|
|
|
+ holder.tvTemp.setText(consentState);
|
|
|
+
|
|
|
+ if (createUserId.equals(userId)) {
|
|
|
+ holder.tvTemp.setVisibility(View.VISIBLE);
|
|
|
+ holder.tvSubText.setText(mContext.getString(R.string.delete));
|
|
|
+ tvSubBg.setColor(ContextCompat.getColor(mContext, R.color.alertColor));
|
|
|
+// holder.tvSubText.setOnClickListener(onClickListener);
|
|
|
+ } else if (consentStateEng.equals(ConsentConfig.UNFINISHED)) {
|
|
|
+ holder.tvTemp.setVisibility(View.VISIBLE);
|
|
|
+ holder.tvSubText.setText(mContext.getString(R.string.delete));
|
|
|
+ tvSubBg.setColor(ContextCompat.getColor(mContext, R.color.alertColor));
|
|
|
+// holder.tvSubText.setOnClickListener(onClickListener);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ holder.tvTemp.setVisibility(View.GONE);
|
|
|
+ holder.tvSubText.setText(consentState);
|
|
|
+ }
|
|
|
+
|
|
|
+ holder.chkConsent.setChecked(false);
|
|
|
+ holder.tvConsentName.setText(formName);
|
|
|
+
|
|
|
+ holder.chkConsent.setOnCheckedChangeListener(onCheckedChangeListener);
|
|
|
+ holder.listLayer.setOnClickListener(onClickListener);
|
|
|
+ }
|
|
|
+
|
|
|
+ private View.OnClickListener onClickListener = new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ ViewHolder holder = (ViewHolder) v.getTag();
|
|
|
+ final int position = holder.getLayoutPosition();
|
|
|
+ ConsentFormListVO consentFormListVO = arrayList.get(position);
|
|
|
+
|
|
|
+ consentEvent = new ConsentEvent(mContext, instance, consentFormListVO);
|
|
|
+ if (checkMap.size() == 0) {
|
|
|
+ consentEvent.consentOpenProc(instance.centerMenu.patientInfoVO, "centerTemp");
|
|
|
+
|
|
|
+ ConsentHistoryAdapter adapter = (ConsentHistoryAdapter) instance.history.historyWriteRecyclerView.getAdapter();
|
|
|
+ if (adapter != null) {
|
|
|
+ adapter.arrayList.clear();
|
|
|
+ adapter = null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ConsentCreateParam consentCreateParam = new ConsentCreateParam(mContext);
|
|
|
+ for (int key : checkMap.keySet()) {
|
|
|
+ Log.e(TAG, "key -- > " + key);
|
|
|
+ ConsentFormListVO consentFormVO = arrayList.get(position);
|
|
|
+ String consentMstRid = consentFormVO.getConsentMstRid();
|
|
|
+ String formRid = consentFormVO.getFormRid();
|
|
|
+ String guid = consentFormVO.getFormGuid();
|
|
|
+ String formPrntNm = consentFormVO.getFormPrntNm();
|
|
|
+ String linkCd = consentFormVO.getLinkFormCd();
|
|
|
+ String ocrTag = consentFormVO.getOcrTag();
|
|
|
+ String userDrFlag = consentFormVO.getUserDrFlag();
|
|
|
+ String consentState = consentFormVO.getConsentState();
|
|
|
+ String consentStateEng = consentFormVO.getConsentStateEng();
|
|
|
+
|
|
|
+
|
|
|
+ HashMap<String, String> globalParam = consentCreateParam.setGlobalParam(instance.centerMenu.patientInfoVO, consentMstRid, consentFormListVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ private CheckBox.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ ViewHolder holder = (ViewHolder) buttonView.getTag();
|
|
|
+ final int position = holder.getLayoutPosition();
|
|
|
+ ConsentFormListVO consentFormListVO = arrayList.get(position);
|
|
|
+ String consentMstRid = consentFormListVO.getConsentMstRid();
|
|
|
+
|
|
|
+ Log.e(TAG, "position -- > " + position);
|
|
|
+ Log.e(TAG, "isChecked -- > " + isChecked);
|
|
|
+ if (isChecked == true) {
|
|
|
+ checkMap.put(position, consentMstRid);
|
|
|
+ } else {
|
|
|
+ checkMap.remove(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+}
|