use of android.app.Fragment 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 android.app.Fragment in project XobotOS by xamarin.
the class PreferenceActivity method startPreferencePanel.
/**
* Start a new fragment containing a preference panel. If the prefences
* are being displayed in multi-pane mode, the given fragment class will
* be instantiated and placed in the appropriate pane. If running in
* single-pane mode, a new activity will be launched in which to show the
* fragment.
*
* @param fragmentClass Full name of the class implementing the fragment.
* @param args Any desired arguments to supply to the fragment.
* @param titleRes Optional resource identifier of the title of this
* fragment.
* @param titleText Optional text of the title of this fragment.
* @param resultTo Optional fragment that result data should be sent to.
* If non-null, resultTo.onActivityResult() will be called when this
* preference panel is done. The launched panel must use
* {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
* @param resultRequestCode If resultTo is non-null, this is the caller's
* request code to be received with the resut.
*/
public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) {
if (mSinglePane) {
startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0);
} else {
Fragment f = Fragment.instantiate(this, fragmentClass, args);
if (resultTo != null) {
f.setTargetFragment(resultTo, resultRequestCode);
}
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(com.android.internal.R.id.prefs, f);
if (titleRes != 0) {
transaction.setBreadCrumbTitle(titleRes);
} else if (titleText != null) {
transaction.setBreadCrumbTitle(titleText);
}
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.addToBackStack(BACK_STACK_PREFS);
transaction.commitAllowingStateLoss();
}
}
use of android.app.Fragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ExpandedDesktop method removeFragment.
private void removeFragment() {
FragmentManager fragmentManager = getChildFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag(EXPANDED_DESKTOP_PREFERENCE_TAG);
if (fragment != null) {
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.remove(fragment).commit();
}
}
use of android.app.Fragment in project android_frameworks_base by ResurrectionRemix.
the class PrintActivity method showFragment.
private void showFragment(Fragment newFragment) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
Fragment oldFragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) {
transaction.remove(oldFragment);
}
if (newFragment != null) {
transaction.add(R.id.embedded_content_container, newFragment, FRAGMENT_TAG);
}
transaction.commitAllowingStateLoss();
getFragmentManager().executePendingTransactions();
}
use of android.app.Fragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class HighPowerDetail method onDismiss.
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
Fragment target = getTargetFragment();
if (target != null) {
target.onActivityResult(getTargetRequestCode(), 0, null);
}
}
Aggregations