Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
 /** 显示事件提醒在控件上 */
 private void showAlertsInView() {
   FDAlert alert = null;
   if (event != null && event.getReminders() != null) {
     alert = new FDAlert(event.getReminders());
   }
   for (Button btn : alertsValueButtons) {
     checkAlertsButtonByAlert(alert, btn);
   }
 }
Ejemplo n.º 3
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);
   }
 }
Ejemplo n.º 4
0
 public FDJson editGoogleEvent(FDEvent event, FDCalendar cal) throws Exception {
   Map<String, String> params = new HashMap<String, String>();
   //		params.put("cid", cid);
   //		params.put("type", "2");
   //		params.put("eid", event.getId());
   //		JSONObject obj = event.toJsonObjByGoogle();
   //		params.put("text", obj.toString());
   params.put("method", "updateEvent");
   params.put("accountId", cal.getGoogleAccountId());
   params.put("calendarId", cal.getId());
   params.put("eventId", event.getId());
   JSONObject obj = event.toJsonObjByGoogle();
   params.put("params", obj.toString());
   FDPrintln.print(" edit Google Event params : " + obj.toString());
   FDJson json = sendPOSTRequestByJson("user/Google", params);
   return json;
 }
Ejemplo n.º 5
0
 /** 初始化地址输入按钮 */
 private void initLocationButton() {
   if (etLocation == null) {
     etLocation = (EditText) findViewById(R.id.etAddEventLocation);
     etLocation.setTypeface(StringUtil.getTypeFaceByRegular(mContext));
     etLocation.setFocusable(false);
     if (event != null) {
       etLocation.setText(event.getLocation());
     }
     etLocation.setOnClickListener(new OpenInputLocationOnClick());
   }
 }
Ejemplo n.º 6
0
 /** 初始化时区按钮 */
 private void initTimeZoneButton() {
   etTimeZone.setText(event != null ? event.getTimezone() : TimeZone.getDefault().getID());
   etTimeZone.setInputType(InputType.TYPE_NULL);
   etTimeZone.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           Intent intent = new Intent(AddPersonEventActivity.this, SelectTimeZoneActivity.class);
           startActivityForResult(intent, BACK_REQUEST_CODE_SELECTE_TIME_ZONE);
         }
       });
 }
Ejemplo n.º 7
0
 /** 计算时间,并写入时间显示栏 */
 private void writeTimeToTimeBar() {
   FDEvent e = event;
   if (e == null) {
     e = new FDEvent();
   }
   e.setFromHour(fromHour);
   e.setFromMinute(fromMinute);
   e.setToHour(toHour);
   e.setToMinute(toMinute);
   e.setToDate(toDay);
   e.setFromDate(fromDay);
   e.setAllDay(isAllDay);
   setComponent.setEventTime(e);
 }
Ejemplo n.º 8
0
    /**
     * ��ʾ�����¼�
     *
     * @param convertView
     * @param day
     */
    private boolean showPersonEvents(View convertView, final FDDay day, LinearLayout llEvents) {
      boolean isNoEvent = false;
      List<FDEvent> es = day.findEvent(events);

      if (es == null || es.size() == 0) {
        // createNoEvent(day, llEvents);
        isNoEvent = true;
      } else {
        Collections.sort(es);
        for (final FDEvent e : es) {
          if (e == null) continue;
          LinearLayout llEvent =
              (LinearLayout) mInflater.inflate(R.layout.view_schedule_item_event, null);
          TextView tvTitle = (TextView) llEvent.findViewById(R.id.tvViewScheduleEventName);
          tvTitle.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
          TextView tvTime = (TextView) llEvent.findViewById(R.id.tvViewScheduleEventTime);
          tvTime.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
          LinearLayout llBg = (LinearLayout) llEvent.findViewById(R.id.llScheduleItemEventBg);
          if (StringUtil.isNoBlank(e.getBackground())) {
            llBg.setBackgroundColor(Color.parseColor(e.getBackground()));
          }
          tvTime.setText(e.getFromAndToTimeString());
          tvTitle.setText(e.getTitle());
          llEvent.setOnClickListener(
              new OnClickListener() {
                public void onClick(View v) {
                  Intent intent = new Intent(getActivity(), ShowPersonEventActivity.class);
                  Bundle extras = new Bundle();
                  extras.putParcelable(FDEvent.BUNDLE_KEY, e);
                  intent.putExtras(extras);
                  startActivity(intent);
                }
              });
          llEvents.addView(llEvent);
        }
      }
      return isNoEvent;
    }
Ejemplo n.º 9
0
 /** 初始化日历选择框 */
 private void initCalendaAccount() {
   CalendarController cController = new CalendarController(this);
   LinearLayout llSelectAccount = (LinearLayout) findViewById(R.id.llAddEventSelecteAccount);
   llSelectAccount.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent = new Intent(AddPersonEventActivity.this, CalendarListActivity.class);
           intent.putExtra(
               CalendarListActivity.BUNDL_KEY_STATE, CalendarListActivity.STATE_CALENDARS);
           if (selectCalendar != null) {
             intent.putExtra(CalendarListActivity.BUNDL_KEY_CALENDAR_ID, selectCalendar.getId());
             intent.putExtra(
                 CalendarListActivity.BUNDL_KEY_CALENDAR_TYPE, selectCalendar.getType());
             intent.putExtra(CalendarListActivity.BUNDL_KEY_IS_EDIT, isEdit);
             intent.putExtra(
                 CalendarListActivity.BUNDL_KEY_CALENDAR_ACCOUNT, selectCalendar.getAccount());
           }
           startActivityForResult(intent, BACK_REQUEST_CODE_SELECTE_CALENDAR);
         }
       });
   ivCalendarBackground = (RoundPictureView) findViewById(R.id.ivAddEventSelectAccountBackground);
   tvCalendarAccount = (TextView) findViewById(R.id.tvAddEventSelectCalendarAccount);
   tvCalendarAccount.setTypeface(StringUtil.getTypeFaceByRegular(mContext));
   if (event != null) {
     selectCalendar = cController.getLocalCalendarById(event.getCalendarId());
     setSelectedCalendarValue();
     return;
   }
   ArrayList<FDCalendar> calendars = (ArrayList<FDCalendar>) cController.getLocalCalendarsa();
   for (int i = 0; calendars != null && i < calendars.size(); i++) {
     FDCalendar cal = calendars.get(i);
     if (cal.isDefault()) {
       selectCalendar = cal;
       setSelectedCalendarValue();
       break;
     }
   }
 }
Ejemplo n.º 10
0
 // 获取外部传入的事件
 private void getIntentToEvent() {
   Bundle extras = getIntent().getExtras();
   Calendar c = Calendar.getInstance();
   if (extras != null) {
     isEdit = extras.getBoolean(BUNDLE_KEY_IS_EDIT, false);
     event = (FDEvent) extras.getParcelable(FDEvent.BUNDLE_KEY);
     if (event != null) {
       fromHour = event.getFromHour();
       fromMinute = event.getFromMinute();
       toHour = event.getToHour();
       toMinute = event.getToMinute();
       isAllDay = event.isAllDay();
       c.set(Calendar.YEAR, event.getYear());
       c.set(Calendar.MONTH, event.getMonth() - 1);
       c.set(Calendar.DAY_OF_MONTH, event.getDay());
       fromDay = new FDDay(c);
       c.set(Calendar.YEAR, event.getToYear());
       c.set(Calendar.MONTH, event.getToMonth() - 1);
       c.set(Calendar.DAY_OF_MONTH, event.getToDay());
       toDay = new FDDay(c);
       etTitle.setText(event.getTitle());
       etNote.setText(event.getNote());
       if (null != event.getRecurrence()) {
         repeat = new FDRepeat(event.getRecurrence());
       }
       if (isEdit) {
         originalDay = fromDay;
       }
       return;
     }
     fromDay = (FDDay) extras.getParcelable(FDDay.BUNDLE_KEY);
     if (fromDay != null) {
       toDay = fromDay.clone();
       fromHour = c.get(Calendar.HOUR_OF_DAY);
       toHour = fromHour + 1;
       fromMinute = 0;
       toMinute = 0;
       isAllDay = false;
     }
   }
 }
Ejemplo n.º 11
0
 /**
  * 保存本地事件
  *
  * @param event 事件
  * @param cid 日历ID
  * @param calendarAccount 日历帐号
  * @return
  * @throws Exception
  */
 public FDEvent saveGo2Events(FDEvent event, FDCalendar cal) throws Exception {
   Map<String, String> params = new HashMap<String, String>();
   params.put("method", "add");
   params.put("title", event.getTitle());
   params.put("description", event.getNote());
   params.put("start", FDTimeFormatUtil.sdfAllDate.format(event.getFromDateByTimeZone()));
   params.put("timezone", event.getTimezone());
   params.put("end", FDTimeFormatUtil.sdfAllDate.format(event.getToDateByTimeZone()));
   params.put("isAllDay", event.isAllDay() ? "1" : "0");
   params.put("location", event.getLocation());
   params.put("cid", event.getCalendarId());
   params.put("recurrence", event.getRecurrence());
   params.put("recurringEventId", event.getRecurringEventId());
   params.put("status", event.getStatus() + "");
   params.put("originalStartTime", event.getOriginalStartTime());
   FDEvent receiveEvent = null;
   FDJson json = sendPOSTRequestByJson("user/privateEvent", params);
   if (json != null) {
     if (json.getStatusCode() != 1) {
       return null;
     }
     receiveEvent = new FDEvent(json.getData(), cal, FDCalendarAccount.TYPE_GO2);
   }
   return receiveEvent;
 }