|
@@ -1,9 +1,13 @@
|
|
|
package com.wdkl.callingmainnurse.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,19 +18,25 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
+import com.wdkl.callingmainnurse.MyApplication;
|
|
|
import com.wdkl.callingmainnurse.R;
|
|
|
import com.wdkl.callingmainnurse.adapter.DoctorHostAdapter;
|
|
|
import com.wdkl.callingmainnurse.adapter.MedicalHostsCallingQueuingInfoAdapter;
|
|
|
import com.wdkl.callingmainnurse.adapter.NurseHostAdapter;
|
|
|
import com.wdkl.callingmainnurse.base.BaseFragment;
|
|
|
import com.wdkl.callingmainnurse.common.Constants;
|
|
|
+import com.wdkl.callingmainnurse.entity.AllDoctorHostEntity;
|
|
|
import com.wdkl.callingmainnurse.entity.CallingQueuingInfoEntity;
|
|
|
import com.wdkl.callingmainnurse.entity.DoctorHostEntity;
|
|
|
import com.wdkl.callingmainnurse.entity.MessageEvent;
|
|
|
import com.wdkl.callingmainnurse.entity.NurseHostListInfo;
|
|
|
+import com.wdkl.callingmainnurse.entity.UdpEntity;
|
|
|
+import com.wdkl.callingmainnurse.ui.activity.MainFragmentActivity;
|
|
|
import com.wdkl.callingmainnurse.util.LogUtil;
|
|
|
import com.wdkl.callingmainnurse.util.StringUtils;
|
|
|
+import com.wdkl.callingmainnurse.util.ToastUtil;
|
|
|
import com.wdkl.callingmainnurse.util.UIUtils;
|
|
|
+import com.wdkl.callingmainnurse.util.UdpSendUtil;
|
|
|
import com.zhy.http.okhttp.OkHttpUtils;
|
|
|
import com.zhy.http.okhttp.callback.StringCallback;
|
|
|
|
|
@@ -36,6 +46,7 @@ import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import butterknife.Bind;
|
|
|
import butterknife.ButterKnife;
|
|
@@ -51,8 +62,9 @@ import static com.wdkl.callingmainnurse.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;
|
|
|
|
|
|
/**
|
|
@@ -127,6 +139,17 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
@Bind(R.id.fragment_tv_doctor_nurse_no)
|
|
|
TextView nurse_CallStaus;
|
|
|
|
|
|
+ //护士主机刷新控件
|
|
|
+ @Bind(R.id.fragment_calling_nurse_layout_sr_refresh)
|
|
|
+ SwipeRefreshLayout swipeNurseRefreshLayout;
|
|
|
+ // 醫生主机刷新控件
|
|
|
+ @Bind(R.id.fragment_calling_doctor_layout_sr_refresh)
|
|
|
+ SwipeRefreshLayout swipeDoctorRefreshLayout;
|
|
|
+ //所有护士主机列表
|
|
|
+ private AllDoctorHostEntity AllDoctorHostEntity;
|
|
|
+ private boolean isCallListCall = true;//呼叫列表是否在通话中,默认是在通话中
|
|
|
+
|
|
|
+
|
|
|
@Nullable
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
@@ -152,6 +175,8 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
ivEndCalling.setOnClickListener(this);
|
|
|
rvDoctor.addOnItemTouchListener(this);
|
|
|
rvNurse.addOnItemTouchListener(this);
|
|
|
+ swipeNurseRefreshLayout.setOnRefreshListener(this);
|
|
|
+ swipeDoctorRefreshLayout.setOnRefreshListener(this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -163,6 +188,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
protected void initData() {
|
|
|
initRecyclerManager();
|
|
|
initCallQueuingInfoBarData();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -177,8 +203,9 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
nurseHostList = new ArrayList<>();
|
|
|
doctorHostList = new ArrayList<>();
|
|
|
|
|
|
- LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
|
|
- manager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
|
|
+// LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
|
|
+// manager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
|
|
+ GridLayoutManager manager = new GridLayoutManager(getActivity(), 4);
|
|
|
rvDoctor.setLayoutManager(manager);
|
|
|
doctorHostAdapter = new DoctorHostAdapter(getActivity(), doctorHostList);
|
|
|
rvDoctor.setAdapter(doctorHostAdapter);
|
|
@@ -191,8 +218,12 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
rvNurse.setAdapter(nurseHostAdapter);
|
|
|
nurseHostAdapter.setNurseHostItemOnclickListener(this);
|
|
|
|
|
|
- getNurseHostList();
|
|
|
+// getNurseHostList();
|
|
|
getDoctorHostList();
|
|
|
+
|
|
|
+// if(Constants.CALL_STATE.equals(Constants.IN_CALL) ){
|
|
|
+// nurse_CallStaus.setText(" 对方正在呼叫中,请先取消对方的呼叫...");
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -220,27 +251,39 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
*/
|
|
|
private void getDoctorHostList() {
|
|
|
if (!StringUtils.notEmpty(Constants.PartID)) return;
|
|
|
+// OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_DOCTORLIST)
|
|
|
OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_DOCTORLIST)
|
|
|
- .addParams("PartID", Constants.PartID)
|
|
|
+ .addParams("PartID", Constants.PartID)
|
|
|
.addParams("deviceId", Constants.MYSELF_ID)
|
|
|
.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, "DoctorHostListresponse==" + response);
|
|
|
+ LogUtil.d(CallingHostFragment.class, "part info==" + response);
|
|
|
String code = getStringData(response, "Code");
|
|
|
+ Log.e(TAG,"code "+code);
|
|
|
if (code.equals("OK!")) {
|
|
|
- doctorHostList = new Gson().fromJson(getStringData(response, "hostList"), new TypeToken<ArrayList<DoctorHostEntity>>() {
|
|
|
+ String data = response.substring(0, response.length() - 4);
|
|
|
+ Log.e(TAG,"返回的数据data "+data);
|
|
|
+ Gson gson = new Gson();
|
|
|
+ doctorHostList = gson.fromJson(getStringData(response, "hostList"), new TypeToken<ArrayList<DoctorHostEntity>>() {
|
|
|
}.getType());
|
|
|
if (null != doctorHostList) {
|
|
|
doctorHostAdapter.updateList(doctorHostList);
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
LogUtil.i(CallingHostFragment.class, "Code==" + code + "---数据返回错误!");
|
|
|
}
|
|
@@ -325,25 +368,116 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
*/
|
|
|
@Override
|
|
|
public void doctorHostItemOnclick(View view, int position) {
|
|
|
- //tvCallingTips.setText("与医生主机" + (position + 1) + "通话中...");
|
|
|
- //rlIncall.setVisibility(View.VISIBLE);
|
|
|
- //rlNotInCallBg.setVisibility(View.GONE);
|
|
|
- //ivDoctorOrNurseCalling.setImageResource(R.mipmap.ic_doctor_right_in_call);
|
|
|
- if (null == doctorHostList || doctorHostList.size() <= 0 || null == doctorHostList.get(position))
|
|
|
+ Log.e(TAG," Constants.CALL_STATE "+Constants.CALL_STATE);
|
|
|
+
|
|
|
+ if (!Constants.CALL_STATE.equals(Constants.STANDBY) && Constants.CallType.equals(Constants.MANAGER_CALL)) {
|
|
|
+ ToastUtil.showToast("请先取消当前呼叫");
|
|
|
return;
|
|
|
- if (null != doctorHostList.get(position) && doctorHostList.get(position).isChecked()) {
|
|
|
- doctorHostList.get(position).setChecked(false);
|
|
|
- } else {
|
|
|
+ } else if(!Constants.DoctorMachineCallStatus.equals(Constants.STANDBY)){
|
|
|
+ ToastUtil.showToast("请先取消当前呼叫");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (doctorHostList.size() <= 0 || position >= doctorHostList.size() || null == doctorHostList.get(position)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ final DoctorHostEntity info = doctorHostList.get(position);
|
|
|
+ if (!info.isChecked()) {
|
|
|
for (DoctorHostEntity entity : doctorHostList) {
|
|
|
if (null == entity) continue;
|
|
|
entity.setChecked(false);
|
|
|
}
|
|
|
- doctorHostList.get(position).setChecked(true);
|
|
|
- showToast("该功能还在开发中...");
|
|
|
+ info.setChecked(true);
|
|
|
+ nurseHostAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+// tvCallingTips.setText(info.getPART_NAME());
|
|
|
+// 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.getID());
|
|
|
+// getNurseHostInfo(info.getID());
|
|
|
+
|
|
|
+ ivEndCalling.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if(!Constants.DoctorMachineCallStatus.equals(Constants.STANDBY)){
|
|
|
+ ToastUtil.showToast("请先取消当前呼叫");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ getActivity().runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ callClick(info.getDeviceHostingID());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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.MANAGER_CALL;
|
|
|
+ } else {
|
|
|
+ //主动挂断
|
|
|
+ if (Constants.CallType.equals(Constants.MANAGER_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 = "";
|
|
|
+ }
|
|
|
}
|
|
|
- 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();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
/**
|
|
|
* 护士主机适配器条目的点击事件
|
|
|
*
|
|
@@ -409,6 +543,77 @@ 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)) {
|
|
|
+ if(!Constants.CallType.equals(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_12_upremove":
|
|
|
+ ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
|
|
|
+ nurse_CallStaus.setText("");
|
|
|
+ Constants.DoctorMachineCallStatus = Constants.STANDBY;
|
|
|
+ break;
|
|
|
+ case "call_13"://医生机呼叫护士主机
|
|
|
+ Constants.DoctorMachineCallStatus = Constants.IN_CALL;
|
|
|
+ Log.e(TAG, "onMoonEvent。。。EVENT_UDP医生机呼叫护士主机");
|
|
|
+ break;
|
|
|
+ case "call_13_hang_up": //医生主机取消呼叫 add by waderson 20191108
|
|
|
+ Constants.DoctorMachineCallStatus = Constants.STANDBY;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -430,4 +635,18 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onRefresh() {
|
|
|
+ resetRightList();
|
|
|
+ getDoctorHostList();
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|