List of usage examples for android.app FragmentManager executePendingTransactions
public abstract boolean executePendingTransactions();
From source file:org.onepf.opfiab.ComponentIabHelper.java
ComponentIabHelper(@Nullable final android.support.v4.app.FragmentManager supportFragmentManager, @Nullable final android.app.FragmentManager fragmentManager) { super();//ww w . ja v a2s . co m // Register for lifecycle event right a way OPFIab.register(this); if (supportFragmentManager != null) { OPFLog.d("ComponentIabHelper uses android.support.v4.app.Fragment."); final android.support.v4.app.Fragment existingFragment = supportFragmentManager .findFragmentByTag(FRAGMENT_TAG); if (existingFragment != null) { // Fragment already attached opfFragment = existingFragment; register(); return; } final android.support.v4.app.Fragment fragment = OPFIabSupportFragment.newInstance(); opfFragment = fragment; // Attach new fragment supportFragmentManager.beginTransaction().add(fragment, FRAGMENT_TAG).commit(); // wait for onAttach() callback supportFragmentManager.executePendingTransactions(); return; } if (fragmentManager != null) { OPFLog.d("ComponentIabHelper uses android.app.Fragment."); final Fragment existingFragment = fragmentManager.findFragmentByTag(FRAGMENT_TAG); if (existingFragment != null) { opfFragment = existingFragment; register(); return; } final Fragment fragment = OPFIabFragment.newInstance(); opfFragment = fragment; fragmentManager.beginTransaction().add(fragment, FRAGMENT_TAG).commit(); fragmentManager.executePendingTransactions(); return; } throw new IllegalStateException(); }
From source file:com.tct.mail.ui.OnePaneController.java
@Override protected void showConversation(Conversation conversation) { super.showConversation(conversation); // TS: tao.gan 2015-09-21 EMAIL FEATURE-559893 ADD_S //we change from ConversationListFragment to ConversationViewFragment, should let the toolbar show animateShow(null);//from w w w . j av a2 s. c o m // TS: tao.gan 2015-09-21 EMAIL FEATURE-559893 ADD_E mConversationListVisible = false; if (conversation == null) { transitionBackToConversationListMode(); return; } disableCabMode(); if (ConversationListContext.isSearchResult(mConvListContext)) { mViewMode.enterSearchResultsConversationMode(); } else { mViewMode.enterConversationMode(); } final FragmentManager fm = mActivity.getFragmentManager(); final FragmentTransaction ft = fm.beginTransaction(); // Switching to conversation view is an incongruous transition: // we are not replacing a fragment with another fragment as // usual. Instead, reveal the heretofore inert conversation // ViewPager and just remove the previously visible fragment // e.g. conversation list, or possibly label list?). final Fragment f = fm.findFragmentById(R.id.content_pane); // FragmentManager#findFragmentById can return fragments that are not added to the activity. // We want to make sure that we don't attempt to remove fragments that are not added to the // activity, as when the transaction is popped off, the FragmentManager will attempt to // readd the same fragment twice if (f != null && f.isAdded()) { ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.remove(f); ft.commitAllowingStateLoss(); //TS: jin.dong 2015-8-28 EMAIL BUGFIX-1075110 MOD_S try { fm.executePendingTransactions(); } catch (IllegalArgumentException e) { LogUtils.d(LOG_TAG, e, "IllegalArgumentException occurred"); } //TS: jin.dong 2015-8-28 EMAIL BUGFIX-1075110 MOD_E } mPagerController.show(mAccount, mFolder, conversation, true /* changeVisibility */); onConversationVisibilityChanged(true); onConversationListVisibilityChanged(false); }
From source file:co.taqat.call.LinphoneActivity.java
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) { FragmentManager fm = getFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); /*/* ww w .ja va 2s.c o m*/ if (!withoutAnimation && 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); } }*/ if (newFragmentType != FragmentsAvailable.DIALER && newFragmentType != FragmentsAvailable.CONTACTS_LIST && newFragmentType != FragmentsAvailable.CHAT_LIST && newFragmentType != FragmentsAvailable.HISTORY_LIST) { transaction.addToBackStack(newFragmentType.toString()); } else { while (fm.getBackStackEntryCount() > 0) { fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); } } transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString()); transaction.commitAllowingStateLoss(); fm.executePendingTransactions(); currentFragment = newFragmentType; }
From source file:com.android.contacts.activities.PeopleActivity.java
private void createViewsAndFragments(Bundle savedState) { // Disable the ActionBar so that we can use a Toolbar. This needs to be called before // setContentView(). getWindow().requestFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.people_activity); final FragmentManager fragmentManager = getFragmentManager(); // Hide all tabs (the current tab will later be reshown once a tab is selected) final FragmentTransaction transaction = fragmentManager.beginTransaction(); mTabTitles = new String[TabState.COUNT]; mTabTitles[TabState.FAVORITES] = getString(R.string.favorites_tab_label); mTabTitles[TabState.ALL] = getString(R.string.all_contacts_tab_label); mTabPager = getView(R.id.tab_pager); mTabPagerAdapter = new TabPagerAdapter(); mTabPager.setAdapter(mTabPagerAdapter); mTabPager.setOnPageChangeListener(mTabPagerListener); // Configure toolbar and toolbar tabs. If in landscape mode, we configure tabs differntly. final Toolbar toolbar = getView(R.id.toolbar); setActionBar(toolbar);//from ww w.j ava2 s . c om final ViewPagerTabs portraitViewPagerTabs = (ViewPagerTabs) findViewById(R.id.lists_pager_header); ViewPagerTabs landscapeViewPagerTabs = null; if (portraitViewPagerTabs == null) { landscapeViewPagerTabs = (ViewPagerTabs) getLayoutInflater() .inflate(R.layout.people_activity_tabs_lands, toolbar, /* attachToRoot = */ false); mViewPagerTabs = landscapeViewPagerTabs; } else { mViewPagerTabs = portraitViewPagerTabs; } mViewPagerTabs.setViewPager(mTabPager); final String FAVORITE_TAG = "tab-pager-favorite"; final String ALL_TAG = "tab-pager-all"; // Create the fragments and add as children of the view pager. // The pager adapter will only change the visibility; it'll never create/destroy // fragments. // However, if it's after screen rotation, the fragments have been re-created by // the fragment manager, so first see if there're already the target fragments // existing. mFavoritesFragment = (ContactTileListFragment) fragmentManager.findFragmentByTag(FAVORITE_TAG); mAllFragment = (MultiSelectContactsListFragment) fragmentManager.findFragmentByTag(ALL_TAG); if (mFavoritesFragment == null) { mFavoritesFragment = new ContactTileListFragment(); mAllFragment = new MultiSelectContactsListFragment(); transaction.add(R.id.tab_pager, mFavoritesFragment, FAVORITE_TAG); transaction.add(R.id.tab_pager, mAllFragment, ALL_TAG); } mFavoritesFragment.setListener(mFavoritesFragmentListener); mAllFragment.setOnContactListActionListener(new ContactBrowserActionListener()); mAllFragment.setCheckBoxListListener(new CheckBoxListListener()); // Hide all fragments for now. We adjust visibility when we get onSelectedTabChanged() // from ActionBarAdapter. transaction.hide(mFavoritesFragment); transaction.hide(mAllFragment); transaction.commitAllowingStateLoss(); fragmentManager.executePendingTransactions(); // Setting Properties after fragment is created mFavoritesFragment.setDisplayType(DisplayType.STREQUENT); mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar(), portraitViewPagerTabs, landscapeViewPagerTabs, toolbar); mActionBarAdapter.initialize(savedState, mRequest); // Add shadow under toolbar ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources()); // Configure floating action button mFloatingActionButtonContainer = findViewById(R.id.floating_action_button_container); final ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button); floatingActionButton.setOnClickListener(this); mFloatingActionButtonController = new FloatingActionButtonController(this, mFloatingActionButtonContainer, floatingActionButton); initializeFabVisibility(); invalidateOptionsMenuIfNeeded(); }