Example #1
0
 @Override
 public void handleMessage(Message msg) {
   // TODO Auto-generated method stub
   switch (msg.what) {
     case uSDKNotificationCenter.DEVICE_STATUS_CHANGED_NOTIFY:
       HashMap<String, HashMap<String, uSDKDeviceAttribute>> maps =
           (HashMap<String, HashMap<String, uSDKDeviceAttribute>>) msg.obj;
       HashMap<String, uSDKDeviceAttribute> attrs = maps.get(mDevice.getDeviceMac());
       mHandler.obtainMessage(Const.MSG_DEVICE_ATTRIBUTE_CHANGE, attrs).sendToTarget();
       Log.d(
           "test",
           "DEVICE_STATUS_CHANGED_NOTIFY  mDevice.size-->" + mDevice.getAttributeMap());
       initDeviceInfo(mDevice.getAttributeMap());
       break;
     case uSDKNotificationCenter.DEVICE_OPERATION_ACK_NOTIFY:
       HashMap<Integer, HashMap<String, uSDKDeviceAttribute>> cmd_maps =
           (HashMap<Integer, HashMap<String, uSDKDeviceAttribute>>) msg.obj;
       HashMap<String, uSDKDeviceAttribute> res_maps = cmd_maps.get(1000);
       initDeviceInfo(mDevice.getAttributeMap());
       break;
     case uSDKNotificationCenter.DEVICE_ALARM_NOTIFY:
       Log.d("test", "DEVICE_ALARM_NOTIFY ");
       HashMap<String, ArrayList<uSDKDeviceAlarm>> alarmList =
           (HashMap<String, ArrayList<uSDKDeviceAlarm>>) msg.obj;
       ArrayList<uSDKDeviceAlarm> deviceAlarmList = alarmList.get(mDevice.getDeviceMac());
       if (deviceAlarmList != null && deviceAlarmList.size() > 0) {
         String alarmContent = "";
         for (uSDKDeviceAlarm ala : deviceAlarmList) {
           alarmContent += ala.getAlarmMessage();
         }
         if (mAlarmDialog != null) {
           if (mAlarmDialog.isShowing()) {
             mAlarmDialog.setMessage(oldAlarmContent + "\n" + alarmContent);
             oldAlarmContent = oldAlarmContent + "\n" + alarmContent;
           } else {
             mAlarmDialog.setMessage(alarmContent);
             mAlarmDialog.show();
             oldAlarmContent = alarmContent;
           }
         } else {
           mAlarmDialog = getAlarmDialog(alarmContent.toString());
           mAlarmDialog.show();
           oldAlarmContent = alarmContent;
         }
       }
       break;
     case uSDKNotificationCenter.DEVICE_ONLINE_CHANGED_NOTIFY:
       HashMap<String, uSDKDeviceStatusConst> map =
           (HashMap<String, uSDKDeviceStatusConst>) msg.obj;
       if (map != null && map.size() > 0) {
         uSDKDeviceStatusConst online = map.get(mDeviceMac);
         if (online != null) {
           Toast.makeText(OvenControlFragment.this, "当前的设备装备:" + online.getValue(), 3000)
               .show();
         }
       }
       break;
   }
 }