List of usage examples for android.support.v4.app FragmentManager POP_BACK_STACK_INCLUSIVE
int POP_BACK_STACK_INCLUSIVE
To view the source code for android.support.v4.app FragmentManager POP_BACK_STACK_INCLUSIVE.
Click Source Link
From source file:com.pdmanager.views.patient.TechnicianActivity.java
@Override public void onMessageReceived(final CNMessage cnMessage) { if (application.getUniqueId().equals(cnMessage.getUniqueId())) { return;// w w w. j a va 2 s . co m } if (cnMessage.getMessageType() == CNMessage.CNMessageType.Calling) { if (application.isInConference()) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.Busy, null); return; } callDialog = new AlertDialog.Builder(this).create(); LayoutInflater inflater = getLayoutInflater(); View incomingCallDialog = inflater.inflate(R.layout.incoming_call_dialog, null); incomingCallDialog.setAlpha(0.5f); callDialog.setView(incomingCallDialog); TextView caller = (TextView) incomingCallDialog.findViewById(R.id.caller); caller.setText(cnMessage.getDisplayName()); Button answerButton = (Button) incomingCallDialog.findViewById(R.id.answer_button); answerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.setConferenceId(cnMessage.getConferenceId()); application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerAccept, null); callDialog.hide(); currentRingtone.stop(); Intent intent = new Intent(application.getContext(), TechnicianActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intent); application.join(application.getConferenceId(), true); } }); Button declineButton = (Button) incomingCallDialog.findViewById(R.id.decline_button); declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerDecline, null); currentRingtone.stop(); callDialog.hide(); } }); callDialog.setCancelable(false); callDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //play current Ringtone currentRingtone.play(); callDialog.show(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.Cancel) { currentRingtone.stop(); callDialog.hide(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.EndCall) { if (application.leave()) { int count = getFragmentManager().getBackStackEntryCount(); String name = getFragmentManager().getBackStackEntryAt(count - 2).getName(); getFragmentManager().popBackStack(name, FragmentManager.POP_BACK_STACK_INCLUSIVE); } } }
From source file:org.alfresco.mobile.android.application.fragments.workflow.CreateTaskFragment.java
@Override public void onNodeSelected(String fieldId, Map<String, Node> p) { if (p == null) { return;/*from www .ja v a 2 s .c o m*/ } items.clear(); for (Entry<String, Node> entry : p.entrySet()) { items.put(entry.getKey(), (Document) entry.getValue()); } // Update documents updateDocuments(); getActivity().getSupportFragmentManager().popBackStackImmediate(DocumentPickerFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); }
From source file:org.envirocar.app.activity.MainActivity.java
private void openFragment(int position) { FragmentManager manager = getSupportFragmentManager(); switch (position) { // Go to the dashboard case DASHBOARD: if (isFragmentVisible(DASHBOARD_TAG)) { break; }/*from ww w . ja v a 2 s . co m*/ Fragment dashboardFragment = getSupportFragmentManager().findFragmentByTag(DASHBOARD_TAG); if (dashboardFragment == null) { dashboardFragment = new DashboardFragment(); } manager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); manager.beginTransaction().replace(R.id.content_frame, dashboardFragment, DASHBOARD_TAG).commit(); break; //Start the Login activity case LOGIN: if (UserManager.instance().isLoggedIn()) { UserManager.instance().logOut(); ListTracksFragment listMeasurementsFragment = (ListTracksFragment) getSupportFragmentManager() .findFragmentByTag("MY_TRACKS"); // check if this fragment is initialized if (listMeasurementsFragment != null) { listMeasurementsFragment.clearRemoteTracks(); } else { //the remote tracks need to be removed in any case DbAdapterImpl.instance().deleteAllRemoteTracks(); } Crouton.makeText(this, R.string.bye_bye, Style.CONFIRM).show(); } else { if (isFragmentVisible(LOGIN_TAG)) { break; } LoginFragment loginFragment = new LoginFragment(); manager.beginTransaction().replace(R.id.content_frame, loginFragment, LOGIN_TAG) .addToBackStack(null).commit(); } break; // Go to the settings case SETTINGS: Intent configIntent = new Intent(this, SettingsActivity.class); startActivity(configIntent); break; // Go to the track list case MY_TRACKS: if (isFragmentVisible(MY_TRACKS_TAG)) { break; } ListTracksFragment listMeasurementFragment = new ListTracksFragment(); manager.beginTransaction().replace(R.id.content_frame, listMeasurementFragment, MY_TRACKS_TAG) .addToBackStack(null).commit(); break; // Start or stop the measurement process case START_STOP_MEASUREMENT: if (!navDrawerItems[position].isEnabled()) return; SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(this.getApplicationContext()); String remoteDevice = preferences.getString(org.envirocar.app.activity.SettingsActivity.BLUETOOTH_KEY, null); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null && adapter.isEnabled() && remoteDevice != null) { if (CarManager.instance().getCar() == null) { Intent settingsIntent = new Intent(this, SettingsActivity.class); startActivity(settingsIntent); } else { /* * We are good to go. process the state and stuff */ OnTrackModeChangeListener trackModeListener = new OnTrackModeChangeListener() { @Override public void onTrackModeChange(int tm) { trackMode = tm; } }; createStartStopUtil().processButtonClick(trackModeListener); } } else { Intent settingsIntent = new Intent(this, SettingsActivity.class); startActivity(settingsIntent); } break; case HELP: if (isFragmentVisible(HELP_TAG)) { break; } HelpFragment helpFragment = new HelpFragment(); manager.beginTransaction().replace(R.id.content_frame, helpFragment, HELP_TAG).addToBackStack(null) .commit(); break; case SEND_LOG: if (isFragmentVisible(SEND_LOG_TAG)) { break; } SendLogFileFragment logFragment = new SendLogFileFragment(); manager.beginTransaction().replace(R.id.content_frame, logFragment, SEND_LOG_TAG).addToBackStack(null) .commit(); default: break; case LOGBOOK: if (isFragmentVisible(LOGBOOK_TAG)) { break; } LogbookFragment logbookFragment = new LogbookFragment(); manager.beginTransaction().replace(R.id.content_frame, logbookFragment, LOGBOOK_TAG) .addToBackStack(null).commit(); break; } drawer.closeDrawer(drawerList); }
From source file:org.videolan.vlc.gui.VLCMainActivity.java
/** * Hide the current secondary fragment./*from w w w . j a va 2s . co m*/ */ public void popSecondaryFragment() { FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); mCurrentFragment = mPreviousFragment; }
From source file:li.barter.activities.AbstractBarterLiActivity.java
/** * Helper method to load fragments into layout * * @param containerResId The container resource Id in the content view into which to load the * fragment//from w w w .j av a2 s . c o m * @param fragment The fragment to load * @param tag The fragment tag * @param addToBackStack Whether the transaction should be addded to the backstack * @param backStackTag The tag used for the backstack tag * @param customAnimate Whether to provide a custom animation for the Fragment. If * <code>true</code>, the Fragment also needs to be annotated with a * {@linkplain li.barter.fragments.FragmentTransition} annotation which * describes the transition to perform. If <code>false</code>, will use * default fragment transition * @param remove Whether the fragment should be removed before adding it */ public void loadFragment(final int containerResId, final AbstractBarterLiFragment fragment, final String tag, final boolean addToBackStack, final String backStackTag, final boolean customAnimate, final boolean remove) { final FragmentManager fragmentManager = getSupportFragmentManager(); if (remove) { fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); fragmentManager.beginTransaction().remove(fragment).commit(); fragmentManager.executePendingTransactions(); } final FragmentTransaction transaction = fragmentManager.beginTransaction(); if (customAnimate) { final FragmentTransition fragmentTransition = fragment.getClass() .getAnnotation(FragmentTransition.class); if (fragmentTransition != null) { transaction.setCustomAnimations(fragmentTransition.enterAnimation(), fragmentTransition.exitAnimation(), fragmentTransition.popEnterAnimation(), fragmentTransition.popExitAnimation()); } } transaction.replace(containerResId, fragment, tag); if (addToBackStack) { transaction.addToBackStack(backStackTag); } transaction.commit(); }
From source file:com.sim2dial.dialer.LinphoneActivity.java
private void changeFragmentForTablets(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) { if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) { if (newFragmentType == FragmentsAvailable.DIALER) { showStatusBar();/* ww w .j av a 2s . co m*/ } else { hideStatusBar(); } } // if (statusFragment != null) // { // statusFragment.closeStatusBar(); // } //LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) { // ll.setVisibility(View.VISIBLE); transaction.addToBackStack(newFragmentType.toString()); //transaction.replace(R.id.fragmentContainer2, newFragment); } else { // if (newFragmentType == FragmentsAvailable.DIALER || newFragmentType == FragmentsAvailable.ABOUT || newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT // || newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS || newFragmentType == FragmentsAvailable.SETTINGS || newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) //{ // ll.setVisibility(View.GONE); //} //else //{ // ll.setVisibility(View.INVISIBLE); //} if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) { if (newFragmentType.isRightOf(currentFragment)) { transaction.setCustomAnimations(R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right); } else { transaction.setCustomAnimations(R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left); } } try { getSupportFragmentManager().popBackStackImmediate(newFragmentType.toString(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } catch (java.lang.IllegalStateException e) { } transaction.addToBackStack(newFragmentType.toString()); transaction.replace(R.id.fragmentContainer, newFragment); } transaction.commitAllowingStateLoss(); getSupportFragmentManager().executePendingTransactions(); currentFragment = newFragmentType; }
From source file:com.openerp.MainActivity.java
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { int item_position = position - 1; DrawerItem item = mDrawerListItems.get(item_position); if (!item.isGroupTitle()) { if (!item.getKey().equals("com.openerp.settings")) { mDrawerItemSelectedPosition = item_position + 1; }//w w w . ja v a 2 s. co m android.support.v4.app.FragmentManager fm1 = getSupportFragmentManager(); fm1.popBackStack("product", FragmentManager.POP_BACK_STACK_INCLUSIVE); fm1.popBackStack(); mAppTitle = item.getTitle(); loadFragment(item); mDrawerLayout.closeDrawers(); } mDrawerListView.setItemChecked(mDrawerItemSelectedPosition, true); }
From source file:bf.io.openshop.ux.MainActivity.java
/** * Method clear fragment backStack (back history). On bottom of stack will remain Fragment added by {@link #addInitialFragment()}. *//*from www . j a v a 2 s. c o m*/ private void clearBackStack() { Timber.d("Clearing backStack"); FragmentManager manager = getSupportFragmentManager(); if (manager.getBackStackEntryCount() > 0) { if (BuildConfig.DEBUG) { for (int i = 0; i < manager.getBackStackEntryCount(); i++) { Timber.d("BackStack content_%d= id: %d, name: %s", i, manager.getBackStackEntryAt(i).getId(), manager.getBackStackEntryAt(i).getName()); } } FragmentManager.BackStackEntry first = manager.getBackStackEntryAt(0); manager.popBackStack(first.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } Timber.d("backStack cleared."); // TODO maybe implement own fragment backStack handling to prevent banner fragment recreation during clearing. // http://stackoverflow.com/questions/12529499/problems-with-android-fragment-back-stack }
From source file:org.namelessrom.devicecontrol.MainActivity.java
private void loadFragmentPrivate(final int i, final boolean onResume) { switch (i) {/*from ww w . j a v a2 s . c om*/ default: // slip through... //-------------------------------------------------------------------------------------- case DeviceConstants.ID_ABOUT: if (!onResume) mCurrentFragment = new AboutFragment(); mTitle = mFragmentTitle = R.string.app_name; mSubFragmentTitle = -1; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_DEVICE_INFORMATION: if (!onResume) mCurrentFragment = new DeviceInformationFragment(); mTitle = mFragmentTitle = R.string.device; mSubFragmentTitle = -1; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_FEATURES: if (!onResume) mCurrentFragment = new DeviceFeatureFragment(); mTitle = mFragmentTitle = R.string.features; mSubFragmentTitle = -1; break; case DeviceConstants.ID_FAST_CHARGE: if (!onResume) mCurrentFragment = new FastChargeFragment(); mTitle = mSubFragmentTitle = R.string.fast_charge; break; case DeviceConstants.ID_SOUND_CONTROL: if (!onResume) mCurrentFragment = new SoundControlFragment(); mTitle = mSubFragmentTitle = R.string.sound_control; break; case DeviceConstants.ID_KSM: if (!onResume) mCurrentFragment = new KsmFragment(); mTitle = mSubFragmentTitle = R.string.ksm; break; case DeviceConstants.ID_UKSM: if (!onResume) mCurrentFragment = new UksmFragment(); mTitle = mSubFragmentTitle = R.string.uksm; break; case DeviceConstants.ID_VOLTAGE: if (!onResume) mCurrentFragment = new VoltageFragment(); mTitle = mSubFragmentTitle = R.string.voltage_control; break; case DeviceConstants.ID_ENTROPY: if (!onResume) mCurrentFragment = new EntropyFragment(); mTitle = mSubFragmentTitle = R.string.entropy; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_PERFORMANCE_INFO: if (!onResume) mCurrentFragment = new InformationFragment(); mTitle = mFragmentTitle = R.string.information; mSubFragmentTitle = -1; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_PERFORMANCE_CPU_SETTINGS: if (!onResume) mCurrentFragment = new CpuSettingsFragment(); mTitle = mFragmentTitle = R.string.cpusettings; mSubFragmentTitle = -1; break; case DeviceConstants.ID_GOVERNOR_TUNABLE: if (!onResume) mCurrentFragment = new GovernorFragment(); mTitle = mSubFragmentTitle = R.string.cpu_governor_tuning; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_PERFORMANCE_GPU_SETTINGS: if (!onResume) mCurrentFragment = new GpuSettingsFragment(); mTitle = mFragmentTitle = R.string.gpusettings; mSubFragmentTitle = -1; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_FILESYSTEM: if (!onResume) mCurrentFragment = new FilesystemFragment(); mTitle = mFragmentTitle = R.string.filesystem; mSubFragmentTitle = -1; break; case DeviceConstants.ID_IOSCHED_TUNING: if (!onResume) mCurrentFragment = new IoSchedConfigFragment(); mTitle = mSubFragmentTitle = R.string.io; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_THERMAL: if (!onResume) mCurrentFragment = new ThermalFragment(); mTitle = mFragmentTitle = R.string.thermal; mSubFragmentTitle = -1; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_TOOLS_TASKER: if (!onResume) mCurrentFragment = new TaskerFragment(); mTitle = mFragmentTitle = R.string.tasker; mSubFragmentTitle = -1; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_TOOLS_FLASHER: if (!onResume) mCurrentFragment = new FlasherFragment(); mTitle = mFragmentTitle = R.string.flasher; mSubFragmentTitle = -1; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_TOOLS_MORE: if (!onResume) mCurrentFragment = new ToolsMoreFragment(); mTitle = mFragmentTitle = R.string.more; mSubFragmentTitle = -1; break; case DeviceConstants.ID_TOOLS_VM: if (!onResume) mCurrentFragment = new SysctlFragment(); mTitle = mSubFragmentTitle = R.string.sysctl_vm; break; case DeviceConstants.ID_TOOLS_EDITORS_VM: if (!onResume) mCurrentFragment = new SysctlEditorFragment(); mTitle = mSubFragmentTitle = R.string.sysctl_vm; break; case DeviceConstants.ID_TOOLS_EDITORS_BUILD_PROP: if (!onResume) mCurrentFragment = new BuildPropEditorFragment(); mTitle = mSubFragmentTitle = R.string.buildprop; break; case DeviceConstants.ID_TOOLS_APP_MANAGER: if (!onResume) mCurrentFragment = new AppListFragment(); mTitle = mSubFragmentTitle = R.string.app_manager; break; case DeviceConstants.ID_TOOLS_WIRELESS_FM: if (!onResume) mCurrentFragment = new WirelessFileManagerFragment(); mTitle = mSubFragmentTitle = R.string.wireless_file_manager; break; //-------------------------------------------------------------------------------------- case DeviceConstants.ID_PREFERENCES: if (!onResume) mCurrentFragment = new PreferencesFragment(); mTitle = mFragmentTitle = R.string.preferences; mSubFragmentTitle = -1; break; } restoreActionBar(); if (onResume) { return; } final boolean isSubFragment = mSubFragmentTitle != -1; final FragmentManager fragmentManager = getSupportFragmentManager(); if (!isSubFragment && fragmentManager.getBackStackEntryCount() > 0) { // set a lock to prevent calling setFragment as onResume gets called AppHelper.preventOnResume = true; MainActivity.sDisableFragmentAnimations = true; fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); MainActivity.sDisableFragmentAnimations = false; // release the lock AppHelper.preventOnResume = false; } final FragmentTransaction ft = fragmentManager.beginTransaction(); if (isSubFragment) { ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_right, R.anim.slide_in_left, R.anim.slide_out_left); ft.addToBackStack(null); } ft.replace(R.id.container, mCurrentFragment); ft.commit(); final MaterialMenuDrawable.IconState iconState; if (isSubFragment) { iconState = MaterialMenuDrawable.IconState.ARROW; } else { iconState = MaterialMenuDrawable.IconState.BURGER; } sMaterialMenu.animateState(iconState); }
From source file:cz.muni.fi.japanesedictionary.main.MainActivity.java
/** * Callback method from ResultFragmentList. Responds to click on list item. * Launches new DetailFragment or updates old in two pane layout on tablet. * * @param index index of item in ResultFragmentList *///from w ww . java 2 s. c o m @Override public void onTranslationSelected(int index) { Log.i(LOG_TAG, "List Item clicked"); FragmentManager fragmentManager = getSupportFragmentManager(); if (findViewById(R.id.detail_fragment) != null) { // two frames layout Log.i(LOG_TAG, "Translation selected - Setting info fragment"); DisplayTranslation fragment = (DisplayTranslation) fragmentManager.findFragmentByTag("displayFragment"); if (fragment == null || !fragment.isVisible()) { getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); DisplayTranslation displayFragment = new DisplayTranslation(); Bundle bundle = getTranslationCallBack(index).createBundleFromTranslation(null); displayFragment.setArguments(bundle); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.detail_fragment, displayFragment, "displayFragment"); ft.commit(); } else { //is visible fragment.setTranslation(getTranslationCallBack(index)); } return; } Bundle bundle = getTranslationCallBack(index).createBundleFromTranslation(null); Intent intent = new Intent(this.getApplicationContext(), cz.muni.fi.japanesedictionary.main.DisplayTranslationActivity.class); intent.putExtras(bundle); startActivity(intent); }