use of com.android.calendar.agenda.AgendaFragment in project Etar-Calendar by Etar-Group.
the class AllInOneActivity method setMainPane.
private void setMainPane(FragmentTransaction ft, int viewId, int viewType, long timeMillis, boolean force) {
if (mOnSaveInstanceStateCalled) {
return;
}
if (!force && mCurrentView == viewType) {
return;
}
// Remove this when transition to and from month view looks fine.
boolean doTransition = viewType != ViewType.MONTH && mCurrentView != ViewType.MONTH;
FragmentManager fragmentManager = getFragmentManager();
// TODO remove this if framework ever supports nested fragments
if (mCurrentView == ViewType.AGENDA) {
// If it was, we need to do some cleanup on it to prevent the
// edit/delete buttons from coming back on a rotation.
Fragment oldFrag = fragmentManager.findFragmentById(viewId);
if (oldFrag instanceof AgendaFragment) {
((AgendaFragment) oldFrag).removeFragments(fragmentManager);
}
}
if (viewType != mCurrentView) {
// controller's and are used for intercepting the back button.
if (mCurrentView != ViewType.EDIT && mCurrentView > 0) {
mPreviousView = mCurrentView;
}
mCurrentView = viewType;
}
// Create new fragment
Fragment frag = null;
Fragment secFrag = null;
switch(viewType) {
case ViewType.AGENDA:
mNavigationView.getMenu().findItem(R.id.agenda_menu_item).setChecked(true);
frag = new AgendaFragment(timeMillis, false);
if (mIsTabletConfig) {
mToolbar.setTitle(R.string.agenda_view);
}
break;
case ViewType.DAY:
mNavigationView.getMenu().findItem(R.id.day_menu_item).setChecked(true);
frag = new DayFragment(timeMillis, 1);
if (mIsTabletConfig) {
mToolbar.setTitle(R.string.day_view);
}
break;
case ViewType.MONTH:
mNavigationView.getMenu().findItem(R.id.month_menu_item).setChecked(true);
frag = new MonthByWeekFragment(timeMillis, false);
if (mShowAgendaWithMonth) {
secFrag = new AgendaFragment(timeMillis, false);
}
if (mIsTabletConfig) {
mToolbar.setTitle(R.string.month_view);
}
break;
case ViewType.WEEK:
default:
mNavigationView.getMenu().findItem(R.id.week_menu_item).setChecked(true);
frag = new DayFragment(timeMillis, Utils.getDaysPerWeek(this));
if (mIsTabletConfig) {
mToolbar.setTitle(R.string.week_view);
}
break;
}
// current view.
if (mCalendarToolbarHandler != null) {
mCalendarToolbarHandler.setCurrentMainView(viewType);
}
if (!mIsTabletConfig) {
refreshActionbarTitle(timeMillis);
}
// Show date only on tablet configurations in views different than Agenda
if (!mIsTabletConfig) {
mDateRange.setVisibility(View.GONE);
} else if (viewType != ViewType.AGENDA) {
mDateRange.setVisibility(View.VISIBLE);
} else {
mDateRange.setVisibility(View.GONE);
}
// Clear unnecessary buttons from the option menu when switching from the agenda view
if (viewType != ViewType.AGENDA) {
clearOptionsMenu();
}
boolean doCommit = false;
if (ft == null) {
doCommit = true;
ft = fragmentManager.beginTransaction();
}
if (doTransition) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
}
ft.replace(viewId, frag);
if (mShowAgendaWithMonth) {
if (secFrag != null) {
ft.replace(R.id.secondary_pane, secFrag);
mSecondaryPane.setVisibility(View.VISIBLE);
} else {
mSecondaryPane.setVisibility(View.GONE);
Fragment f = fragmentManager.findFragmentById(R.id.secondary_pane);
if (f != null) {
ft.remove(f);
}
mController.deregisterEventHandler(R.id.secondary_pane);
}
}
if (DEBUG) {
Log.d(TAG, "Adding handler with viewId " + viewId + " and type " + viewType);
}
// If the key is already registered this will replace it
mController.registerEventHandler(viewId, (EventHandler) frag);
if (secFrag != null) {
mController.registerEventHandler(viewId, (EventHandler) secFrag);
}
if (doCommit) {
if (DEBUG) {
Log.d(TAG, "setMainPane AllInOne=" + this + " finishing:" + this.isFinishing());
}
ft.commit();
}
}
use of com.android.calendar.agenda.AgendaFragment in project Etar-Calendar by Etar-Group.
the class SearchActivity method initFragments.
private void initFragments(long timeMillis, String query) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction ft = fragmentManager.beginTransaction();
AgendaFragment searchResultsFragment = new AgendaFragment(timeMillis, true);
ft.replace(R.id.search_results, searchResultsFragment);
mController.registerEventHandler(R.id.search_results, searchResultsFragment);
ft.commit();
Time t = new Time();
t.set(timeMillis);
search(query, t);
}
Aggregations