Exemplo n.º 1
0
    /**
     * ��ʾ���˻
     *
     * @param convertView
     * @param day
     * @param llEvents
     */
    private void showSocialEvents(
        View convertView, FDDay day, LinearLayout llEvents, boolean isNoEvent, final int position) {
      // Calendar calToday = day.getTodayCalendar();
      if (day == null) return;
      //  ������˻��ʱ��
      Map<String, FDTimeEntity> socialEventTodaysTime = null;
      // �ҵ���������ж��˻
      List<FDSocialEvent> todayEvents = day.findSocials(mSocialEvents, socialEventTodaysTime);

      // System.out.println("today social events :"+todayEvents.size());
      if (isNoEvent && todayEvents.size() == 0) {
        createNoEvent(day, llEvents);
      }
      int index = 0;
      for (final FDSocialEvent socialEvent : todayEvents) {
        index++;
        if (socialEvent == null) continue;
        FrameLayout llEvent =
            (FrameLayout) mInflater.inflate(R.layout.view_schedule_item_social, null);
        TextView tvTitle = (TextView) llEvent.findViewById(R.id.tvViewScheduleSocialEventName);
        tvTitle.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
        TextView tvTime = (TextView) llEvent.findViewById(R.id.tvViewScheduleSocialEventTime);
        tvTime.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
        LinearLayout llTransparent =
            (LinearLayout) llEvent.findViewById(R.id.llScheduleSocialEventBg);
        tvTitle.setText(socialEvent.getTitle());
        if (socialEventTodaysTime != null) {
          FDTimeEntity todayEventTime = socialEventTodaysTime.get(socialEvent.getId());
          tvTime.setText(todayEventTime == null ? "" : todayEventTime.getScheduleFormatTime());
        }
        llEvent.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(getActivity(), ShowSocialGo2Activity.class);
                intent.putExtra(FDSocialEvent.BUNDLE_KEY, socialEvent);
                startActivityForResult(
                    intent, MainNoticesFragment.REQUEST_CODE_MANAGER_DATA_UPDATE);
              }
            });
        final ImageView imgBg = (ImageView) llEvent.findViewById(R.id.imgScheduleSocialEventBg);

        if (StringUtil.isNoBlank(socialEvent.getImgUrl())) {
          imageLoader.displayImage(BaseService.WEB_HOST + socialEvent.getThumbnail(), imgBg);
        } else {
          llTransparent.setVisibility(View.GONE);
          imgBg.setImageResource(R.drawable.social_event);
        }
        llEvents.addView(llEvent);
      }
    }
 /**
  * 检测按钮是否有在提醒时间内,是则显示为红色
  *
  * @param alert
  * @param btn
  */
 private void checkAlertsButtonByAlert(FDAlert alert, Button btn) {
   int minute = (Integer) btn.getTag();
   if (alert != null) {
     if (alert.isUseDefault()) { // 使用日历的默认提醒时间
       useCalendarDefaultReminder(btn, minute);
     } else {
       if (alert.getOverrides() != null) {
         for (int j = 0; j < alert.getOverrides().size(); j++) {
           Map<String, String> reminder = alert.getOverrides().get(j);
           if (reminder != null) {
             String minuteString = reminder.get(FDAlert.REMINDERS_KEY_MINUTES);
             if (StringUtil.isNoBlank(minuteString)) {
               try {
                 int reminderMinute = Integer.parseInt(minuteString);
                 checkReminderMinute(btn, minute, reminderMinute);
               } catch (NumberFormatException e) {
                 e.printStackTrace();
               }
             }
           }
         }
       }
     }
   } else if (!isEdit) { // 创建事件时,使用日历的默认提醒时间
     useCalendarDefaultReminder(btn, minute);
   }
 }
Exemplo n.º 3
0
 /**
  * 解析google事件列表
  *
  * @param cal
  * @param json
  * @return
  * @throws JSONException
  */
 private List<FDEvent> getGoogleEventsByJson(FDCalendar cal, String json) throws JSONException {
   List<FDEvent> events = new ArrayList<FDEvent>();
   if (StringUtil.isBlank(json) || json.length() < 5) return events;
   JSONObject jObj = new JSONObject(json);
   JSONObject obj = null;
   if (jObj.has("data")) {
     obj = jObj.getJSONObject("data");
     String itemsJson = jObj.getJSONObject("data").toString();
     //			System.out.println("items : "+itemsJson);
     //			System.out.println("obj : "+obj);
   }
   // 当json返回为空或是数字时,不作处理,返回无数据集合出去
   if (obj == null) {
     return events;
   }
   if (obj != null) {
     if (obj.has("items")) {
       setItemsToList(cal, events, obj);
     } else if (obj.has("data")) {
       JSONObject itemsJson = obj.getJSONObject("data");
       if (itemsJson.has("items")) {
         setItemsToList(cal, events, itemsJson);
       }
     }
   }
   return events;
 }
Exemplo n.º 4
0
  private void initSearchComponent() {
    //		etSearch = (EditText) mView.findViewById(R.id.etHomeSearch);
    etSearch = new EditText(getActivity());
    Drawable drawable = getResources().getDrawable(R.drawable.search_white);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    etSearch.setCompoundDrawables(drawable, null, null, null);
    etSearch.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
    etSearch.setFocusable(true);
    etSearch.setHint(R.string.eventName);
    etSearch.setFocusableInTouchMode(true);
    LayoutParams params = etSearch.getLayoutParams();
    if (params == null) {
      params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    }
    params.height = LayoutParams.WRAP_CONTENT;
    params.width = LayoutParams.MATCH_PARENT;
    etSearch.setLayoutParams(params);
    LinearLayout llSearch = new LinearLayout(getActivity());
    llSearch.setPadding(3, 3, 3, 3);
    llSearch.addView(etSearch);
    plvManage.getRefreshableView().addHeaderView(llSearch);
    etSearch.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            mManageAdapter.filterEventsByText(s.toString());
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
 /** 初始化标题栏 */
 private void initTitleBar() {
   LinearLayout llBar = (LinearLayout) findViewById(R.id.llTitleBarMid);
   TextView tvTitle = new TextView(this);
   tvTitle.setTypeface(StringUtil.getTypeFaceByRegular(mContext));
   tvTitle.setTextColor(Color.WHITE);
   tvTitle.setText(event == null ? R.string.newEvent : R.string.editEvent);
   tvTitle.setTextSize(22.0f);
   llBar.addView(tvTitle);
 }
Exemplo n.º 6
0
 /** ��ʼ��schdule ҳ�� */
 private void initSchdule() {
   lvDays = (ListView) mView.findViewById(R.id.lvScheduleCalendarDays);
   calendarComponent = (CalendarComponent) mView.findViewById(R.id.ccSchedule);
   calendarComponent.setExtentionCalendar(true);
   tvMonth = (TextView) mView.findViewById(R.id.tvScheduleCalendarMonth);
   tvMonth.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
   llCalendarComponent = (LinearLayout) mView.findViewById(R.id.llScheduleCalendar);
   initData();
 }
 /**
  * 根据分钟得到显示于提醒按钮的字符串
  *
  * @param minute
  * @return
  */
 private String getAlertsString(int minute) {
   String alertsString = minute + " m";
   if (minute >= 30 && minute < 24 * 60) {
     float hour = (minute / (float) 60);
     alertsString = StringUtil.getFloatStringToTime(hour) + " h";
   } else if (minute >= 24 * 60) {
     alertsString = minute / (60 * 24) + " d";
   }
   return alertsString;
 }
Exemplo n.º 8
0
 // ��ʼ��������ť
 private void initCreateComponent() {
   Button btnCreate = (Button) mView.findViewById(R.id.btnHomeCreate);
   btnCreate.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
   btnCreate.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           View layout = mInflater.inflate(R.layout.custom_dialog_creat_event, null, false);
           final Dialog dialog = new Dialog(getActivity(), R.style.dialog);
           dialog.setContentView(layout);
           dialog.setCancelable(true);
           dialog.show();
           Window win = dialog.getWindow();
           win.getDecorView().setPadding(0, 0, 0, 0);
           WindowManager.LayoutParams lp = win.getAttributes();
           lp.width = WindowManager.LayoutParams.MATCH_PARENT;
           lp.height = WindowManager.LayoutParams.MATCH_PARENT;
           win.setAttributes(lp);
           Button btnCancel = (Button) layout.findViewById(R.id.btnCustomDialogCreateEventCancel);
           btnCancel.setOnClickListener(
               new OnClickListener() {
                 @Override
                 public void onClick(View v) {
                   dialog.dismiss();
                 }
               });
           final Bundle extras = new Bundle();
           extras.putParcelable(FDDay.BUNDLE_KEY, new FDDay(Calendar.getInstance()));
           Button btnSocial =
               (Button) layout.findViewById(R.id.btnCustomDialogCreateEventSocialEvent);
           btnSocial.setOnClickListener(
               new OnClickListener() {
                 @Override
                 public void onClick(View v) {
                   Intent socialIntent = new Intent(getActivity(), AddSocialGo2OneActivity.class);
                   socialIntent.putExtras(extras);
                   startActivity(socialIntent);
                   dialog.dismiss();
                 }
               });
           Button btnPerson =
               (Button) layout.findViewById(R.id.btnCustomDialogCreateEventPersonal);
           btnPerson.setOnClickListener(
               new OnClickListener() {
                 @Override
                 public void onClick(View v) {
                   Intent personalIntent = new Intent(getActivity(), AddPersonGo2Activity.class);
                   personalIntent.putExtras(extras);
                   startActivity(personalIntent);
                   dialog.dismiss();
                 }
               });
         }
       });
 }
Exemplo n.º 9
0
 public View getView(int position, View convertView, ViewGroup parent) {
   final FDDay day = (FDDay) getItem(position);
   if (day != null) {
     tvMonth.setText(getResources().getString(R.string.month_simple_tag_1 + day.getMonth() - 1));
   }
   DaysCache cache = null;
   if (convertView == null) {
     cache = new DaysCache();
     convertView = mInflater.inflate(R.layout.item_tab_schedule, parent, false);
     cache.tvDay = (TextView) convertView.findViewById(R.id.tvItemTabScheduleDay);
     cache.tvDay.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
     cache.tvWeek = (TextView) convertView.findViewById(R.id.tvItemTabScheduleWeek);
     cache.tvWeek.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
     cache.llEvents = (LinearLayout) convertView.findViewById(R.id.llItemTabScheduleEvents);
     convertView.setTag(cache);
   } else {
     cache = (DaysCache) convertView.getTag();
   }
   TextView tvDay = cache.tvDay;
   TextView tvWeek = cache.tvWeek;
   LinearLayout llEvents = cache.llEvents;
   llEvents.removeAllViews();
   if (day == null) {
     return convertView;
   }
   tvDay.setText(day.getDay() + "");
   String weekTag =
       getActivity()
           .getResources()
           .getString(R.string.week_simple_tag_1 + day.getDayOfWeek() - 1);
   tvWeek.setText(weekTag);
   if (day.isToday()) {
     tvDay.setTextColor(getActivity().getResources().getColor(R.color.main_blue));
     tvWeek.setTextColor(getActivity().getResources().getColor(R.color.main_blue));
   } else {
     tvDay.setTextColor(getActivity().getResources().getColor(R.color.main_gray));
     tvWeek.setTextColor(getActivity().getResources().getColor(R.color.main_gray));
   }
   boolean isNoEvent = showPersonEvents(convertView, day, llEvents);
   showSocialEvents(convertView, day, llEvents, isNoEvent, position);
   return convertView;
 }
Exemplo n.º 10
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());
   }
 }
Exemplo n.º 11
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;
    }
Exemplo n.º 12
0
 // 初始化重复值
 private void initRepeatButtons() {
   tvRepeatValue = (TextView) findViewById(R.id.tvAddPersonEventRepeatValue);
   tvRepeatValue.setTypeface(StringUtil.getTypeFaceByRegular(mContext));
   setRepeatToView();
   RelativeLayout rlRepeat = (RelativeLayout) findViewById(R.id.rlAddPersonRepeat);
   rlRepeat.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           Intent repeatIntent = new Intent(AddPersonEventActivity.this, RepeatActivity.class);
           repeatIntent.putExtra(FDRepeat.BUNDLE_KEY, repeat);
           startActivityForResult(repeatIntent, BACK_REQUEST_CODE_REPEAT);
         }
       });
   setRepeatToView();
 }
Exemplo n.º 13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_person_event);
    etNote = (EditText) findViewById(R.id.etAddEventNote);
    etNote.setTypeface(StringUtil.getTypeFaceByRegular(mContext));

    etTimeZone = (EditText) findViewById(R.id.etAddEventTimeZone);
    etTimeZone.setTypeface(StringUtil.getTypeFaceByRegular(mContext));
    initTitleComponent();
    eventControl = new EventController(AddPersonEventActivity.this);
    getIntentToEvent();
    initSubmitButton();
    initCalendaAccount();
    initTimeZoneButton();
    initTitleBar();
    initSelecteTimeButton();
    initRepeatButtons();
    initAlertsButton();
    hideImputOnScrolling();
    initLocationButton();
    setTitleBarLeftButtonToBack();
    //		setTitleBarLeftButtonToBack();
  }
Exemplo n.º 14
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;
     }
   }
 }
Exemplo n.º 15
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    //		System.out.println("requestCode : "+requestCode+ "  result code "+ resultCode+"
    // data:"+data);
    if (requestCode == BACK_REQUEST_CODE_SELECTE_TIME) { // 选择时间返回
      if (data != null) {
        Bundle extras = data.getExtras();
        fromHour = extras.getInt(SelectTimeActivity.BUNDLER_KEY_FROM_HOUR);
        fromMinute = extras.getInt(SelectTimeActivity.BUNDLER_KEY_FROM_MINUTE);
        toHour = extras.getInt(SelectTimeActivity.BUNDLER_KEY_TO_HOUR);
        toMinute = extras.getInt(SelectTimeActivity.BUNDLER_KEY_TO_MINUTE);
        isAllDay = extras.getBoolean(SelectTimeActivity.BUNDLER_KEY_IS_ALLDAY);

        fromDay = (FDDay) extras.getParcelable(SelectTimeActivity.BUNDLER_KEY_FROM_DAY);
        toDay = (FDDay) extras.getParcelable(SelectTimeActivity.BUNDLER_KEY_TO_DAY);
        writeTimeToTimeBar();
        //				resetRadioButton();
      }
    } else if (requestCode == BACK_REQUEST_CODE_LOCATION) { // 选择地址
      if (data != null) {
        Bundle extras = data.getExtras();
        if (extras == null) return;
        final FDGooglePlace place =
            (FDGooglePlace) extras.getSerializable(FDGooglePlace.BUNDLE_KEY);
        if (place != null) {
          etLocation.setText(place.getDescription());
          if (StringUtil.isNoBlank(place.getReference())) { // 有地图引用,则打开地图显示
            new Thread(
                    new Runnable() {
                      public void run() {
                        try {
                          FDGoogleDetail detail =
                              FDGoogleMapsHttpUtil.getLocationByReference(place.getReference());
                          mapHand.sendMessage(mapHand.obtainMessage(1, detail));
                        } catch (Exception e) {
                          e.printStackTrace();
                        }
                      }
                    })
                .start();
          } else {
            //						llMap.setVisibility(View.GONE);
            mLatitude = 0;
            mLongitude = 0;
          }
        }
      }
    } else if (requestCode == BACK_REQUEST_CODE_SELECTE_TIME_ZONE) {
      if (data != null) {
        etTimeZone.setText(data.getStringExtra("timezone"));
      }
    } else if (requestCode == BACK_REQUEST_CODE_SELECTE_CALENDAR) {
      if (data != null) {
        selectCalendar = data.getParcelableExtra(FDCalendar.BUNDL_KEY);
        setSelectedCalendarValue();
        showAlertsInView();
      }
    } else if (requestCode == BACK_REQUEST_CODE_REPEAT) {
      if (data != null) {
        repeat = data.getParcelableExtra(FDRepeat.BUNDLE_KEY);
        setRepeatToView();
      }
    }
  }
Exemplo n.º 16
0
 /** 初始化标题输入框 */
 private void initTitleComponent() {
   etTitle = (EditText) findViewById(R.id.etEventTitle);
   etTitle.setTypeface(StringUtil.getTypeFaceByRegular(mContext));
   etTitle.setOnEditorActionListener(new DisableEnterButtonOnEditorActionListerner());
 }