|
@@ -5,23 +5,52 @@ import androidx.annotation.Nullable;
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
|
|
+import android.content.Context;
|
|
|
import android.os.Bundle;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.Spinner;
|
|
|
|
|
|
+import com.dbs.mplus.knuh.BuildConfig;
|
|
|
import com.dbs.mplus.knuh.R;
|
|
|
+import com.dbs.mplus.knuh.adapter.CategoryAdapter;
|
|
|
+import com.dbs.mplus.knuh.httpTask.CallBack;
|
|
|
+import com.dbs.mplus.knuh.httpTask.SoapParser;
|
|
|
+import com.dbs.mplus.knuh.model.CategoryVO;
|
|
|
+import com.dbs.mplus.knuh.util.ConsentConfig;
|
|
|
+import com.dbs.mplus.knuh.util.Util;
|
|
|
+
|
|
|
+import org.ksoap2.serialization.SoapObject;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
public class SearchFragment extends Fragment {
|
|
|
|
|
|
- public SearchFragment() {
|
|
|
+ private static final String TAG = "SearchFragment";
|
|
|
+
|
|
|
+ private AppCompatActivity mActivity;
|
|
|
+ private Context mContext;
|
|
|
|
|
|
+ private CategoryAdapter categoryAdapter;
|
|
|
+
|
|
|
+ private Spinner searchHospitalSpinner;
|
|
|
+ private Spinner searchDeptSpinner;
|
|
|
+ private LinearLayout searchHospitalLayout;
|
|
|
+ private LinearLayout searchDeptLayout;
|
|
|
+
|
|
|
+ public SearchFragment() {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
+ mContext = getActivity();
|
|
|
+ mActivity = (AppCompatActivity) getActivity();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -31,7 +60,103 @@ public class SearchFragment extends Fragment {
|
|
|
|
|
|
View view = (View) inflater.inflate(R.layout.activity_search_fragment, container, false);
|
|
|
|
|
|
+ searchHospitalLayout = (LinearLayout) view.findViewById(R.id.searchHospitalLayout);
|
|
|
+ searchDeptLayout = (LinearLayout) view.findViewById(R.id.searchDeptLayout);
|
|
|
+ searchDeptSpinner = (Spinner) view.findViewById(R.id.searchDeptSpinner);
|
|
|
+ searchHospitalSpinner = (Spinner) view.findViewById(R.id.searchHospitalSpinner);
|
|
|
+
|
|
|
+ getHospitalList("1");
|
|
|
+
|
|
|
return view;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getHospitalList(final String categoryId) {
|
|
|
+ CallBack callBack = new CallBack() {
|
|
|
+ @Override
|
|
|
+ public void result(SoapObject result) {
|
|
|
+ Log.e(TAG, "getHospitalList --> " + result);
|
|
|
+ if (result == null || result.toString().indexOf("null") > 0) {
|
|
|
+ stop();
|
|
|
+ } else {
|
|
|
+ ArrayList<CategoryVO> arrayList = SoapParser.getHospitalList(result);
|
|
|
+ if (arrayList.size() == 0) {
|
|
|
+ stop();
|
|
|
+ } else {
|
|
|
+ setSpinnerAdapter(arrayList, categoryId);
|
|
|
+ }
|
|
|
|
|
|
+ for (int i = 0; i < arrayList.size(); i++) {
|
|
|
+ CategoryVO categoryVO = arrayList.get(i);
|
|
|
+ String categoryId = categoryVO.getCategoryId();
|
|
|
+ if (categoryId.equals("EMA_" + BuildConfig.INST_CD)) {
|
|
|
+ getHospitalRowList(categoryId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+// ArrayList<CategoryVO> arrayList = new ArrayList<CategoryVO>();
|
|
|
+// arrayList.add(new CategoryVO("", "", "전체"));
|
|
|
+// setSpinnerAdapter(arrayList);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void error() {
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ HashMap<String, String> mData = new HashMap<String, String>();
|
|
|
+ mData.put("categoryId", categoryId);
|
|
|
+ Util.callHttp(mContext, ConsentConfig.HOST_CONSENT, ConsentConfig.GET_CONSENT_CATEGORYY, mData, callBack);
|
|
|
}
|
|
|
+
|
|
|
+ private void getHospitalRowList(final String categoryId) {
|
|
|
+ CallBack callBack = new CallBack() {
|
|
|
+ @Override
|
|
|
+ public void result(SoapObject result) {
|
|
|
+ Log.e(TAG, "RowListResult --> " + result);
|
|
|
+ if (result == null || result.toString().indexOf("null") > 0) {
|
|
|
+ stop();
|
|
|
+ } else {
|
|
|
+ ArrayList<CategoryVO> arrayList = SoapParser.getHospitalList(result);
|
|
|
+ setSpinnerAdapter(arrayList, categoryId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void error() {
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ HashMap<String, String> mData = new HashMap<String, String>();
|
|
|
+ mData.put("categoryId", categoryId);
|
|
|
+ Util.callHttp(mContext, ConsentConfig.HOST_CONSENT, ConsentConfig.GET_CONSENT_CATEGORYY, mData, callBack);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setSpinnerAdapter(final ArrayList arrayList, final String categoryId) {
|
|
|
+ mActivity.runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ categoryAdapter = new CategoryAdapter(mActivity, arrayList);
|
|
|
+
|
|
|
+ if (!categoryId.equals("EMA_" + BuildConfig.INST_CD)) {
|
|
|
+ searchHospitalSpinner.setAdapter(categoryAdapter);
|
|
|
+ }
|
|
|
+ if (categoryId.equals("EMA_" + BuildConfig.INST_CD)) {
|
|
|
+ searchDeptSpinner.setAdapter(categoryAdapter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|