Example usage for android.text.format Time Time

List of usage examples for android.text.format Time Time

Introduction

In this page you can find the example usage for android.text.format Time Time.

Prototype

public Time(Time other) 

Source Link

Document

A copy constructor.

Usage

From source file:pt.up.mobile.syncadapter.SigarraSyncAdapter.java

private void syncSchedule(Account account, SyncResult syncResult)
        throws JSONException, AuthenticationException, IOException {
    final User user = AccountUtils.getUser(getContext(), account.name);
    final String type;
    if (user.getType().equals(SifeupAPI.STUDENT_TYPE))
        type = SigarraContract.Schedule.STUDENT;
    else//from  www.j  av a 2s .c  o m
        type = SigarraContract.Schedule.EMPLOYEE;
    final Long mondayMillis = DateUtils.firstDayofWeek();
    Time monday = new Time(DateUtils.TIME_REFERENCE);
    monday.set(mondayMillis);
    monday.normalize(false);
    String initialDay = monday.format("%Y%m%d");
    // Friday
    monday.set(DateUtils.moveDayofWeek(mondayMillis, 4));
    monday.normalize(false);
    String finalDay = monday.format("%Y%m%d");
    getSchedule(account, user.getUserCode(), type, initialDay, finalDay, SyncStates.KEEP, syncResult);
}

From source file:org.dmfs.webcal.fragments.CalendarItemFragment.java

private void goToToday() {
    Time now = new Time(TimeZone.getDefault().getID());
    now.setToNow();/*from  w w  w .ja va 2 s . co m*/
    int nowIdx = (now.year << 16) + (now.month << 8) + now.monthDay;

    if (mSectionAdapter != null) {
        for (int i = 0, count = mSectionAdapter.getCount(); i < count; ++i) {
            long id = mSectionAdapter.getItemId(i);
            if (SectionTitlesAdapter.itemPos(id) == SectionTitlesAdapter.HEADER_ID) {
                if (SectionTitlesAdapter.sectionId(id) >= nowIdx) {
                    mListView.setSelectionFromTop(Math.min(mSectionAdapter.getCount() - 1, i + 1), 0);
                    return;
                }
            }
        }
    }

    // all events in the past, go to the end of the list
    mListView.setSelectionFromTop(mSectionAdapter.getCount() - 1, 0);
}

From source file:com.abiansoftware.lib.reader.AbianReaderData.java

public AbianReaderData() {
    m_itemVector = new Vector<AbianReaderItem>();
    m_newItemVector = new Vector<AbianReaderItem>();
    m_itemVector.clear();/*from w w w. j  a v  a2  s.c o  m*/
    m_lastUpdateTime = new Time(Time.getCurrentTimezone());
    m_lastUpdateTime.set(0);
    m_pageNumber = 1;
    m_autoUpdateTimeInMinutes = 0;
}

From source file:uk.org.openseizuredetector.SdServer.java

/** 
 * Checks the status of the connection to the pebble watch,
 * and sets class variables for use by other functions.
 * If the watch app is not running, it attempts to re-start it.
 *//* ww w.j  av  a2s  .c  o  m*/
public void getPebbleStatus() {
    Time tnow = new Time(Time.getCurrentTimezone());
    tnow.setToNow();
    // Check we are actually connected to the pebble.
    sdData.pebbleConnected = PebbleKit.isWatchConnected(this);
    // And is the pebble_sd app running?
    // set mPebbleAppRunningCheck has been false for more than 10 seconds
    // the app is not talking to us
    // mPebbleAppRunningCheck is set to true in the receiveData handler. 
    if (!mPebbleAppRunningCheck && ((tnow.toMillis(false) - mPebbleStatusTime.toMillis(false)) > 10000)) {
        Log.v(TAG, "tdiff = " + (tnow.toMillis(false) - mPebbleStatusTime.toMillis(false)));
        sdData.pebbleAppRunning = false;
        Log.v(TAG, "Pebble App Not Running - Attempting to Re-Start");
        startWatchApp();
        getPebbleSdSettings();
        if (mAudibleFaultWarning) {
            faultWarningBeep();
        }
    } else {
        sdData.pebbleAppRunning = true;
    }

    // if we have confirmation that the app is running, reset the
    // status time to now and initiate another check.
    if (mPebbleAppRunningCheck) {
        mPebbleAppRunningCheck = false;
        mPebbleStatusTime.setToNow();
    }

    if (!sdData.haveSettings) {
        Log.v(TAG, "getPebbleStatus() - no settings received yet - requesting");
        getPebbleSdSettings();
    }
}

From source file:com.xandy.calendar.AllInOneActivity.java

@Override
protected void onResume() {
    super.onResume();

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    mOnSaveInstanceStateCalled = false;/*from  ww w  .ja  v a 2 s  .c  om*/
    mContentResolver.registerContentObserver(CalendarContract.Events.CONTENT_URI, true, mObserver);
    if (mUpdateOnResume) {
        initFragments(mController.getTime(), mController.getViewType(), null);
        mUpdateOnResume = false;
    }
    Time t = new Time(mTimeZone);
    t.set(mController.getTime());
    mController.sendEvent(this, EventType.UPDATE_TITLE, t, t, -1, ViewType.CURRENT, mController.getDateFlags(),
            null, null);
    // Make sure the drop-down menu will get its date updated at midnight
    if (mActionBarMenuSpinnerAdapter != null) {
        mActionBarMenuSpinnerAdapter.refresh(this);
    }

    if (mControlsMenu != null) {
        mControlsMenu.setTitle(mHideControls ? mShowString : mHideString);
    }
    mPaused = false;

    if (mViewEventId != -1 && mIntentEventStartMillis != -1 && mIntentEventEndMillis != -1) {
        long currentMillis = System.currentTimeMillis();
        long selectedTime = -1;
        if (currentMillis > mIntentEventStartMillis && currentMillis < mIntentEventEndMillis) {
            selectedTime = currentMillis;
        }
        mController.sendEventRelatedEventWithExtra(this, EventType.VIEW_EVENT, mViewEventId,
                mIntentEventStartMillis, mIntentEventEndMillis, -1, -1,
                EventInfo.buildViewExtraLong(mIntentAttendeeResponse, mIntentAllDay), selectedTime);
        mViewEventId = -1;
        mIntentEventStartMillis = -1;
        mIntentEventEndMillis = -1;
        mIntentAllDay = false;
    }
    Utils.setMidnightUpdater(mHandler, mTimeChangesUpdater, mTimeZone);
    // Make sure the today icon is up to date
    invalidateOptionsMenu();

    mCalIntentReceiver = Utils.setTimeChangesReceiver(this, mTimeChangesUpdater);
}

From source file:org.dmfs.tasks.notification.NotificationUpdaterService.java

private void resolveDelayAction(Intent intent) {
    if (!(intent.hasExtra(EXTRA_TASK_DUE) && intent.hasExtra(EXTRA_TIMEZONE))) {
        return;//from   w w w  .  j a va 2  s  .com
    }
    final String action = intent.getAction();
    final Uri taskUri = intent.getData();
    long due = intent.getLongExtra(EXTRA_TASK_DUE, -1);
    String tz = intent.getStringExtra(EXTRA_TIMEZONE);
    boolean allDay = intent.getBooleanExtra(EXTRA_ALLDAY, false);

    int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);

    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
    notificationManager.cancel(notificationId);

    if (ACTION_DELAY_1H.equals(action)) {
        Time time = new Time(tz);
        time.set(due);
        time.allDay = false;
        time.hour++;
        time.normalize(true);
        delayTask(taskUri, time);
    } else if (ACTION_DELAY_1D.equals(action)) {
        if (tz == null) {
            tz = "UTC";
        }
        Time time = new Time(tz);
        time.set(due);
        time.allDay = allDay;
        time.monthDay++;
        time.normalize(true);
        delayTask(taskUri, time);
    }

}

From source file:org.dmfs.webcal.fragments.CalendarItemFragment.java

@Override
public void onItemClick(AdapterView<?> listView, View view, int position, long id) {
    Cursor cursor = (Cursor) listView.getAdapter().getItem(position);

    Time start = new Time(cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.TIMZONE)));
    start.set(cursor.getLong(cursor.getColumnIndex(WebCalReaderContract.Events.DTSTART)));
    start.allDay = cursor.getInt(cursor.getColumnIndex(WebCalReaderContract.Events.IS_ALLDAY)) != 0;

    Time end = new Time(cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.TIMZONE)));
    end.set(cursor.getLong(cursor.getColumnIndex(WebCalReaderContract.Events.DTEND)));
    end.allDay = start.allDay;/*from   w w w.j a  va2  s . com*/

    Event event = new Event(start, end,
            cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.TITLE)),
            cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.DESCRIPTION)),
            cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.LOCATION)));

    EventsPreviewActivity.show(getActivity(), event, mCalendarName, mIcon, mTitle);
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

private void init(Context context) {
    setFocusable(true);/*from ww w . ja v  a  2  s  .  c  o m*/

    // Allow focus in touch mode so that we can do keyboard shortcuts
    // even after we've entered touch mode.
    setFocusableInTouchMode(true);
    setClickable(true);
    setOnCreateContextMenuListener(this);

    mFirstDayOfWeek = Time.MONDAY;

    mCurrentTime = new Time(DayUtils.getTimeZone(context, mTZUpdater));
    long currentTime = System.currentTimeMillis();
    mCurrentTime.set(currentTime);
    mTodayJulianDay = Time.getJulianDay(currentTime, mCurrentTime.gmtoff);

    mEventTextPaint.setTextSize(EVENT_TEXT_FONT_SIZE);
    mEventTextPaint.setTextAlign(Align.LEFT);
    mEventTextPaint.setAntiAlias(true);

    int gridLineColor = 0xff707070;
    Paint p = mSelectionPaint;
    p.setColor(gridLineColor);
    p.setStyle(Style.FILL);
    p.setAntiAlias(false);

    p = mPaint;
    p.setAntiAlias(true);

    // Long day names
    mDayStrsLong = new String[14];

    // Allocate space for 2 weeks worth of weekday names so that we can
    // easily start the week display at any week day.
    mDayStrs = new String[14];

    // Also create an array of 2-letter abbreviations.
    mDayStrs2Letter = new String[14];

    for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
        int index = i - Calendar.SUNDAY;

        mDayStrsLong[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_LONG).toUpperCase();
        mDayStrsLong[index + 7] = mDayStrsLong[index];
        // e.g. Tue for Tuesday
        mDayStrs[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_MEDIUM).toUpperCase();
        mDayStrs[index + 7] = mDayStrs[index];
        // e.g. Tu for Tuesday
        mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORT).toUpperCase();

        // If we don't have 2-letter day strings, fall back to 1-letter.
        if (mDayStrs2Letter[index].equals(mDayStrs[index])) {
            mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORTEST);
        }

        mDayStrs2Letter[index + 7] = mDayStrs2Letter[index];
    }

    // Figure out how much space we need for the 3-letter abbrev names
    // in the worst case.
    p.setTextSize(DATE_HEADER_FONT_SIZE);
    p.setTypeface(mBold);
    String[] dateStrs = { " 28", " 30" };
    mDateStrWidth = computeMaxStringWidth(0, dateStrs, p);
    Time time = new Time();
    time.setJulianDay(mFirstJulianDay);
    String s = SimpleDateFormat.getDateInstance().format(new Date(time.toMillis(false)));
    mDateStrWidthLong = computeMaxStringWidth(0, new String[] { s }, p);
    p.setTextSize(DAY_HEADER_FONT_SIZE);
    mDateStrWidth += computeMaxStringWidth(0, mDayStrs, p);
    mDateStrWidthLong += computeMaxStringWidth(0, mDayStrsLong, p);

    p.setTextSize(HOURS_TEXT_SIZE);
    p.setTypeface(null);
    handleOnResume();

    mAmString = DateUtils.getAMPMString(Calendar.AM).toUpperCase();
    mPmString = DateUtils.getAMPMString(Calendar.PM).toUpperCase();
    String[] ampm = { mAmString, mPmString };
    p.setTextSize(AMPM_TEXT_SIZE);
    mHoursWidth = Math.max(HOURS_MARGIN, computeMaxStringWidth(mHoursWidth, ampm, p) + HOURS_RIGHT_MARGIN);
    mHoursWidth = Math.max(MIN_HOURS_WIDTH, mHoursWidth);

    LayoutInflater inflater;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Resources.Theme dialogTheme = getResources().newTheme();
    dialogTheme.applyStyle(android.R.style.Theme_Dialog, true);
    TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground });

    // Catch long clicks for creating a new event
    mBaseDate = new Time(DayUtils.getTimeZone(context, mTZUpdater));
    long millis = System.currentTimeMillis();
    mBaseDate.set(millis);

    mEarliestStartHour = new int[mNumDays];
    mHasAllDayEvent = new boolean[mNumDays];

    // mLines is the array of points used with Canvas.drawLines() in
    // drawGridBackground() and drawAllDayEvents().  Its size depends
    // on the max number of lines that can ever be drawn by any single
    // drawLines() call in either of those methods.
    final int maxGridLines = (24 + 1) // max horizontal lines we might draw
            + (mNumDays + 1); // max vertical lines we might draw
    mLines = new float[maxGridLines * 4];
}

From source file:com.android.calendar.AllInOneActivity.java

@Override
protected void onResume() {
    super.onResume();
    dynamicTheme.onResume(this);

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    mOnSaveInstanceStateCalled = false;/*from  ww w.  jav  a2s . c  o m*/
    mContentResolver.registerContentObserver(CalendarContract.Events.CONTENT_URI, true, mObserver);
    if (mUpdateOnResume) {
        initFragments(mController.getTime(), mController.getViewType(), null);
        mUpdateOnResume = false;
    }
    Time t = new Time(mTimeZone);
    t.set(mController.getTime());
    mController.sendEvent(this, EventType.UPDATE_TITLE, t, t, -1, ViewType.CURRENT, mController.getDateFlags(),
            null, null);

    if (mControlsMenu != null) {
        mControlsMenu.setTitle(mHideControls ? mShowString : mHideString);
    }
    mPaused = false;

    if (mViewEventId != -1 && mIntentEventStartMillis != -1 && mIntentEventEndMillis != -1) {
        long currentMillis = System.currentTimeMillis();
        long selectedTime = -1;
        if (currentMillis > mIntentEventStartMillis && currentMillis < mIntentEventEndMillis) {
            selectedTime = currentMillis;
        }
        mController.sendEventRelatedEventWithExtra(this, EventType.VIEW_EVENT, mViewEventId,
                mIntentEventStartMillis, mIntentEventEndMillis, -1, -1,
                EventInfo.buildViewExtraLong(mIntentAttendeeResponse, mIntentAllDay), selectedTime);
        mViewEventId = -1;
        mIntentEventStartMillis = -1;
        mIntentEventEndMillis = -1;
        mIntentAllDay = false;
    }
    Utils.setMidnightUpdater(mHandler, mTimeChangesUpdater, mTimeZone);
    // Make sure the today icon is up to date
    invalidateOptionsMenu();

    mCalIntentReceiver = Utils.setTimeChangesReceiver(this, mTimeChangesUpdater);
}

From source file:be.billington.calendar.recurrencepicker.RecurrencePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRecurrence.wkst = EventRecurrence.timeDay2Day(Utils.getFirstDayOfWeek(getActivity()));

    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    boolean endCountHasFocus = false;
    if (savedInstanceState != null) {
        RecurrenceModel m = (RecurrenceModel) savedInstanceState.get(BUNDLE_MODEL);
        if (m != null) {
            mModel = m;//  w  w  w.  j  ava  2 s  .c  o  m
        }
        endCountHasFocus = savedInstanceState.getBoolean(BUNDLE_END_COUNT_HAS_FOCUS);
    } else {
        Bundle b = getArguments();
        if (b != null) {
            mTime.set(b.getLong(BUNDLE_START_TIME_MILLIS));

            String tz = b.getString(BUNDLE_TIME_ZONE);
            if (!TextUtils.isEmpty(tz)) {
                mTime.timezone = tz;
            }
            mTime.normalize(false);

            // Time days of week: Sun=0, Mon=1, etc
            mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
            String rrule = b.getString(BUNDLE_RRULE);
            if (!TextUtils.isEmpty(rrule)) {
                mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
                mRecurrence.parse(rrule);
                copyEventRecurrenceToModel(mRecurrence, mModel);
                // Leave today's day of week as checked by default in weekly view.
                if (mRecurrence.bydayCount == 0) {
                    mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
                }
            }

        } else {
            mTime.setToNow();
        }
    }

    mResources = getResources();
    mView = inflater.inflate(R.layout.recurrencepicker, container, true);

    final Activity activity = getActivity();
    final Configuration config = activity.getResources().getConfiguration();

    mRepeatSwitch = (Switch) mView.findViewById(R.id.repeat_switch);
    mRepeatSwitch.setChecked(mModel.recurrenceState == RecurrenceModel.STATE_RECURRENCE);
    mRepeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mModel.recurrenceState = isChecked ? RecurrenceModel.STATE_RECURRENCE
                    : RecurrenceModel.STATE_NO_RECURRENCE;
            togglePickerOptions();
        }
    });

    mFreqSpinner = (Spinner) mView.findViewById(R.id.freqSpinner);
    mFreqSpinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.recurrence_freq, R.layout.recurrencepicker_freq_item);
    freqAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mFreqSpinner.setAdapter(freqAdapter);

    mInterval = (EditText) mView.findViewById(R.id.interval);
    mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) {
        @Override
        void onChange(int v) {
            if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) {
                mModel.interval = v;
                updateIntervalText();
                mInterval.requestLayout();
            }
        }
    });
    mIntervalPreText = (TextView) mView.findViewById(R.id.intervalPreText);
    mIntervalPostText = (TextView) mView.findViewById(R.id.intervalPostText);

    mEndNeverStr = mResources.getString(R.string.recurrence_end_continously);
    mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label);
    mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label);

    mEndSpinnerArray.add(mEndNeverStr);
    mEndSpinnerArray.add(mEndDateLabel);
    mEndSpinnerArray.add(mEndCountLabel);
    mEndSpinner = (Spinner) mView.findViewById(R.id.endSpinner);
    mEndSpinner.setOnItemSelectedListener(this);
    mEndSpinnerAdapter = new EndSpinnerAdapter(getActivity(), mEndSpinnerArray,
            R.layout.recurrencepicker_freq_item, R.layout.recurrencepicker_end_text);
    mEndSpinnerAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
    mEndSpinner.setAdapter(mEndSpinnerAdapter);

    mEndCount = (EditText) mView.findViewById(R.id.endCount);
    mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) {
        @Override
        void onChange(int v) {
            if (mModel.endCount != v) {
                mModel.endCount = v;
                updateEndCountText();
                mEndCount.requestLayout();
            }
        }
    });
    mPostEndCount = (TextView) mView.findViewById(R.id.postEndCount);

    mEndDateTextView = (TextView) mView.findViewById(R.id.endDate);
    mEndDateTextView.setOnClickListener(this);
    if (mModel.endDate == null) {
        mModel.endDate = new Time(mTime);
        switch (mModel.freq) {
        case RecurrenceModel.FREQ_DAILY:
        case RecurrenceModel.FREQ_WEEKLY:
            mModel.endDate.month += 1;
            break;
        case RecurrenceModel.FREQ_MONTHLY:
            mModel.endDate.month += 3;
            break;
        case RecurrenceModel.FREQ_YEARLY:
            mModel.endDate.year += 3;
            break;
        }
        mModel.endDate.normalize(false);
    }

    mWeekGroup = (LinearLayout) mView.findViewById(R.id.weekGroup);
    mWeekGroup2 = (LinearLayout) mView.findViewById(R.id.weekGroup2);

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    String[] dayOfWeekString = new DateFormatSymbols().getWeekdays();

    mMonthRepeatByDayOfWeekStrs = new String[7][];
    // from Time.SUNDAY as 0 through Time.SATURDAY as 6
    mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun);
    mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon);
    mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues);
    mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed);
    mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs);
    mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri);
    mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat);

    // In Time.java day of week order e.g. Sun = 0
    int idx = Utils.getFirstDayOfWeek(getActivity());

    // In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
    dayOfWeekString = new DateFormatSymbols().getShortWeekdays();

    int numOfButtonsInRow1;
    int numOfButtonsInRow2;

    if (mResources.getConfiguration().screenWidthDp > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
        numOfButtonsInRow1 = 7;
        numOfButtonsInRow2 = 0;
        mWeekGroup2.setVisibility(View.GONE);
        mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
    } else {
        numOfButtonsInRow1 = 4;
        numOfButtonsInRow2 = 3;

        mWeekGroup2.setVisibility(View.VISIBLE);
        // Set rightmost button on the second row invisible so it takes up
        // space and everything centers properly
        mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
    }

    /* First row */
    for (int i = 0; i < 7; i++) {
        if (i >= numOfButtonsInRow1) {
            mWeekGroup.getChildAt(i).setVisibility(View.GONE);
            continue;
        }

        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    /* 2nd Row */
    for (int i = 0; i < 3; i++) {
        if (i >= numOfButtonsInRow2) {
            mWeekGroup2.getChildAt(i).setVisibility(View.GONE);
            continue;
        }
        mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup2.getChildAt(i);
        mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
        mWeekByDayButtons[idx].setOnCheckedChangeListener(this);

        if (++idx >= 7) {
            idx = 0;
        }
    }

    mMonthGroup = (LinearLayout) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup = (RadioGroup) mView.findViewById(R.id.monthGroup);
    mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this);
    mRepeatMonthlyByNthDayOfWeek = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfTheWeek);
    mRepeatMonthlyByNthDayOfMonth = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfMonth);

    mDone = (Button) mView.findViewById(R.id.done);
    mDone.setOnClickListener(this);

    togglePickerOptions();
    updateDialog();
    if (endCountHasFocus) {
        mEndCount.requestFocus();
    }
    return mView;
}