|
@@ -1,9 +1,13 @@
|
|
|
package com.wdkl.callingdoctor.ui.fragment;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.support.v4.widget.SwipeRefreshLayout;
|
|
|
+import android.support.v7.widget.GridLayoutManager;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
@@ -14,28 +18,40 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
+import com.wdkl.callingdoctor.MyApplication;
|
|
|
import com.wdkl.callingdoctor.R;
|
|
|
import com.wdkl.callingdoctor.adapter.DoctorHostAdapter;
|
|
|
+import com.wdkl.callingdoctor.adapter.DutyDoctorAdapter;
|
|
|
+import com.wdkl.callingdoctor.adapter.DutyNurseAdapter;
|
|
|
import com.wdkl.callingdoctor.adapter.MedicalHostsCallingQueuingInfoAdapter;
|
|
|
import com.wdkl.callingdoctor.adapter.NurseHostAdapter;
|
|
|
import com.wdkl.callingdoctor.base.BaseFragment;
|
|
|
import com.wdkl.callingdoctor.common.Constants;
|
|
|
+import com.wdkl.callingdoctor.entity.AllNurseHostEntity;
|
|
|
import com.wdkl.callingdoctor.entity.CallingQueuingInfoEntity;
|
|
|
import com.wdkl.callingdoctor.entity.DoctorHostEntity;
|
|
|
+import com.wdkl.callingdoctor.entity.HospitalInfoEntity;
|
|
|
import com.wdkl.callingdoctor.entity.MessageEvent;
|
|
|
import com.wdkl.callingdoctor.entity.NurseHostListInfo;
|
|
|
+import com.wdkl.callingdoctor.entity.UdpEntity;
|
|
|
+import com.wdkl.callingdoctor.ui.activity.MainFragmentActivity;
|
|
|
import com.wdkl.callingdoctor.util.LogUtil;
|
|
|
+import com.wdkl.callingdoctor.util.PalyPhonetics;
|
|
|
import com.wdkl.callingdoctor.util.StringUtils;
|
|
|
+import com.wdkl.callingdoctor.util.ToastUtil;
|
|
|
import com.wdkl.callingdoctor.util.UIUtils;
|
|
|
+import com.wdkl.callingdoctor.util.UdpSendUtil;
|
|
|
import com.zhy.http.okhttp.OkHttpUtils;
|
|
|
import com.zhy.http.okhttp.callback.StringCallback;
|
|
|
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
|
+import org.json.JSONArray;
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import butterknife.Bind;
|
|
|
import butterknife.ButterKnife;
|
|
@@ -44,6 +60,7 @@ import okhttp3.Call;
|
|
|
import static com.wdkl.callingdoctor.util.StringUtils.notEmpty;
|
|
|
import static com.wdkl.callingdoctor.util.ToastUtil.showToast;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Created by xuhuan on 2017/8/23.<br></>
|
|
|
* Changed by Waderson on 2017/12/1
|
|
@@ -51,7 +68,9 @@ import static com.wdkl.callingdoctor.util.ToastUtil.showToast;
|
|
|
|
|
|
public class CallingHostFragment extends BaseFragment implements DoctorHostAdapter.DoctorHostItemOnclickListener,
|
|
|
NurseHostAdapter.NurseHostItemOnclickListener, View.OnClickListener,
|
|
|
- MedicalHostsCallingQueuingInfoAdapter.CallingQueuingBarItemOnClickListener, RecyclerView.OnItemTouchListener {
|
|
|
+ MedicalHostsCallingQueuingInfoAdapter.CallingQueuingBarItemOnClickListener, RecyclerView.OnItemTouchListener, SwipeRefreshLayout.OnRefreshListener {
|
|
|
+
|
|
|
+ private String TAG = CallingHostFragment.class.getSimpleName();
|
|
|
|
|
|
private View mView;
|
|
|
|
|
@@ -69,6 +88,10 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
* 医生主机的适配器
|
|
|
*/
|
|
|
private DoctorHostAdapter doctorHostAdapter;
|
|
|
+
|
|
|
+ //护士主机刷新控件
|
|
|
+ @Bind(R.id.fragment_calling_nurse_layout_sr_refresh)
|
|
|
+ SwipeRefreshLayout swipeNurseRefreshLayout;
|
|
|
/**
|
|
|
* 护士主机RV
|
|
|
*/
|
|
@@ -127,6 +150,29 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
@Bind(R.id.fragment_tv_doctor_nurse_no)
|
|
|
TextView nurse_CallStaus;
|
|
|
|
|
|
+ //所有护士主机列表
|
|
|
+ private AllNurseHostEntity AllNurseHostEntity;
|
|
|
+
|
|
|
+ private List<NurseHostListInfo> nurseHostListInfo = new ArrayList<>();
|
|
|
+
|
|
|
+ //值班医生
|
|
|
+ @Bind(R.id.fragment_rv_doctors)
|
|
|
+ RecyclerView rvDutyDoctors;
|
|
|
+
|
|
|
+ //值班护士
|
|
|
+ @Bind(R.id.fragment_rv_nurses)
|
|
|
+ RecyclerView rvDutyNurses;
|
|
|
+
|
|
|
+ private DutyDoctorAdapter dutyDoctorAdapter;
|
|
|
+ private DutyNurseAdapter dutyNurseAdapter;
|
|
|
+ private ArrayList<String> dutyDoctorsList = new ArrayList<>();
|
|
|
+ private ArrayList<String> dutyNursesList = new ArrayList<>();
|
|
|
+
|
|
|
+ //科室数据
|
|
|
+ private HospitalInfoEntity hospitalInfoEntity;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Nullable
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
@@ -152,6 +198,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
ivEndCalling.setOnClickListener(this);
|
|
|
rvDoctor.addOnItemTouchListener(this);
|
|
|
rvNurse.addOnItemTouchListener(this);
|
|
|
+ swipeNurseRefreshLayout.setOnRefreshListener(this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -184,15 +231,113 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
rvDoctor.setAdapter(doctorHostAdapter);
|
|
|
doctorHostAdapter.setDoctorHostItemOnclickListener(this);
|
|
|
|
|
|
- LinearLayoutManager nurseManager = new LinearLayoutManager(getActivity());
|
|
|
- nurseManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
|
|
+// LinearLayoutManager nurseManager = new LinearLayoutManager(getActivity());
|
|
|
+// nurseManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
|
|
+ GridLayoutManager nurseManager = new GridLayoutManager(getActivity(), 4);
|
|
|
rvNurse.setLayoutManager(nurseManager);
|
|
|
nurseHostAdapter = new NurseHostAdapter(getActivity(), nurseHostList);
|
|
|
rvNurse.setAdapter(nurseHostAdapter);
|
|
|
nurseHostAdapter.setNurseHostItemOnclickListener(this);
|
|
|
|
|
|
- getNurseHostList();
|
|
|
- getDoctorHostList();
|
|
|
+ //责任医生列表
|
|
|
+ GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 3);
|
|
|
+ rvDutyDoctors.setLayoutManager(layoutManager);
|
|
|
+ dutyDoctorAdapter = new DutyDoctorAdapter(getActivity(), dutyDoctorsList);
|
|
|
+ rvDutyDoctors.setAdapter(dutyDoctorAdapter);
|
|
|
+
|
|
|
+ //责任护士列表
|
|
|
+ GridLayoutManager layoutManager2 = new GridLayoutManager(getActivity(), 3);
|
|
|
+ rvDutyNurses.setLayoutManager(layoutManager2);
|
|
|
+ dutyNurseAdapter = new DutyNurseAdapter(getActivity(), dutyNursesList);
|
|
|
+ rvDutyNurses.setAdapter(dutyNurseAdapter);
|
|
|
+
|
|
|
+ // 原有护士主机逻辑
|
|
|
+// getNurseHostList();
|
|
|
+// getDoctorHostList();
|
|
|
+
|
|
|
+ getAllNurseHosts();
|
|
|
+ getAllDeviceInfo();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getAllDeviceInfo() {
|
|
|
+ OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_DEVICE_INFO)
|
|
|
+ .addParams("PartID", Constants.PartID)
|
|
|
+ .build()
|
|
|
+ .execute(new StringCallback() {
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ if (swipeNurseRefreshLayout.isRefreshing()) {
|
|
|
+ swipeNurseRefreshLayout.setRefreshing(false);
|
|
|
+ }
|
|
|
+ hideProgress();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(String response, int id) {
|
|
|
+ if (swipeNurseRefreshLayout.isRefreshing()) {
|
|
|
+ swipeNurseRefreshLayout.setRefreshing(false);
|
|
|
+ }
|
|
|
+ if (notEmpty(response)) {
|
|
|
+ LogUtil.d(CallingHostFragment.class, "device info==" + response);
|
|
|
+ } else {
|
|
|
+ LogUtil.i(CallingHostFragment.class, "数据返回为空!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getAllNurseHosts() {
|
|
|
+
|
|
|
+// OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_PART_INFO)
|
|
|
+ // 测试使用
|
|
|
+// OkHttpUtils.post().url(Constants.URL + Constants.URL_END +"/Mgr/GetWD_PartInfoArray.aspx")
|
|
|
+ Log.e(TAG,"url "+Constants.URL + Constants.URL_END+"/WDHS-I/callingMainNurse_NurseHostList.aspx");
|
|
|
+ Log.e(TAG,"url "+Constants.MYSELF_ID+" "+Constants.PartID);
|
|
|
+ OkHttpUtils.post().url(Constants.URL + Constants.URL_END +Constants.CALLINGMAINNURSE_NURSELIST)
|
|
|
+ .addParams("deviceId", Constants.MYSELF_ID)
|
|
|
+ .addParams("PartID", Constants.PartID)
|
|
|
+ .build()
|
|
|
+ .execute(new StringCallback() {
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ Log.e(TAG,e.getMessage(),e);
|
|
|
+ if (swipeNurseRefreshLayout.isRefreshing()) {
|
|
|
+ swipeNurseRefreshLayout.setRefreshing(false);
|
|
|
+ }
|
|
|
+ hideProgress();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(String response, int id) {
|
|
|
+ if (swipeNurseRefreshLayout.isRefreshing()) {
|
|
|
+ swipeNurseRefreshLayout.setRefreshing(false);
|
|
|
+ }
|
|
|
+ if (notEmpty(response)) {
|
|
|
+ LogUtil.d(CallingHostFragment.class, "part info==" + response);
|
|
|
+ String code = getStringData(response, "Code");
|
|
|
+ Log.e(TAG,"code "+code);
|
|
|
+ if (code.equals("OK!")) {
|
|
|
+ String data = response.substring(0, response.length() - 4);
|
|
|
+ Log.e(TAG,"返回的数据data "+data);
|
|
|
+ Gson gson = new Gson();
|
|
|
+ nurseHostList = gson.fromJson(getStringData(response, "hostList"),
|
|
|
+ new TypeToken<ArrayList<NurseHostListInfo>>() {
|
|
|
+ }.getType());
|
|
|
+ if (null != nurseHostList) {
|
|
|
+ LogUtil.d(CallingHostFragment.class, "nurseHostListsize==" + nurseHostList.size());
|
|
|
+ nurseHostAdapter.updateList(nurseHostList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ LogUtil.i(CallingHostFragment.class, "Code==" + code + "---数据返回错误!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ LogUtil.i(CallingHostFragment.class, "数据返回为空!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -251,42 +396,43 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取医护主机列表信息
|
|
|
- */
|
|
|
- private void getNurseHostList() {
|
|
|
- if (!StringUtils.notEmpty(Constants.PartID)) return;
|
|
|
- OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_NURSELIST)
|
|
|
- .addParams("PartID", Constants.PartID)
|
|
|
- .addParams("deviceId", Constants.MYSELF_ID)
|
|
|
- .build()
|
|
|
- .execute(new StringCallback() {
|
|
|
- @Override
|
|
|
- public void onError(Call call, Exception e, int id) {
|
|
|
- hideProgress();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onResponse(String response, int id) {
|
|
|
- if (notEmpty(response)) {
|
|
|
- LogUtil.d(CallingHostFragment.class, "NurseHostListresponse==" + response);
|
|
|
- String code = getStringData(response, "Code");
|
|
|
- if (code.equals("OK!")) {
|
|
|
- nurseHostList = new Gson().fromJson(getStringData(response, "hostList"), new TypeToken<ArrayList<NurseHostListInfo>>() {
|
|
|
- }.getType());
|
|
|
- if (null != nurseHostList) {
|
|
|
- LogUtil.d(CallingHostFragment.class, "nurseHostListsize==" + nurseHostList.size());
|
|
|
- nurseHostAdapter.updateList(nurseHostList);
|
|
|
- }
|
|
|
- } else {
|
|
|
- LogUtil.i(CallingHostFragment.class, "Code==" + code + "---数据返回错误!");
|
|
|
- }
|
|
|
- } else {
|
|
|
- LogUtil.i(CallingHostFragment.class, "数据返回为空!");
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 获取医护主机列表信息
|
|
|
+// */
|
|
|
+// private void getNurseHostList() {
|
|
|
+// if (!StringUtils.notEmpty(Constants.PartID)) return;
|
|
|
+// OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_NURSELIST)
|
|
|
+// .addParams("PartID", Constants.PartID)
|
|
|
+// .addParams("deviceId", Constants.MYSELF_ID)
|
|
|
+// .build()
|
|
|
+// .execute(new StringCallback() {
|
|
|
+// @Override
|
|
|
+// public void onError(Call call, Exception e, int id) {
|
|
|
+// hideProgress();
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onResponse(String response, int id) {
|
|
|
+// if (notEmpty(response)) {
|
|
|
+// LogUtil.d(CallingHostFragment.class, "NurseHostListresponse==" + response);
|
|
|
+// String code = getStringData(response, "Code");
|
|
|
+// if (code.equals("OK!")) {
|
|
|
+// nurseHostList = new Gson().fromJson(getStringData(response, "hostList"),
|
|
|
+// new TypeToken<ArrayList<NurseHostListInfo>>() {
|
|
|
+// }.getType());
|
|
|
+// if (null != nurseHostList) {
|
|
|
+// LogUtil.d(CallingHostFragment.class, "nurseHostListsize==" + nurseHostList.size());
|
|
|
+// nurseHostAdapter.updateList(nurseHostList);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// LogUtil.i(CallingHostFragment.class, "Code==" + code + "---数据返回错误!");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// LogUtil.i(CallingHostFragment.class, "数据返回为空!");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
|
|
|
// /**
|
|
|
// * 获取呼叫历史列表信息
|
|
@@ -344,6 +490,127 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
doctorHostAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void getPartData(String partId) {
|
|
|
+ if (!StringUtils.notEmpty(Constants.URL)) return;
|
|
|
+ if (!StringUtils.notEmpty(partId)) return;
|
|
|
+ OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_HOSPITAL)
|
|
|
+ .addParams("PartID", partId)
|
|
|
+ .build()
|
|
|
+ .execute(new StringCallback() {
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ LogUtil.d("getPartData", "===error===");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(String response, int id) {
|
|
|
+ String data = response.substring(0, response.length() - 4);
|
|
|
+ LogUtil.d("getPartData", "data=="+data);
|
|
|
+ try {
|
|
|
+ JSONObject jsonObj = new JSONObject(data);
|
|
|
+ if (jsonObj.getString("Code").equals("ERROR!")) {
|
|
|
+ LogUtil.d("getPartData", "网络错误");
|
|
|
+ } else {
|
|
|
+ Gson gson = new Gson();
|
|
|
+ hospitalInfoEntity = gson.fromJson(data, HospitalInfoEntity.class);
|
|
|
+ ArrayList<String> doctorList = (ArrayList<String>) hospitalInfoEntity.getDutyDoctorList();
|
|
|
+ ArrayList<String> nurseList = (ArrayList<String>) hospitalInfoEntity.getNurseOnDutyList();
|
|
|
+ dutyDoctorAdapter.updateList(doctorList);
|
|
|
+ dutyNurseAdapter.updateList(nurseList);
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getNurseHostInfo(String partId) {
|
|
|
+ try {
|
|
|
+ OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_NURSELIST)
|
|
|
+ .addParams("PartID", partId)
|
|
|
+ .build()
|
|
|
+ .execute(new StringCallback() {
|
|
|
+ @Override
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
+ LogUtil.d("getNurseHostInfo", "===error===");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(String response, int id) {
|
|
|
+ try {
|
|
|
+ JSONObject jsonObj = new JSONObject(response);
|
|
|
+ if (jsonObj.getString("Code").equals("ERROR!")) {
|
|
|
+ LogUtil.d("getNurseHostInfo", "网络错误");
|
|
|
+ } else {
|
|
|
+ if (jsonObj.getString("Code").equals("OK!")) {
|
|
|
+ String data = jsonObj.getString("hostList");
|
|
|
+ JSONArray array = new JSONArray(data);
|
|
|
+ Gson gson = new Gson();
|
|
|
+ List<NurseHostListInfo> nurseHostList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < array.length(); i++) {
|
|
|
+ NurseHostListInfo nurseHostListInfo = gson.fromJson(array.get(i).toString(), NurseHostListInfo.class);
|
|
|
+ nurseHostList.add(nurseHostListInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nurseHostList.size() > 0 && nurseHostList.get(0) != null) {
|
|
|
+ NurseHostListInfo hostInfo = nurseHostList.get(0);
|
|
|
+ final String hostId = hostInfo.getDeviceHostingID();
|
|
|
+ //final String sip = hostInfo.getDeviceSipIp();
|
|
|
+ //final String name = hostInfo.getDeviceName();
|
|
|
+ ivEndCalling.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getActivity().runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ callClick(hostId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ LogUtil.d("Code", "网络错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void callClick(String hostId) {
|
|
|
+ if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
|
|
|
+ //呼叫中
|
|
|
+ ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_hang_up);
|
|
|
+ nurse_CallStaus.setText("正在呼叫...");
|
|
|
+ Log.e(TAG,"callClick 正在呼叫");
|
|
|
+ UdpSendUtil.sendNurseHostCall(hostId);
|
|
|
+ Constants.CALL_STATE = Constants.IN_CALL;
|
|
|
+ Constants.CALLING_HOST_ID = hostId;
|
|
|
+ Constants.CallType = Constants.DOCTOR_CALL;
|
|
|
+ } else {
|
|
|
+ //主动挂断
|
|
|
+ if (Constants.CallType.equals(Constants.DOCTOR_CALL)) {
|
|
|
+ ((MainFragmentActivity) getActivity()).endCalled();
|
|
|
+ ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
|
|
|
+ nurse_CallStaus.setText("");
|
|
|
+ UdpSendUtil.sendNurseHostHangUp(hostId);
|
|
|
+ Constants.CALL_STATE = Constants.STANDBY;
|
|
|
+ Constants.CALLING_HOST_ID = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 护士主机适配器条目的点击事件
|
|
|
*
|
|
@@ -352,27 +619,51 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
*/
|
|
|
@Override
|
|
|
public void nurseHostItemOnclick(View view, int position) {
|
|
|
- if (null == nurseHostList || nurseHostList.size() <= 0 || null == nurseHostList.get(position))
|
|
|
+ if (!Constants.CALL_STATE.equals(Constants.STANDBY) && Constants.CallType.equals(Constants.DOCTOR_CALL)) {
|
|
|
+ ToastUtil.showToast("请先取消当前呼叫");
|
|
|
return;
|
|
|
- if (nurseHostList.get(position).isChecked()) {
|
|
|
- nurseHostList.get(position).setChecked(false);
|
|
|
- rlIncall.setVisibility(View.GONE);
|
|
|
- rlNotInCallBg.setVisibility(View.VISIBLE);
|
|
|
- tvCallingTips.setText("");
|
|
|
- } else {
|
|
|
+ }else if(!Constants.NurseHostCallStatus.equals(Constants.STANDBY)){
|
|
|
+ ToastUtil.showToast("请先取消当前呼叫...");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (nurseHostList.size() <= 0 || position >= nurseHostList.size() || null == nurseHostList.get(position)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ final NurseHostListInfo info = nurseHostList.get(position);
|
|
|
+ if (!info.isChecked()) {
|
|
|
for (NurseHostListInfo entity : nurseHostList) {
|
|
|
if (null == entity) continue;
|
|
|
entity.setChecked(false);
|
|
|
}
|
|
|
- nurseHostList.get(position).setChecked(true);
|
|
|
- tvCallingTips.setText(nurseHostList.get(position).getDeviceName());
|
|
|
- nurse_CallStaus.setText(nurseHostList.get(position).getDeviceName());
|
|
|
+ info.setChecked(true);
|
|
|
+ nurseHostAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ tvCallingTips.setText("");
|
|
|
+ //nurse_CallStaus.setText(info.getPART_NAME());
|
|
|
ivDoctorOrNurseCalling.setImageResource(R.mipmap.ic_nurse_right_in_call);
|
|
|
ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
|
|
|
+ ivEndCalling.setVisibility(View.VISIBLE);
|
|
|
rlIncall.setVisibility(View.VISIBLE);
|
|
|
rlNotInCallBg.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ getPartData(info.getDeviceSipStatus());
|
|
|
+ ivEndCalling.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if(!Constants.NurseHostCallStatus.equals(Constants.STANDBY)){
|
|
|
+ ToastUtil.showToast("请先取消当前呼叫");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ getActivity().runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ callClick(info.getDeviceHostingID());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // getNurseHostInfo(info.getDeviceSipStatus());
|
|
|
}
|
|
|
- nurseHostAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -409,6 +700,90 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void onMoonEvent(MessageEvent messageEvent) {
|
|
|
+ Log.e(TAG, "onMoonEvent返回。。。"+messageEvent.getType());
|
|
|
+ switch (messageEvent.getType()){
|
|
|
+ case Constants.EVENT_SIP:
|
|
|
+ Log.e(TAG, "Constants.CALL_STATE==" + Constants.CALL_STATE);
|
|
|
+ if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
|
|
|
+ LogUtil.d("onMoonEvent", "通话状态==STANDBY");
|
|
|
+
|
|
|
+ if (null != MyApplication.serialPortUtil) { //呼叫结束了;打开外部音响
|
|
|
+ MyApplication.serialPortUtil.stereoControl("1");
|
|
|
+ }
|
|
|
+ ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
|
|
|
+ nurse_CallStaus.setText("");
|
|
|
+ }
|
|
|
+ if (Constants.CALL_STATE.equals(Constants.IN_CALL)) {
|
|
|
+
|
|
|
+ } else if (Constants.CALL_STATE.equals(Constants.IN_CALLING)) {
|
|
|
+
|
|
|
+
|
|
|
+ Log.e(TAG,"Constants.CallType "+Constants.CallType);
|
|
|
+
|
|
|
+ if(Constants.CallType != Constants.MAIN_CALL){
|
|
|
+ ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_hang_up);
|
|
|
+ nurse_CallStaus.setText(" 正在通话中...");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != MyApplication.serialPortUtil) { //正在呼叫;将关闭外部音响
|
|
|
+ MyApplication.serialPortUtil.stereoControl("0");
|
|
|
+ }
|
|
|
+
|
|
|
+ MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
|
|
|
+ }
|
|
|
+ }, 600);
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
|
|
|
+ }
|
|
|
+ }, 1100);
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Constants.EVENT_UDP:
|
|
|
+ Log.e(TAG, "onMoonEvent返回。。。EVENT_UDP");
|
|
|
+ UdpEntity udpEntity = (UdpEntity) messageEvent.getMessage();
|
|
|
+ String nurseHostID = udpEntity.getNurseHostID();
|
|
|
+ String headMachineID = udpEntity.getHeadMachineID();
|
|
|
+ switch (udpEntity.getIndexes()) {
|
|
|
+ case "call_13_upremove"://护士主机上划删除了医生机的呼叫
|
|
|
+ ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
|
|
|
+ nurse_CallStaus.setText("");
|
|
|
+ Constants.NurseHostCallStatus = Constants.STANDBY;
|
|
|
+ Constants.CALL_STATE = Constants.STANDBY;
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "call_13"://护士主机呼叫医生主机
|
|
|
+ Constants.NurseHostCallStatus = Constants.IN_CALL;
|
|
|
+ break;
|
|
|
+ case "call_13_hang_up"://护士主机取消呼叫医生主机
|
|
|
+ Constants.NurseHostCallStatus = Constants.STANDBY;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -430,4 +805,21 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onRefresh() {
|
|
|
+ resetRightList();
|
|
|
+ getAllNurseHosts();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void resetRightList() {
|
|
|
+ tvCallingTips.setText("");
|
|
|
+ nurse_CallStaus.setText("");
|
|
|
+ ivDoctorOrNurseCalling.setImageResource(R.mipmap.ic_trusteeship_n);
|
|
|
+ ivEndCalling.setVisibility(View.GONE);
|
|
|
+ rlIncall.setVisibility(View.VISIBLE);
|
|
|
+ rlNotInCallBg.setVisibility(View.GONE);
|
|
|
+ dutyDoctorAdapter.clear();
|
|
|
+ dutyNurseAdapter.clear();
|
|
|
+ }
|
|
|
}
|