Search in sources :

Example 1 with SelectVisibleCalendarsFragment

use of com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment in project Etar-Calendar by Etar-Group.

the class AllInOneActivity method initFragments.

private void initFragments(long timeMillis, int viewType, Bundle icicle) {
    if (DEBUG) {
        Log.d(TAG, "Initializing to " + timeMillis + " for view " + viewType);
    }
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    if (mShowCalendarControls) {
        Fragment miniMonthFrag = new MonthByWeekFragment(timeMillis, true);
        ft.replace(R.id.mini_month, miniMonthFrag);
        mController.registerEventHandler(R.id.mini_month, (EventHandler) miniMonthFrag);
        Fragment selectCalendarsFrag = new SelectVisibleCalendarsFragment();
        ft.replace(R.id.calendar_list, selectCalendarsFrag);
        mController.registerEventHandler(R.id.calendar_list, (EventHandler) selectCalendarsFrag);
    }
    if (!mShowCalendarControls || viewType == ViewType.EDIT) {
        mMiniMonth.setVisibility(View.GONE);
        mCalendarsList.setVisibility(View.GONE);
    }
    EventInfo info = null;
    if (viewType == ViewType.EDIT) {
        mPreviousView = GeneralPreferences.getSharedPreferences(this).getInt(GeneralPreferences.KEY_START_VIEW, GeneralPreferences.DEFAULT_START_VIEW);
        long eventId = -1;
        Intent intent = getIntent();
        Uri data = intent.getData();
        if (data != null) {
            try {
                eventId = Long.parseLong(data.getLastPathSegment());
            } catch (NumberFormatException e) {
                if (DEBUG) {
                    Log.d(TAG, "Create new event");
                }
            }
        } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) {
            eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
        }
        long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
        long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
        info = new EventInfo();
        if (end != -1) {
            info.endTime = new Time();
            info.endTime.set(end);
        }
        if (begin != -1) {
            info.startTime = new Time();
            info.startTime.set(begin);
        }
        info.id = eventId;
        // We set the viewtype so if the user presses back when they are
        // done editing the controller knows we were in the Edit Event
        // screen. Likewise for eventId
        mController.setViewType(viewType);
        mController.setEventId(eventId);
    } else {
        mPreviousView = viewType;
    }
    setMainPane(ft, R.id.main_pane, viewType, timeMillis, true);
    // this needs to be after setMainPane()
    ft.commit();
    Time t = new Time(mTimeZone);
    t.set(timeMillis);
    if (viewType == ViewType.AGENDA && icicle != null) {
        mController.sendEvent(this, EventType.GO_TO, t, null, icicle.getLong(BUNDLE_KEY_EVENT_ID, -1), viewType);
    } else if (viewType != ViewType.EDIT) {
        mController.sendEvent(this, EventType.GO_TO, t, null, -1, viewType);
    }
}
Also used : SelectVisibleCalendarsFragment(com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment) FragmentTransaction(android.app.FragmentTransaction) EventInfo(com.android.calendar.CalendarController.EventInfo) Intent(android.content.Intent) Time(android.text.format.Time) MonthByWeekFragment(com.android.calendar.month.MonthByWeekFragment) SelectVisibleCalendarsFragment(com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment) AgendaFragment(com.android.calendar.agenda.AgendaFragment) Fragment(android.app.Fragment) MonthByWeekFragment(com.android.calendar.month.MonthByWeekFragment) Uri(android.net.Uri)

Aggregations

Fragment (android.app.Fragment)1 FragmentTransaction (android.app.FragmentTransaction)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Time (android.text.format.Time)1 EventInfo (com.android.calendar.CalendarController.EventInfo)1 AgendaFragment (com.android.calendar.agenda.AgendaFragment)1 MonthByWeekFragment (com.android.calendar.month.MonthByWeekFragment)1 SelectVisibleCalendarsFragment (com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment)1