Example #1
0
  /**
   * 保存google事件
   *
   * @param event
   * @param cid
   * @throws Exception
   */
  public FDEvent saveGoogleEvent(FDEvent event, FDCalendar cal) throws Exception {
    Map<String, String> params = new HashMap<String, String>();
    //		params.put("cid", cal.getId());
    //		params.put("cid", event.getCalendarId());
    //		params.put("type", "1"	);
    //		FDPrintln.print("save google event :"+event);
    //		JSONObject obj =event.toJsonObjByGoogle();
    //		params.put("text", obj.toString()	);

    params.put("method", "addEvent");
    params.put("accountId", cal.getGoogleAccountId());
    params.put("calendarId", event.getCalendarId());
    FDPrintln.print("save google event :" + event);
    JSONObject obj = event.toJsonObjByGoogle();
    params.put("params", obj.toString());
    FDPrintln.print("saveGoogleEvent params  " + obj.toString());
    FDEvent receiveEvent = null;
    FDJson json = sendPOSTRequestByJson("user/Google", params);
    if (json != null) {
      if (json.getStatusCode() != 1) return null;
      receiveEvent = new FDEvent(json.getData(), cal, FDCalendarAccount.TYPE_GOOGLE);
      receiveEvent.setBackground(cal.getBackgroundColor());
      receiveEvent.setAccount(cal.getId());
    }
    return receiveEvent;
  }
Example #2
0
 private void setItemsToList(FDCalendar cal, List<FDEvent> events, JSONObject obj)
     throws JSONException {
   JSONArray items = obj.getJSONArray("items");
   for (int i = 0; i < items.length(); i++) {
     JSONObject item = items.getJSONObject(i);
     FDEvent event = new FDEvent(item.toString(), cal, FDCalendarAccount.TYPE_GOOGLE);
     //					event.setTimezone(timeZone);
     event.setBackground(cal.getBackgroundColor());
     events.add(event);
   }
 }