Beispiel #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;
   }
 }
Beispiel #2
0
  private Dialog createDialog() {

    Dialog dialog = new Dialog(this, R.style.NobackDialog);
    View view = LayoutInflater.from(this).inflate(R.layout.dialog_time_picker, null);
    Button btn_submit = (Button) view.findViewById(R.id.btn_dialog_submit);
    final WheelView hours = (WheelView) view.findViewById(R.id.wheel_hour);
    hours.setViewAdapter(new NumericWheelAdapter(this, 0, 23));
    hours.setCyclic(true);
    final WheelView mins = (WheelView) view.findViewById(R.id.wheel_mins);
    mins.setViewAdapter(new NumericWheelAdapter(this, 0, 59, "%02d"));
    mins.setCyclic(true);
    int curHours = 0;
    int curMinutes = 0;
    Map<String, uSDKDeviceAttribute> attrs = mDevice.getAttributeMap();
    switch (mCurrentType) {
      case 1:
        if (!TextUtils.isEmpty(getTime(attrs, 1))) {
          curHours = Integer.parseInt(getTime(attrs, 1).split(":")[0]);
          curMinutes = Integer.parseInt(getTime(attrs, 1).split(":")[1]);
        }
        break;
      case 2:
        if (!TextUtils.isEmpty(getTime(attrs, 2))) {
          curHours = Integer.parseInt(getTime(attrs, 2).split(":")[0]);
          curMinutes = Integer.parseInt(getTime(attrs, 2).split(":")[1]);
        }
        break;
    }
    hours.setCurrentItem(curHours);
    mins.setCurrentItem(curMinutes);
    OnWheelClickedListener click =
        new OnWheelClickedListener() {
          public void onItemClicked(WheelView wheel, int itemIndex) {
            wheel.setCurrentItem(itemIndex, true);
          }
        };
    hours.addClickingListener(click);
    mins.addClickingListener(click);
    btn_submit.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            mSetTime = formatTime(hours.getCurrentItem(), mins.getCurrentItem());
            mDialog.dismiss();
            switch (mCurrentType) {
              case 1:
                mSetTime0 = mSetTime;
                mOvenTime.setText(mSetTime0);
                sendCommand(mDevice, "20v00f", mSetTime0);
                break;
            }
          }
        });
    dialog.setContentView(view);
    dialog.setCanceledOnTouchOutside(true);
    return dialog;
  }