List of usage examples for android.app FragmentTransaction hide
public abstract FragmentTransaction hide(Fragment fragment);
From source file:com.poloure.simplerss.Constants.java
static void hideFragments(Fragment... fragments) { FragmentTransaction transaction = s_fragmentManager.beginTransaction(); for (Fragment fragment : fragments) { transaction.hide(fragment); }//from www. j a va2 s. com transaction.commit(); }
From source file:com.poloure.simplerss.Utilities.java
private static void switchToFragment(Fragment fragment, boolean addToBackStack) { if (fragment.isHidden()) { Fragment[] fragments = { s_fragmentFavourites, s_fragmentManage, s_fragmentFeeds, s_fragmentSettings }; FragmentTransaction transaction = s_fragmentManager.beginTransaction(); for (Fragment frag : fragments) { if (frag.isVisible()) { transaction.hide(frag); }/*from ww w. ja v a 2 s .co m*/ } transaction.show(fragment); if (addToBackStack) { transaction.addToBackStack(null); // Set the default transition for adding to the stack. transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); } transaction.commit(); s_fragmentManager.executePendingTransactions(); fragment.getActivity().invalidateOptionsMenu(); } }
From source file:com.orange.ocara.ui.activity.EditCommentAudioActivity.java
@Override protected void createAttachment() { android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.hide(audioPlayerFragment); transaction.commit();/*from ww w. j av a 2s. c o m*/ validateComment.setEnabled(false); // new : launchRecorder(); }
From source file:com.example.google.touroflondon.MainActivity.java
@Override protected void onResume() { super.onResume(); // Verify that Google Play Services is available int playStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); if (playStatus != ConnectionResult.SUCCESS) { // Google Play services is not available, prompt user and close // application when dialog is dismissed Dialog dialog = GooglePlayServicesUtil.getErrorDialog(playStatus, this, 0); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override// w w w . j av a 2 s. c om public void onCancel(DialogInterface dialog) { finish(); } }); dialog.show(); // Hide all active fragments FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.hide(mMapFragment); if (mPoiListFragment != null) { ft.hide(mPoiListFragment); } ft.commit(); } else { // Make sure active fragments are shown when returning from Play // Services dialog interaction FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(mMapFragment); if (mPoiListFragment != null) { ft.show(mPoiListFragment); } ft.commit(); } }
From source file:com.example.android.touroflondon.MainActivity.java
@Override protected void onResume() { super.onResume(); //Verify that Google Play Services is available int playStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); if (playStatus != ConnectionResult.SUCCESS) { // Google Play services is not available, prompt user and close application when dialog is dismissed Dialog dialog = GooglePlayServicesUtil.getErrorDialog(playStatus, this, 0); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override//w ww .ja v a2 s .c o m public void onCancel(DialogInterface dialog) { finish(); } }); dialog.show(); // Hide all active fragments FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.hide(mMapFragment); if (mPoiListFragment != null) { ft.hide(mPoiListFragment); } ft.commit(); } else { // Getting reference to the SupportMapFragment of activity_main.xml TourMapFragment fm = (TourMapFragment) getFragmentManager().findFragmentById(R.id.fragment_map); // Getting GoogleMap object from the fragment googleMap = fm.getMap(); // Enabling MyLocation Layer of Google Map googleMap.setMyLocationEnabled(true); // Getting LocationManager object from System Service LOCATION_SERVICE LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 20000, 0, mMapFragment); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 20000, 0, mMapFragment); // Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); // Make sure active fragments are shown when returning from Play Services dialog interaction FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(mMapFragment); if (mPoiListFragment != null) { ft.show(mPoiListFragment); } ft.commit(); } }
From source file:org.chromium.chrome.browser.bookmark.ManageBookmarkActivity.java
/** * Initializes the fragment state after a state restoration. * <p>//w w w . j ava 2 s. c o m * Reinitializes all of the event listeners on the fragments as they are not persisted across * activity recreation (and were referencing the old activity anyway). * <p> * The hidden state of the fragments are also not persisted across activity changes, so we need * to hide and show the fragments accordingly (since we know that hierarchy of the fragments * we can do this as a simple nested conditional). */ private void initializeFragmentState() { AddEditBookmarkFragment baseAddEditFragment = (AddEditBookmarkFragment) getFragmentManager() .findFragmentByTag(BASE_ADD_EDIT_FRAGMENT_TAG); setActionListenerOnAddEdit(baseAddEditFragment); Fragment selectFolderFragment = getFragmentManager().findFragmentByTag(BASE_SELECT_FOLDER_FRAGMENT_TAG); if (selectFolderFragment != null) { setActionListenerOnFolderSelection((SelectBookmarkFolderFragment) selectFolderFragment); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.hide(baseAddEditFragment); Fragment addFolderFragment = getFragmentManager().findFragmentByTag(ADD_FOLDER_FRAGMENT_TAG); if (addFolderFragment != null) { fragmentTransaction.hide(selectFolderFragment); setActionListenerOnAddEdit((AddEditBookmarkFragment) addFolderFragment); Fragment addFolderSelectFolderFragment = getFragmentManager() .findFragmentByTag(ADD_FOLDER_SELECT_FOLDER_FRAGMENT_TAG); if (addFolderSelectFolderFragment != null) { setActionListenerOnFolderSelection( (SelectBookmarkFolderFragment) addFolderSelectFolderFragment); fragmentTransaction.hide(addFolderFragment); fragmentTransaction.show(addFolderSelectFolderFragment); } else { fragmentTransaction.show(addFolderFragment); } } else { fragmentTransaction.show(selectFolderFragment); } fragmentTransaction.commit(); } }
From source file:com.skubit.comics.activities.MainActivity.java
private void hidesFragments(int visPosition, FragmentTransaction transaction) { for (int i = 0; i < fragments.length; i++) { if (i != visPosition) { if (fragments[i] != null) { transaction.hide(fragments[i]); } else { Fragment fragment = getFragmentManager().findFragmentByTag(fragmentTags[i]); if (fragment != null) { transaction.hide(fragment); }/*w w w. ja v a2 s . c om*/ } } } }
From source file:com.breadwallet.presenter.activities.IntroActivity.java
private void showHideFragments(Fragment... fragments) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.hide(introWelcomeFragment); fragmentTransaction.hide(introNewRecoverFragment); fragmentTransaction.hide(introNewWalletFragment); fragmentTransaction.hide(introRecoverWalletFragment); fragmentTransaction.hide(introWarningFragment); for (Fragment f : fragments) { fragmentTransaction.show(f);/*from w w w . ja v a 2 s . c om*/ } fragmentTransaction.commitAllowingStateLoss(); }
From source file:am.project.x.business.main.MainActivity.java
private void setFragment(String tag) { final String oldTag = mCurrent; mCurrent = tag;/* ww w . ja va 2 s . c om*/ final FragmentManager manager = getFragmentManager(); final FragmentTransaction transaction = manager.beginTransaction(); if (!TextUtils.isEmpty(oldTag)) { final Fragment old = manager.findFragmentByTag(oldTag); if (old != null && old.isVisible()) { transaction.hide(old); } } Fragment target = manager.findFragmentByTag(tag); if (target != null && target.isVisible()) return; if (target == null) { switch (tag) { default: case TAG_WIDGETS: target = WidgetsFragment.newInstance(); break; case TAG_DRAWABLES: target = DrawablesFragment.newInstance(); break; case TAG_OTHERS: target = OthersFragment.newInstance(); break; case TAG_DEVELOP: target = DevelopFragment.newInstance(); break; } transaction.add(mVContent.getId(), target, tag); } transaction.show(target); transaction.commit(); }
From source file:com.tassadar.multirommgr.MainActivity.java
/** Swaps fragments in the main content view */ private void selectItem(int position) { if (position < 0 || position >= m_fragments.length) { Log.e("MultiROMMgr", "Invalid fragment index " + position); return;/*w w w. ja v a2s .c o m*/ } // Insert the fragment by replacing any existing fragment FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction t = fragmentManager.beginTransaction(); if (m_curFragment != -1) t.hide(m_fragments[m_curFragment]); t.show(m_fragments[position]); t.commit(); m_curFragment = position; // Highlight the selected item, update the title, and close the drawer m_drawerList.setItemChecked(position, true); setTitle(m_fragmentTitles[position]); m_drawerLayout.closeDrawer(m_drawerList); }