protected void showFragment(Fragment oldFragment, Fragment newFragment) { android.support.v4.app.Fragment currentFragment = getSupportFragmentManager().findFragmentByTag(newFragment.getFragmentTag()); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (currentFragment != null) { if (oldFragment != null) transaction.hide(oldFragment); if (currentFragment.isDetached()) transaction.attach(currentFragment); transaction.show(currentFragment); } else { if (oldFragment != null) transaction.hide(oldFragment); if (newFragment != null) { if (newFragment.isDetached()) { transaction.attach(newFragment); } else { transaction.add(R.id.MainLayout, newFragment, newFragment.getFragmentTag()); } } } if (oldFragment != null) transaction.addToBackStack(null); transaction.commit(); }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (getResources().getBoolean(R.bool.portrait_only)) { // do not rotate for phones //noinspection ResourceType setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT); } else { // use layout for tablets - landscape or portrait. // save fragments for re-use in new layout! FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); CategoryList attackFragment = (CategoryList) fragmentManager.findFragmentByTag(getResources().getString(R.string.items_attack)); CategoryList defenseFragment = (CategoryList) fragmentManager.findFragmentByTag(getResources().getString(R.string.items_defense)); HeroList heroFragment = (HeroList) fragmentManager.findFragmentByTag(getResources().getString(R.string.items_hero)); fragmentTransaction.detach(attackFragment); fragmentTransaction.detach(defenseFragment); fragmentTransaction.detach(heroFragment); fragmentTransaction.commitAllowingStateLoss(); fragmentManager.executePendingTransactions(); // load appropriate layout Log.v(getClass().getCanonicalName(), "re-load layout for tablets"); setContentView(R.layout.main); Log.v(getClass().getCanonicalName(), "re-use fragments"); fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.attach(defenseFragment); fragmentTransaction.attach(attackFragment); fragmentTransaction.attach(heroFragment); fragmentTransaction.commitAllowingStateLoss(); fragmentManager.executePendingTransactions(); } }
private void selectItem(int pos) { if (pos < 0 || pos >= mMainMenu.getEntries().length) { pos = 0; } String titlePrefix = getString(R.string.main_activity_title_prefix); getSupportActionBar().setTitle(titlePrefix + mMainMenu.getEntries()[pos]); String nextFragmentTag = "FRAGMENT_TAG_" + Integer.toString(pos); Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.container); if (currentFragment != null && nextFragmentTag.equals(currentFragment.getTag())) { return; } Fragment recycledFragment = getSupportFragmentManager().findFragmentByTag(nextFragmentTag); try { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (currentFragment != null) { transaction.detach(currentFragment); } if (recycledFragment != null) { transaction.attach(recycledFragment); } else { transaction.add(R.id.container, mMainMenu.createFragment(pos), nextFragmentTag); } transaction.commit(); getSupportFragmentManager().executePendingTransactions(); // The header takes the first position. mDrawerMenu.setItemChecked(pos + 1, true); getAppPreferences().edit().putInt(PREF_LAST_SCREEN_ID, pos).apply(); } catch (InstantiationException e) { Log.wtf(TAG, "Error while instantiating the selected fragment", e); } catch (IllegalAccessException e) { Log.wtf(TAG, "Error while instantiating the selected fragment", e); } }
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); if (currentFragment != null) { transaction.detach(currentFragment); } String newFragmentTag = FRAGMENT_TAGS.get(position); currentFragment = fragmentManager.findFragmentByTag(newFragmentTag); if (currentFragment == null) { try { currentFragment = FRAGMENT_CLASSES.get(newFragmentTag).getConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException("Cannot instantiate fragment", e); } transaction.add(R.id.container, currentFragment, newFragmentTag); } mTitle = newFragmentTag; restoreActionBar(); transaction.attach(currentFragment).commit(); }
private void selectMenuSection(int position) { Section section = menuAdapter.getItem(position); if (section != currentSection) { // Switch to new section FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment f = fm.findFragmentById(R.id.content); if (f != null) { if (currentSection.shouldKeep()) { ft.detach(f); } else { ft.remove(f); } } String fragmentClassName = section.getFragmentClassName(); if (section.shouldKeep() && ((f = fm.findFragmentByTag(fragmentClassName)) != null)) { ft.attach(f); } else { f = Fragment.instantiate(MainActivity.this, fragmentClassName); ft.add(R.id.content, f, fragmentClassName); } ft.commit(); currentSection = section; updateActionBar(); menuAdapter.notifyDataSetChanged(); } }
public void onTabSelected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub mFragment = new VaccineManager(); // Attach fragment2.xml layout ft.add(android.R.id.content, mFragment); ft.attach(mFragment); }
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { TabInfo newTab = mTabs.get("" + checkedId); if (mLastTab != newTab) { FragmentTransaction ft = mFragmentManager.beginTransaction(); if (mLastTab != null) { if (mLastTab.fragment != null) { ft.detach(mLastTab.fragment); } } if (newTab != null) { if (newTab.fragment == null) { newTab.fragment = (BaseFragment) Fragment.instantiate(group.getContext(), newTab.clss.getName(), newTab.args); ft.add(mContainerId, newTab.fragment, newTab.tag); } else { ft.attach(newTab.fragment); } } mLastTab = newTab; ft.commit(); mFragmentManager.executePendingTransactions(); } }
public void onTabSelected(Tab tab, FragmentTransaction ft) { if (mFragment == null) { mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs); ft.add(android.R.id.content, mFragment, mTag); } else { ft.attach(mFragment); } }
public void onTabSelected(Tab tab, FragmentTransaction ft) { if (mFragment == null) { mFragment = (SherlockFragment) SherlockFragment.instantiate(mActivity, mClass.getName()); ft.add(mfragmentContainerId, mFragment, mTag); } else { ft.attach(mFragment); } }
@Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { if (fragment == null) { String fragmentName = fragmentClass.getName(); fragment = Fragment.instantiate(activity, fragmentName); fragmentTransaction.add(fragmentContainer, fragment, fragmentName); } else { fragmentTransaction.attach(fragment); } }
private void attachFragment(Fragment fragment, String tag) { if (fragment != null) { if (fragment.isDetached()) { ensureTransaction(); fragmentTransaction.attach(fragment); } else if (!fragment.isAdded()) { ensureTransaction(); fragmentTransaction.add(containerId, fragment, tag); } } }
public void onTabSelected(Tab tab, FragmentTransaction unused) { // The parameter is always null // See: // http://groups.google.com/group/actionbarsherlock/browse_thread/thread/89eac58c13fe1ae0/8d6db0ba248e53d9?show_docid=8d6db0ba248e53d9 FragmentManager fm = mActivity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); if (mFragment == null) { mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs); ft.add(android.R.id.content, mFragment, mTag); } else { ft.attach(mFragment); } ft.commit(); }
/* The following are each of the ActionBar.TabListener callbacks */ @Override public void onTabSelected(CompatTab tab, FragmentTransaction ft) { // Check if the fragment is already initialized Fragment fragment = tab.getFragment(); if (fragment == null) { // If not, instantiate and add it to the activity fragment = Fragment.instantiate(mActivity, mClass.getName()); tab.setFragment(fragment); ft.add(android.R.id.tabcontent, fragment, tab.getTag()); } else { // If it exists, simply attach it in order to show it ft.attach(fragment); } }
/** * Instantiate or reattach existing Fragment * * @param context context * @param manager fragment manager * @param tx existing transaction * @param containerId container * @param info fragment definition */ public static void addOrAttachFragment( Context context, FragmentManager manager, FragmentTransaction tx, int containerId, FragmentElement element) { if (element.fragment == null) element.fragment = manager.findFragmentByTag(element.name); if (element.fragment == null) { Log.v("FragmentManager", "Instantiated new Fragment: " + element.name); tx.add(containerId, element.instantiate(context), element.name); } else { Log.v("FragmentManager", "Reattaching existing Fragment: " + element.name); tx.attach(element.fragment); } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if(listFragment == null) { listFragment = new SearchListFragment(); fragmentTransaction.add(R.id.list_container, listFragment); } else { fragmentTransaction.attach(listFragment); } fragmentTransaction.commit(); return inflater.inflate(R.layout.fragment_search, container, false); }
@Override public void onTabSelected(Tab tab, FragmentTransaction ft) { if (mFragment == null) { mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs); ft.add(android.R.id.content, mFragment, mTag); } else { ft.attach(mFragment); } if (mFragment instanceof GotoDirectFragment) { ((GotoDirectFragment) mFragment).onTabSelected(); } else { InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow( mActivity.findViewById(android.R.id.content).getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); } }
public void onTabChanged(String tabId) { TabInfo newTab = mTabs.get(tabId); if (mLastTab != newTab) { FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction(); if (mLastTab != null) { if (mLastTab.fragment != null) { ft.detach(mLastTab.fragment); } } if (newTab != null) { if (newTab.fragment == null) { newTab.fragment = Fragment.instantiate(mActivity, newTab.clss.getName(), newTab.args); ft.add(mContainerId, newTab.fragment, newTab.tag); } else { ft.attach(newTab.fragment); } } mLastTab = newTab; ft.commit(); mActivity.getSupportFragmentManager().executePendingTransactions(); } }
/** * Changement de Tabs * * @see android.widget.TabHost.OnTabChangeListener#onTabChanged(java.lang.String) */ public void onTabChanged(String tag) { TabInfo newTab = (TabInfo) this.mapTabInfo.get(tag); if (mLastTab != newTab) { FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); if (mLastTab != null) { if (mLastTab.fragment != null) { ft.detach(mLastTab.fragment); } } if (newTab != null) { if (newTab.fragment == null) { newTab.fragment = Fragment.instantiate(this, newTab.clss.getName(), newTab.args); ft.add(R.id.realtabcontent, newTab.fragment, newTab.tag); } else { ft.attach(newTab.fragment); } } mLastTab = newTab; ft.commit(); this.getSupportFragmentManager().executePendingTransactions(); } }
private FragmentTransaction doTabChanged(String tabId, FragmentTransaction ft) { TabInfo newTab = null; for (int i = 0; i < mTabs.size(); i++) { TabInfo tab = mTabs.get(i); if (tab.tag.equals(tabId)) { newTab = tab; } } if (newTab == null) { throw new IllegalStateException("No tab known for tag " + tabId); } if (mLastTab != newTab) { if (ft == null) { ft = mFragmentManager.beginTransaction(); } if (mLastTab != null) { if (mLastTab.fragment != null) { // 将detach替换为hide,隐藏Fragment ft.detach(mLastTab.fragment); // ft.hide(mLastTab.fragment); } } if (newTab != null) { if (newTab.fragment == null) { newTab.fragment = Fragment.instantiate(mContext, newTab.clss.getName(), newTab.args); ft.add(mContainerId, newTab.fragment, newTab.tag); } else { // 将attach替换为show,显示Fragment ft.attach(newTab.fragment); // ft.show(newTab.fragment); } } mLastTab = newTab; } return ft; }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (AppMain.isphone) { if (Fragment_Ebook.isChoice) { ProgressDialog dialog = new ProgressDialog(ebook.getActivity()); dialog.show(); Fragment_Ebook.isChoice = false; Adapter_List_Ebook_MasterDetail.phoneToDetail = false; Fragment_Ebook.sCatIDs = ""; Fragment_Ebook.bCode = ""; if (ebook != null) { ebook.setListViewMaster(AppMain.pList_default_ebook_master, dialog); return false; } return true; } else { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (mLastTab.tag.equals("Tab3")) { if (AppMain.pList_Subcategories != null && AppMain.pList_Subcategories_ebook != null) { Fragment_Category.category.setListView_SubCategory( AppMain.pList_Subcategories, null); AppMain.pList_Subcategories_ebook = null; return true; } if (AppMain.pList_Subcategories != null) { Fragment_Category.category.setListViewCategory(AppMain.pList_categories, null); AppMain.pList_Subcategories = null; return true; } } try { if (mLastTab.tag.equals("Tab1")) { if (Fragment_Ebook.fragment_ebook.HaveFragment) { FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); if (Fragment_Ebook.fragment_ebook.frag_search != null) { ft.detach(Fragment_Ebook.fragment_ebook.frag_search); } if (Activity_Tab.mLastTab.fragment != null) { ft.attach(mLastTab.fragment); } ft.commit(); this.getSupportFragmentManager().executePendingTransactions(); Fragment_Ebook.fragment_ebook.HaveFragment = false; return true; } } } catch (Exception e) { // TODO: handle exception } if (mLastTab.tag.equals("Tab2")) { if (Fragment_Publisher.fragment_Publisher.HaveFragment) { FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); if (Fragment_Publisher.fragment_Publisher.frag_searchpublisher != null) { ft.detach(Fragment_Publisher.fragment_Publisher.frag_searchpublisher); } if (Activity_Tab.mLastTab.fragment != null) { ft.attach(mLastTab.fragment); } ft.commit(); this.getSupportFragmentManager().executePendingTransactions(); Fragment_Publisher.fragment_Publisher.HaveFragment = false; return true; } } } } } } else { if (Fragment_Ebook.isTabletChoose) { Fragment_Ebook.isTabletChoose = false; Adapter_List_Ebook_MasterDetail.phoneToDetail = false; Fragment_Ebook.sCatIDs = ""; Fragment_Ebook.bCode = ""; if (ebook != null) { ebook.setViewPagerMaster(AppMain.pList_default_ebook_master, null); return false; } return true; } // tablet } return super.onKeyDown(keyCode, event); }
@Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { if (fragment != null) { fragmentTransaction.attach(fragment); } }
@Override public void onTabChanged(String tag) { AppMain.isShelf = false; if (AppMain.isphone) { TabInfo newTab = mapTabInfo.get(tag); if (mLastTab != newTab) { FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); // pause if (mLastTab != null) { if (mLastTab.fragment != null) { ft.detach(mLastTab.fragment); } if (mLastTab.tag.equals("Tab1")) { if (Fragment_Ebook.isChoice) { Fragment_Ebook.isChoice = false; Adapter_List_Ebook_MasterDetail.phoneToDetail = false; Fragment_Ebook.sCatIDs = ""; Fragment_Ebook.bCode = ""; } if (getSupportFragmentManager().getBackStackEntryCount() > 0) { getSupportFragmentManager().popBackStack(); } if (Fragment_Ebook.fragment_ebook != null) { if (Fragment_Ebook.fragment_ebook.HaveFragment) { if (Fragment_Ebook.fragment_ebook.frag_search != null) { ft.detach(Fragment_Ebook.fragment_ebook.frag_search); } } } } if (mLastTab.tag.equals("Tab2")) { if (Fragment_Publisher.fragment_Publisher != null) { if (Fragment_Publisher.fragment_Publisher.HaveFragment) { if (Fragment_Publisher.fragment_Publisher.frag_searchpublisher != null) { ft.detach(Fragment_Publisher.fragment_Publisher.frag_searchpublisher); } } } } } // resume if (newTab != null) { if (newTab.tag.equals("Tab1")) { if (Fragment_Ebook.fragment_ebook != null) { if (Fragment_Ebook.fragment_ebook.HaveFragment) { if (Fragment_Ebook.fragment_ebook.frag_search != null) { ft.attach(Fragment_Ebook.fragment_ebook.frag_search); } mLastTab = newTab; ft.commit(); this.getSupportFragmentManager().executePendingTransactions(); return; } } } if (newTab.tag.equals("Tab2")) { if (Fragment_Publisher.fragment_Publisher != null) { if (Fragment_Publisher.fragment_Publisher.HaveFragment) { if (Fragment_Publisher.fragment_Publisher.frag_searchpublisher != null) { ft.attach(Fragment_Publisher.fragment_Publisher.frag_searchpublisher); } mLastTab = newTab; ft.commit(); this.getSupportFragmentManager().executePendingTransactions(); return; } } } if (newTab.fragment == null) { newTab.fragment = Fragment.instantiate(this, newTab.clss.getName(), newTab.args); ft.add(R.id.realtabcontent, newTab.fragment, newTab.tag); } else { ft.attach(newTab.fragment); } } mLastTab = newTab; ft.commit(); this.getSupportFragmentManager().executePendingTransactions(); } } else { if (Fragment_Ebook.isTabletChoose) { Fragment_Ebook.isTabletChoose = false; Adapter_List_Ebook_MasterDetail.phoneToDetail = false; Fragment_Ebook.sCatIDs = ""; Fragment_Ebook.bCode = ""; } if (getSupportFragmentManager().getBackStackEntryCount() > 0) { getSupportFragmentManager().popBackStack(); } // tablet TabInfo newTab = mapTabInfo.get(tag); if (mLastTab != newTab) { FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); // pause if (mLastTab != null) { if (mLastTab.fragment != null) { ft.detach(mLastTab.fragment); } } // resume if (newTab != null) { if (newTab.fragment == null) { newTab.fragment = Fragment.instantiate(this, newTab.clss.getName(), newTab.args); ft.add(R.id.realtabcontent, newTab.fragment, newTab.tag); } else { ft.attach(newTab.fragment); } } mLastTab = newTab; ft.commit(); this.getSupportFragmentManager().executePendingTransactions(); } } }
/** * Callback method from {@link * com.metric.skava.assessment.fragment.AssessmentStageListFragment.StageSelectionCallback} * indicating that the item with the given ID was selected. */ @Override public void onItemSelected(String id) { if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. if (id.equalsIgnoreCase(AssesmentStageDataProvider.GRAL_INFO)) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fx = fragmentManager.beginTransaction(); // whats the current fragment Fragment previous = fragmentManager.findFragmentById(R.id.stage_detail_container); if (previous != null) { fx.detach(previous); } // use the previous fragment if there is one Fragment fragment = fragmentManager.findFragmentByTag(FRAGMENT_GRAL_INFO_STAGE_TAG); IdentificationMainFragment gralInfoFragment; if (fragment != null) { gralInfoFragment = (IdentificationMainFragment) fragment; fx.attach(gralInfoFragment); } else { gralInfoFragment = new IdentificationMainFragment(); Bundle arguments = new Bundle(); arguments.putString(IdentificationMainFragment.ARG_BASKET_ID, id); gralInfoFragment.setArguments(arguments); fx.add(R.id.stage_detail_container, gralInfoFragment, FRAGMENT_GRAL_INFO_STAGE_TAG); } fx.commit(); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.DISCONTINUITIES)) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fx = fragmentManager.beginTransaction(); Fragment previous = getSupportFragmentManager().findFragmentById(R.id.stage_detail_container); if (previous != null) { fx.detach(previous); } // use the previous fragment if there is one Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_DISCONTINUITIES_STAGE_TAG); DiscontinuitiesMainFragment discontinuitiesFragment; if (fragment != null) { discontinuitiesFragment = (DiscontinuitiesMainFragment) fragment; fx.attach(discontinuitiesFragment); } else { discontinuitiesFragment = new DiscontinuitiesMainFragment(); Bundle arguments = new Bundle(); arguments.putString(DiscontinuitiesMainFragment.ARG_BASKET_ID, id); discontinuitiesFragment.setArguments(arguments); fx.add( R.id.stage_detail_container, discontinuitiesFragment, FRAGMENT_DISCONTINUITIES_STAGE_TAG); } fx.commit(); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.Q)) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fx = fragmentManager.beginTransaction(); Fragment previous = getSupportFragmentManager().findFragmentById(R.id.stage_detail_container); if (previous != null) { fx.detach(previous); } Fragment fragment = fragmentManager.findFragmentByTag(FRAGMENT_Q_STAGE_TAG); QBartonCalculatorMainFragment qBartonFragment; // use the previous fragment if there is one if (fragment != null) { qBartonFragment = (QBartonCalculatorMainFragment) fragment; fx.attach(qBartonFragment); } else { Bundle arguments = new Bundle(); arguments.putString(QBartonCalculatorMainFragment.ARG_BASKET_ID, id); qBartonFragment = new QBartonCalculatorMainFragment(); qBartonFragment.setArguments(arguments); fx.add(R.id.stage_detail_container, qBartonFragment, FRAGMENT_Q_STAGE_TAG); } fx.commit(); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.RMR)) { FragmentTransaction fx = getSupportFragmentManager().beginTransaction(); Fragment previous = getSupportFragmentManager().findFragmentById(R.id.stage_detail_container); if (previous != null) { fx.detach(previous); } // use the previous fragment if there is one Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_RMR_STAGE_TAG); RMRCalculatorMainFragment rmrFragment; if (fragment != null) { rmrFragment = (RMRCalculatorMainFragment) fragment; fx.attach(rmrFragment); } else { rmrFragment = new RMRCalculatorMainFragment(); Bundle arguments = new Bundle(); arguments.putString(RMRCalculatorMainFragment.ARG_BASKET_ID, id); rmrFragment.setArguments(arguments); fx.add(R.id.stage_detail_container, rmrFragment, FRAGMENT_RMR_STAGE_TAG); } fx.commit(); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.PICS)) { FragmentTransaction fx = getSupportFragmentManager().beginTransaction(); Fragment previous = getSupportFragmentManager().findFragmentById(R.id.stage_detail_container); if (previous != null) { fx.detach(previous); } // use the previous fragment if there is one Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_PICTURES_STAGE_TAG); PicturesMainFragment picturesFragment; if (fragment != null) { picturesFragment = (PicturesMainFragment) fragment; fx.attach(picturesFragment); } else { picturesFragment = new PicturesMainFragment(); Bundle arguments = new Bundle(); arguments.putString(PicturesMainFragment.ARG_BASKET_ID, id); picturesFragment.setArguments(arguments); fx.add(R.id.stage_detail_container, picturesFragment, FRAGMENT_PICTURES_STAGE_TAG); } fx.commit(); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.DESC)) { FragmentTransaction fx = getSupportFragmentManager().beginTransaction(); Fragment previous = getSupportFragmentManager().findFragmentById(R.id.stage_detail_container); if (previous != null) { fx.detach(previous); } // use the previous fragment if there is one Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_DESCRIPTION_STAGE_TAG); RockMassDescriptionMainFragment rockMassDescriptionFragment; if (fragment != null) { rockMassDescriptionFragment = (RockMassDescriptionMainFragment) fragment; fx.attach(rockMassDescriptionFragment); } else { rockMassDescriptionFragment = new RockMassDescriptionMainFragment(); Bundle arguments = new Bundle(); arguments.putString(RockMassDescriptionMainFragment.ARG_BASKET_ID, id); rockMassDescriptionFragment.setArguments(arguments); fx.add( R.id.stage_detail_container, rockMassDescriptionFragment, FRAGMENT_DESCRIPTION_STAGE_TAG); } fx.commit(); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.INSTRUCTIONS)) { FragmentTransaction fx = getSupportFragmentManager().beginTransaction(); Fragment previous = getSupportFragmentManager().findFragmentById(R.id.stage_detail_container); if (previous != null) { fx.detach(previous); } // use the previous fragment if there is one Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_RECOMENDATION_STAGE_TAG); InstructionsMainFragment supportRecomendationFragment; if (fragment != null) { supportRecomendationFragment = (InstructionsMainFragment) fragment; fx.attach(supportRecomendationFragment); } else { supportRecomendationFragment = new InstructionsMainFragment(); Bundle arguments = new Bundle(); arguments.putString(InstructionsMainFragment.ARG_BASKET_ID, id); supportRecomendationFragment.setArguments(arguments); fx.add( R.id.stage_detail_container, supportRecomendationFragment, FRAGMENT_RECOMENDATION_STAGE_TAG); } fx.commit(); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.REPORT)) { // To make it full screen size launh it as an activity instead of as a fragment Intent detailIntent = new Intent(this, MappingReportMainActivity.class); detailIntent.putExtra(MappingReportMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; // Bundle arguments = new Bundle(); // arguments.putString(MappingReportMainFragment.ARG_BASKET_ID, id); // MappingReportMainFragment fragment = new MappingReportMainFragment(); // fragment.setArguments(arguments); // getSupportFragmentManager().beginTransaction() // .replace(R.id.stage_detail_container, fragment) // .commit(); // return; } } else { // In single-pane mode, simply start the detail activity // for the selected item ID. if (id.equalsIgnoreCase(AssesmentStageDataProvider.GRAL_INFO)) { Intent detailIntent = new Intent(this, IdentificationMainActivity.class); detailIntent.putExtra(IdentificationMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.DISCONTINUITIES)) { Intent detailIntent = new Intent(this, DiscontinuitiesMainActivity.class); detailIntent.putExtra(DiscontinuitiesMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.Q)) { Intent detailIntent = new Intent(this, QBartonCalculatorDetailActivity.class); detailIntent.putExtra(QBartonCalculatorMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.RMR)) { Intent detailIntent = new Intent(this, RMRCalculatorDetailActivity.class); detailIntent.putExtra(RMRCalculatorMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.PICS)) { Intent detailIntent = new Intent(this, PicturesMainActivity.class); detailIntent.putExtra(PicturesMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.DESC)) { Intent detailIntent = new Intent(this, RockMassDescriptionMainActivity.class); detailIntent.putExtra(RMRCalculatorMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.INSTRUCTIONS)) { Intent detailIntent = new Intent(this, InstructionsMainActivity.class); detailIntent.putExtra(InstructionsMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; } if (id.equalsIgnoreCase(AssesmentStageDataProvider.REPORT)) { Intent detailIntent = new Intent(this, MappingReportMainActivity.class); detailIntent.putExtra(MappingReportMainFragment.ARG_BASKET_ID, id); startActivity(detailIntent); return; } } }