|
@@ -2,7 +2,6 @@ package com.dbs.dbsec.activity.fragment;
|
|
|
|
|
|
import android.content.Context;
|
|
|
import android.os.Bundle;
|
|
|
-import android.telecom.Call;
|
|
|
import android.util.Log;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.LayoutInflater;
|
|
@@ -19,9 +18,11 @@ import com.dbs.dbsec.BuildConfig;
|
|
|
import com.dbs.dbsec.R;
|
|
|
import com.dbs.dbsec.activity.ConsentActivity;
|
|
|
import com.dbs.dbsec.activity.adapter.CategoryAdapter;
|
|
|
+import com.dbs.dbsec.activity.adapter.ConsentListAdapter;
|
|
|
import com.dbs.dbsec.httpTask.CallBack;
|
|
|
import com.dbs.dbsec.httpTask.ParseJsonData;
|
|
|
import com.dbs.dbsec.model.CategoryVO;
|
|
|
+import com.dbs.dbsec.model.ConsentFormListVO;
|
|
|
import com.dbs.dbsec.util.Common;
|
|
|
import com.dbs.dbsec.util.ConsentConfig;
|
|
|
|
|
@@ -44,7 +45,7 @@ public class SearchFragment extends Fragment {
|
|
|
private ConsentActivity instance;
|
|
|
|
|
|
private CategoryAdapter categoryAdapter;
|
|
|
-// private ConsentListAdapter consentListAdapter;
|
|
|
+ private ConsentListAdapter consentListAdapter;
|
|
|
|
|
|
private LinearLayoutManager linearLayoutManager;
|
|
|
private LinearLayout searchClickLayout;
|
|
@@ -52,7 +53,7 @@ public class SearchFragment extends Fragment {
|
|
|
|
|
|
private Spinner searchDeptSpinner;
|
|
|
private TextView tvHospitalName;
|
|
|
- private EditText etPatientId;
|
|
|
+ private EditText etKeyWord;
|
|
|
private TextView tvEmptySearchConsent;
|
|
|
|
|
|
private String categoryId = "";
|
|
@@ -81,43 +82,43 @@ public class SearchFragment extends Fragment {
|
|
|
|
|
|
searchDeptSpinner = (Spinner) view.findViewById(R.id.searchDeptSpinner);
|
|
|
tvHospitalName = (TextView) view.findViewById(R.id.tvHospitalName);
|
|
|
- etPatientId = (EditText) view.findViewById(R.id.etPatientId);
|
|
|
+ etKeyWord = (EditText) view.findViewById(R.id.etKeyWord);
|
|
|
searchClickLayout = (LinearLayout) view.findViewById(R.id.searchClickLayout);
|
|
|
searchRecyclerView = (RecyclerView) view.findViewById(R.id.searchRecyclerView);
|
|
|
tvEmptySearchConsent = (TextView) view.findViewById(R.id.tvEmptySearchConsent);
|
|
|
|
|
|
getCategoryList(BuildConfig.INST_CD);
|
|
|
|
|
|
-// setEvent();
|
|
|
+ setEvent();
|
|
|
|
|
|
return view;
|
|
|
}
|
|
|
|
|
|
-// private void setEvent() {
|
|
|
-// searchClickLayout.setOnClickListener(onClickListener);
|
|
|
-// etPatientId.setOnEditorActionListener(onEditorActionListener);
|
|
|
-// }
|
|
|
-
|
|
|
-// private View.OnClickListener onClickListener = new View.OnClickListener() {
|
|
|
-// @Override
|
|
|
-// public void onClick(View v) {
|
|
|
-// if (v == searchClickLayout) {
|
|
|
-// getConsentList(categoryId);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// };
|
|
|
-//
|
|
|
-// public EditText.OnEditorActionListener onEditorActionListener = new EditText.OnEditorActionListener() {
|
|
|
-// @Override
|
|
|
-// public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
-// if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT) {
|
|
|
-// if (v == etPatientId) {
|
|
|
-// getConsentList(categoryId);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// };
|
|
|
+ private void setEvent() {
|
|
|
+ searchClickLayout.setOnClickListener(onClickListener);
|
|
|
+ etKeyWord.setOnEditorActionListener(onEditorActionListener);
|
|
|
+ }
|
|
|
+
|
|
|
+ private View.OnClickListener onClickListener = new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (v == searchClickLayout) {
|
|
|
+ getConsentBySearch(categoryId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ public EditText.OnEditorActionListener onEditorActionListener = new EditText.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT) {
|
|
|
+ if (v == etKeyWord) {
|
|
|
+ getConsentBySearch(categoryId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
/** Spinner List API **/
|
|
|
/**
|
|
@@ -173,7 +174,6 @@ public class SearchFragment extends Fragment {
|
|
|
instance.showProgress();
|
|
|
Common.callHttp(mContext, ConsentConfig.GET_CATEGORY_LIST, mData, callBack);
|
|
|
} else {
|
|
|
- instance.dismissProgress();
|
|
|
Common.networkErrorAlert(mActivity);
|
|
|
}
|
|
|
}
|
|
@@ -207,70 +207,73 @@ public class SearchFragment extends Fragment {
|
|
|
* @author jksong
|
|
|
* @since 2020-01-28 오후 5:03
|
|
|
**/
|
|
|
-// private void getConsentList(String categoryId) {
|
|
|
-// CallBack callBack = new CallBack() {
|
|
|
-// @Override
|
|
|
-// public void result(final SoapObject result) {
|
|
|
-//
|
|
|
-// mActivity.runOnUiThread(new Runnable() {
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// instance.dismissProgress();
|
|
|
-// if (result == null || result.toString().indexOf("null") > 0 || result.getPropertyCount() == 0) {
|
|
|
-// tvEmptySearchConsent.setVisibility(View.VISIBLE);
|
|
|
-//
|
|
|
-// if (consentListAdapter != null) {
|
|
|
-// consentListAdapter.arrayList.clear();
|
|
|
-// consentListAdapter.notifyDataSetChanged();
|
|
|
-// }
|
|
|
-//
|
|
|
-// } else {
|
|
|
-// tvEmptySearchConsent.setVisibility(View.GONE);
|
|
|
-// ArrayList<ConsentFormListVO> arrayList = SoapParser.getConsentList(result);
|
|
|
-// setConsentAdapter(arrayList);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// });
|
|
|
-//
|
|
|
-// }
|
|
|
-// @Override
|
|
|
-// public void stop() {
|
|
|
-// }
|
|
|
-// @Override
|
|
|
-// public void error() {
|
|
|
-//
|
|
|
-// }
|
|
|
-// };
|
|
|
-//
|
|
|
-// if ((categoryId.equals("EMA_031") || categoryId.equals("EMA_032")) && etPatientId.getText().toString().trim().equals("")) {
|
|
|
-//// categoryNotSelected
|
|
|
-// instance.showSingButtonDialog(mContext.getString(R.string.categoryNotSelected));
|
|
|
-// } else {
|
|
|
-// instance.showProgress();
|
|
|
-// HashMap<String, String> mData = new HashMap<String, String>();
|
|
|
-// mData.put("instCd", BuildConfig.INST_CD);
|
|
|
-// mData.put("keyWord", etPatientId.getText().toString().trim());
|
|
|
-// mData.put("categoryId", categoryId);
|
|
|
-//
|
|
|
-// if (Util.checkNetwork(mContext) == true) {
|
|
|
-// Util.callHttp(mContext, ConsentConfig.HOST_CONSENT, ConsentConfig.GET_CONSENT_SEARCH, mData, callBack);
|
|
|
-// } else {
|
|
|
-// instance.dismissProgress();
|
|
|
-// Util.networkErrorAlert(mActivity);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// private void setConsentAdapter(final ArrayList<ConsentFormListVO> arrayList) {
|
|
|
-// if (consentListAdapter == null) {
|
|
|
-// linearLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
|
|
|
-// searchRecyclerView.setLayoutManager(linearLayoutManager);
|
|
|
-// consentListAdapter = new ConsentListAdapter(mActivity, mContext, arrayList, ConsentConfig.GET_CONSENT_SEARCH);
|
|
|
-// searchRecyclerView.setAdapter(consentListAdapter);
|
|
|
-// } else {
|
|
|
-// consentListAdapter.arrayList = arrayList;
|
|
|
-// consentListAdapter.notifyDataSetChanged();
|
|
|
-// }
|
|
|
-// }
|
|
|
+ private void getConsentBySearch(String categoryId) {
|
|
|
+ CallBack callBack = new CallBack() {
|
|
|
+ @Override
|
|
|
+ public void result(final String result) {
|
|
|
+ Log.e(TAG, "getConsentBySearch -- > " + result);
|
|
|
+ mActivity.runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ instance.dismissProgress();
|
|
|
+ ArrayList<HashMap<String, String>> arrayList = Common.parseJSON(mContext, result);
|
|
|
+ String code = arrayList.get(0).get("code");
|
|
|
+
|
|
|
+ if (!code.equals("00")) {
|
|
|
+ stop();
|
|
|
+ } else {
|
|
|
+ tvEmptySearchConsent.setVisibility(View.GONE);
|
|
|
+ ArrayList<ConsentFormListVO> consentArr = ParseJsonData.getInstance(mContext).getConsentFormList(arrayList);
|
|
|
+ setConsentAdapter(consentArr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+ tvEmptySearchConsent.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
+ if (consentListAdapter != null) {
|
|
|
+ consentListAdapter.arrayList.clear();
|
|
|
+ consentListAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void error() {
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ if (categoryId.equals("1") && etKeyWord.getText().toString().trim().equals("")) {
|
|
|
+// categoryNotSelected
|
|
|
+ instance.showSingButtonDialog(mContext.getString(R.string.categoryNotSelected));
|
|
|
+ } else {
|
|
|
+ instance.showProgress();
|
|
|
+ HashMap<String, String> mData = new HashMap<String, String>();
|
|
|
+ mData.put("instCd", BuildConfig.INST_CD);
|
|
|
+ mData.put("keyWord", etKeyWord.getText().toString().trim());
|
|
|
+ mData.put("categoryId", categoryId);
|
|
|
+
|
|
|
+ if (Common.checkNetwork(mContext) == true) {
|
|
|
+ Common.callHttp(mContext, ConsentConfig.GET_CONSENT_BY_SEARCH, mData, callBack);
|
|
|
+ } else {
|
|
|
+ instance.dismissProgress();
|
|
|
+ Common.networkErrorAlert(mActivity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setConsentAdapter(final ArrayList<ConsentFormListVO> arrayList) {
|
|
|
+ if (consentListAdapter == null) {
|
|
|
+ linearLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
|
|
|
+ searchRecyclerView.setLayoutManager(linearLayoutManager);
|
|
|
+ consentListAdapter = new ConsentListAdapter(mActivity, mContext, arrayList, ConsentConfig.GET_CONSENT_BY_SEARCH);
|
|
|
+ searchRecyclerView.setAdapter(consentListAdapter);
|
|
|
+ } else {
|
|
|
+ consentListAdapter.arrayList = arrayList;
|
|
|
+ consentListAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|