Quellcode durchsuchen

<完善通话流程>

weizhengliang vor 5 Jahren
Ursprung
Commit
389dff9b77

+ 3 - 2
app/src/main/java/com/wdkl/callingmainnursemanager/common/Constants.java

@@ -221,15 +221,16 @@ public class Constants {
 
     /**
      * 各种呼叫的机型
-     * type : 0总控机 1门口机 2主机 3 子机  4请求增援 5卫生间优先等级依次升高   12传统机
+     * type : 1门口机 2主机 3 子机  4请求增援 5卫生间 6总控机 优先等级依次升高   12传统机
      */
-    public static final String MANAGER_CALL = "0";
     public static final String DOOR_CALL = "1";
     public static final String MAIN_CALL = "2";
     public static final String SON_CALL = "3";
     public static final String ROOMHELP_CALL = "4";
     public static final String WSHROOM_CALL = "5";
+    public static final String MANAGER_CALL = "6";
     public static final String TRADITION_CALL = "12";
+    public static String CallType = "";
 
     public static String DEVICE_ID = "";
     public static String MYSELF_ID = "";//自己的机器ID

+ 2 - 2
app/src/main/java/com/wdkl/callingmainnursemanager/ui/activity/MainFragmentActivity.java

@@ -501,9 +501,9 @@ public class MainFragmentActivity extends FragmentActivity implements IVvsipServ
      */
     public void initiateCall(String sipAddress, String type, String mac) {
         //=============================================SIP拨打电话===================================//
-        Log.d("sendCall1", "sipAddress==" + sipAddress);
+        Log.d("sendCall1", "sipAddress==" + sipAddress + ", type==" + type);
         SipHelperUtil.getInstance(this).getmSipCallBackI().startCall(sipAddress, type, mac);
-
+        Constants.CallType = type;
     }
 
     /**

+ 13 - 9
app/src/main/java/com/wdkl/callingmainnursemanager/ui/fragment/CallingBedFragment.java

@@ -443,7 +443,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
     protected void initView(View RootView) {
 
         //默认的通话状态
-        Constants.CALL_STATE = Constants.STANDBY;
+        //Constants.CALL_STATE = Constants.STANDBY;
         vRightPatientInfo.setVisibility(View.VISIBLE);
         vRightCallInfo.setVisibility(View.GONE);
         vRightCallListInfo.setVisibility(View.GONE);
@@ -1191,6 +1191,10 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
      */
     @OnClick(R.id.right_in_calling_layout_iv_call)
     public void Call(View view) {
+        if (!Constants.CALL_STATE.equals(Constants.STANDBY)) {
+            ToastUtil.showToast("请先取消当前呼叫");
+            return;
+        }
         currentTime = System.currentTimeMillis();
         if (currentTime - lastClickTime > CLICK_DELAY_TIME) {
             lastClickTime = currentTime;
@@ -1211,7 +1215,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         //ToastUtil.showToast(sipAddress+"===="+sickBedInfo.getDeviceMAC());
                         callBed = true;
                         ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
-                        mainFragmentActivity.initiateCall(sipAddress, "", sickBedInfo.getDeviceMAC() == null ? "-1" : sickBedInfo.getDeviceMAC());
+                        mainFragmentActivity.initiateCall(sipAddress, Constants.SON_CALL, sickBedInfo.getDeviceMAC() == null ? "-1" : sickBedInfo.getDeviceMAC());
                     }
                 }
             } else {
@@ -1303,7 +1307,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         if (null == sickbedInformationList || null == sickbedInformationList.get(position) || null == sickbedInformationList.get(position).getPatientID()) {
             return;
         }
-        if (!Constants.CALL_STATE.equals(Constants.STANDBY) && !sickBedInfo.equals(sickbedInformationList.get(position))) {
+        if (!Constants.CALL_STATE.equals(Constants.STANDBY) /*&& !sickBedInfo.equals(sickbedInformationList.get(position))*/) {
             ToastUtil.showToast("请先取消当前呼叫");
             return;
         }
@@ -1315,7 +1319,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     if (StringUtils.notEmpty(sipAddress)) {
                         callBed = true;
                         ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
-                        mainFragmentActivity.initiateCall(sipAddress, "", sickBedInfo.getDeviceMAC() == null ? "-1" : sickBedInfo.getDeviceMAC());
+                        mainFragmentActivity.initiateCall(sipAddress, Constants.SON_CALL, sickBedInfo.getDeviceMAC() == null ? "-1" : sickBedInfo.getDeviceMAC());
                     }
                 } else {
                     endCall();
@@ -1447,7 +1451,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
      */
     @Override
     public void callListItemOnclick(View view, int position) {
-        if (!Constants.CALL_STATE.equals(Constants.STANDBY) && !callItemChooseEntity.equals(MyApplication.callEntityList.get(position))) {
+        if (!Constants.CALL_STATE.equals(Constants.STANDBY) /*&& !callItemChooseEntity.equals(MyApplication.callEntityList.get(position))*/) {
             ToastUtil.showToast("请先取消当前呼叫");
             return;
         }
@@ -2611,23 +2615,23 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         if (Constants.currentFragment != 0) {
             return;
         }
-        Message msg = handler.obtainMessage();
+        /*Message msg = handler.obtainMessage();
         Bundle data = new Bundle();
         data.putByteArray(OUTBUTTONCLICK_CONTENT, buffer);
         msg.setData(data);
         msg.what = OUTBUTTONCLICK;
-        handler.sendMessage(msg);
+        handler.sendMessage(msg);*/
     }
 
     @Override
     public void forkSpringData(int data) {
         //叉簧开关 的状态(Waderson)
-        Message msg = handler.obtainMessage();
+        /*Message msg = handler.obtainMessage();
         Bundle data_p = new Bundle();
         data_p.putInt(SPRINGCLICK_CONTENT, data);
         msg.setData(data_p);
         msg.what = SPRINGCLICK;
-        handler.sendMessage(msg);
+        handler.sendMessage(msg);*/
     }
 
     @Override

+ 25 - 24
app/src/main/java/com/wdkl/callingmainnursemanager/ui/fragment/CallingHostFragment.java

@@ -99,9 +99,6 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
     //科室数据
     private HospitalInfoEntity hospitalInfoEntity;
 
-    //通话的状态
-    private String CALL_STATUS = Constants.STANDBY;
-
     /**
      * 医生主机的适配器
      */
@@ -597,21 +594,24 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
     }
 
     private void callClick(String hostId) {
-        if (CALL_STATUS.equals(Constants.STANDBY)) {
+        if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
             //呼叫中
             ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_hang_up);
             nurse_CallStaus.setText("正在呼叫...");
             UdpSendUtil.sendNurseHostCall(hostId);
-            CALL_STATUS = Constants.IN_CALL;
+            Constants.CALL_STATE = Constants.IN_CALL;
             Constants.CALLING_HOST_ID = hostId;
+            Constants.CallType = Constants.MANAGER_CALL;
         } else {
-            //挂断
-            ((MainFragmentActivity) getActivity()).endCalled();
-            ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
-            nurse_CallStaus.setText("");
-            UdpSendUtil.sendNurseHostHangUp(hostId);
-            CALL_STATUS = Constants.STANDBY;
-            Constants.CALLING_HOST_ID = "";
+            //主动挂断
+            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 = "";
+            }
         }
     }
 
@@ -661,7 +661,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
      */
     @Override
     public void nurseHostItemOnclick(View view, int position) {
-        if (!Constants.CALL_STATE.equals(Constants.STANDBY)) {
+        if (!Constants.CALL_STATE.equals(Constants.STANDBY) && Constants.CallType.equals(Constants.MANAGER_CALL)) {
             ToastUtil.showToast("请先取消当前呼叫");
             return;
         }
@@ -732,21 +732,22 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
                     //对方挂断
                     ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
                     nurse_CallStaus.setText("");
-                    CALL_STATUS = Constants.STANDBY;
+                    Constants.CALL_STATE = Constants.STANDBY;
                     Constants.CALLING_HOST_ID = "";
                 }
                 break;
             case Constants.EVENT_SIP:
-                LogUtil.d("CallingHost", "Constants.CALL_STATE==" + Constants.CALL_STATE);
-                if (Constants.CALL_STATE.equals(Constants.IN_CALL)) {
-                    ((MainFragmentActivity) getActivity()).autoCall();
-                } else if (Constants.CALL_STATE.equals(Constants.IN_CALLING)) {
-                    nurse_CallStaus.setText("正在通话中...");
-                } else if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
-                    ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
-                    nurse_CallStaus.setText("");
-                    CALL_STATUS = Constants.STANDBY;
-                    Constants.CALLING_HOST_ID = "";
+                LogUtil.d("CallingHost", "Constants.CallType == " + Constants.CallType);
+                if (Constants.CallType.equals(Constants.MANAGER_CALL)) {
+                    if (Constants.CALL_STATE.equals(Constants.IN_CALL)) {
+                        ((MainFragmentActivity) getActivity()).autoCall();
+                    } else if (Constants.CALL_STATE.equals(Constants.IN_CALLING)) {
+                        nurse_CallStaus.setText("正在通话中...");
+                    } else if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
+                        ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
+                        nurse_CallStaus.setText("");
+                        Constants.CALLING_HOST_ID = "";
+                    }
                 }
                 break;
         }