示例#1
0
  /**
   * Update styles according to the given style. Then creating a command object for updating
   * corresponding view and put the command object in the queue.
   *
   * @param ref Reference of the dom.
   * @param style the new style. This style is only a part of the full style, and will be merged
   *     into styles
   * @see #updateAttrs(String, JSONObject)
   */
  void updateStyle(String ref, JSONObject style) {
    if (mDestroy || style == null) {
      return;
    }
    WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
    WXDomObject domObject = mRegistry.get(ref);
    if (domObject == null) {
      if (instance != null) {
        instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
      }
      return;
    }

    Map<String, Object> animationMap = WXDataStructureUtil.newHashMapWithExpectedSize(2);
    animationMap.put(WXDomObject.TRANSFORM, style.remove(WXDomObject.TRANSFORM));
    animationMap.put(WXDomObject.TRANSFORM_ORIGIN, style.remove(WXDomObject.TRANSFORM_ORIGIN));
    animations.add(new Pair<>(ref, animationMap));

    if (!style.isEmpty()) {
      domObject.updateStyle(style);
      transformStyle(domObject, false);
      updateStyle(domObject, style);
    }
    mDirty = true;

    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
    }
  }
  public Notification build() {
    Notification notification = new Notification();
    if (token != null) {
      notification.setToken(token);
    } else {
      throw new IllegalArgumentException("token is null!");
    }
    notification.setPriority(priority);
    // TODO 这里是否把没有设置过期时间的通知都设置成无限的?
    notification.setExpirationDate(expirationDate);

    /**
     *
     *
     * <pre>
     * 因为这里有两种格式,一种是:
     *     "aps" : {
     *         "alert" : "You got your emails.",
     *         "badge" : 9,
     *         "sound" : "bingbong.aiff"
     *     },
     *
     * 另一种是:
     * "aps" : {
     *    "alert" : {
     *      "body" : "Bob wants to play poker",
     *      "action-loc-key" : "PLAY"
     *    },
     *    "badge" : 5,
     *  },
     * </pre>
     */
    if (alert != null) {
      aps.put("alert", alert);
    } else {
      aps.put("alert", alertObject);
    }

    if (alert != null && !alertObject.isEmpty()) {
      logger.warn(
          "can not set alert and alertObject both!, https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW12");
    }

    payload.put("aps", aps);

    byte[] bytes = payload.toString().getBytes(utf8);
    if (bytes.length > MAX_PAYLOAD_SIZE) {
      throw new IllegalArgumentException("payload.length >" + MAX_PAYLOAD_SIZE);
    }
    notification.setPayload(bytes);
    return notification;
  }
示例#3
0
 public VideoMessage(byte[] data) {
   String jsonStr = new String(data);
   if (!TextUtils.isEmpty(jsonStr)) {
     JSONObject jsonObject = JSON.parseObject(jsonStr);
     if (!jsonObject.isEmpty()) {
       String videoUrl = jsonObject.getString("videoUrl");
       if (!TextUtils.isEmpty(videoUrl)) {
         this.remoteVideoUri = Uri.parse(videoUrl);
       }
       if (this.getRemoteVideoUri() != null
           && this.getRemoteVideoUri().getScheme() != null
           && !this.getRemoteVideoUri().getScheme().equals("http")) {
         this.localVideoUri = this.remoteVideoUri;
       }
       base64ImgContent = jsonObject.getString("imgContent");
       this.isUploadExp = true;
       this.setUserInfo(jsonObject.getObject("user", UserInfo.class));
     }
   }
 }