List of usage examples for android.support.v4.app FragmentTransaction commit
public abstract int commit();
From source file:com.android.gallery3d.filtershow.category.MainPanel.java
public void showImageStatePanel(boolean show) { View container = mMainView.findViewById(R.id.state_panel_container); FragmentTransaction transaction = null; if (container == null) { FilterShowActivity activity = (FilterShowActivity) getActivity(); container = activity.getMainStatePanelContainer(R.id.state_panel_container); } else {/*from w w w. j a v a2 s . com*/ transaction = getChildFragmentManager().beginTransaction(); } if (container == null) { return; } else { transaction = getFragmentManager().beginTransaction(); } int currentPanel = mCurrentSelected; if (show) { container.setVisibility(View.VISIBLE); StatePanel statePanel = new StatePanel(); statePanel.setMainPanel(this); FilterShowActivity activity = (FilterShowActivity) getActivity(); activity.updateVersions(); transaction.replace(R.id.state_panel_container, statePanel, StatePanel.FRAGMENT_TAG); } else { container.setVisibility(View.GONE); Fragment statePanel = getChildFragmentManager().findFragmentByTag(StatePanel.FRAGMENT_TAG); if (statePanel != null) { transaction.remove(statePanel); } if (currentPanel == VERSIONS) { currentPanel = LOOKS; } } mCurrentSelected = -1; showPanel(currentPanel); transaction.commit(); }
From source file:cn.thinkjoy.startup.widget.FragmentTabHost.java
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); String currentTab = getCurrentTabTag(); // Go through all tabs and make sure their fragments match // the correct state. FragmentTransaction ft = null; for (int i = 0; i < mTabs.size(); i++) { TabInfo tab = mTabs.get(i);// ww w. ja va 2s. co m tab.fragment = mFragmentManager.findFragmentByTag(tab.tag); // if (tab.fragment != null && !tab.fragment.isDetached()) { if (tab.fragment != null) { if (tab.tag.equals(currentTab)) { // The fragment for this tab is already there and // active, and it is what we really want to have // as the current tab. Nothing to do. mLastTab = tab; this.currentTab = i; } else { // This fragment was restored in the active state, // but is not the current tab. Deactivate it. if (ft == null) { ft = mFragmentManager.beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_NONE); } // ft.detach(tab.fragment); ft.hide(tab.fragment); } } } // We are now ready to go. Make sure we are switched to the // correct tab. mAttached = true; ft = doTabChanged(currentTab, ft); if (ft != null) { ft.commit(); mFragmentManager.executePendingTransactions(); } }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
public void loadEditorPanel(FilterRepresentation representation, final Editor currentEditor) { if (representation.getEditorId() == ImageOnlyEditor.ID) { currentEditor.reflectCurrentFilter(); return;/* w ww . j ava 2s .c o m*/ } final int currentId = currentEditor.getID(); Runnable showEditor = new Runnable() { @Override public void run() { EditorPanel panel = new EditorPanel(); panel.setEditor(currentId); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG)); transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG); transaction.commit(); } }; Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); boolean doAnimation = false; if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { doAnimation = true; } if (doAnimation && main != null && main instanceof MainPanel) { MainPanel mainPanel = (MainPanel) main; View container = mainPanel.getView().findViewById(R.id.category_panel_container); View bottom = mainPanel.getView().findViewById(R.id.bottom_panel); int panelHeight = container.getHeight() + bottom.getHeight(); ViewPropertyAnimator anim = mainPanel.getView().animate(); anim.translationY(panelHeight).start(); final Handler handler = new Handler(); handler.postDelayed(showEditor, anim.getDuration()); } else { showEditor.run(); } }
From source file:com.android.calendar.agenda.AgendaFragment.java
private void showEventInfo(EventInfo event, boolean allDay, boolean replaceFragment) { // Ignore unknown events if (event.id == -1) { Log.e(TAG, "showEventInfo, event ID = " + event.id); return;//w w w . ja v a2 s . c o m } mLastShownEventId = event.id; // Create a fragment to show the event to the side of the agenda list if (mShowEventDetailsWithAgenda) { FragmentManager fragmentManager = getFragmentManager(); if (fragmentManager == null) { // Got a goto event before the fragment finished attaching, // stash the event and handle it later. mOnAttachedInfo = event; mOnAttachAllDay = allDay; return; } FragmentTransaction ft = fragmentManager.beginTransaction(); if (allDay) { event.startTime.timezone = Time.TIMEZONE_UTC; event.endTime.timezone = Time.TIMEZONE_UTC; } if (DEBUG) { Log.d(TAG, "***"); Log.d(TAG, "showEventInfo: start: " + new Date(event.startTime.toMillis(true))); Log.d(TAG, "showEventInfo: end: " + new Date(event.endTime.toMillis(true))); Log.d(TAG, "showEventInfo: all day: " + allDay); Log.d(TAG, "***"); } long startMillis = event.startTime.toMillis(true); long endMillis = event.endTime.toMillis(true); EventInfoFragment fOld = (EventInfoFragment) fragmentManager.findFragmentById(R.id.agenda_event_info); if (fOld == null || replaceFragment || fOld.getStartMillis() != startMillis || fOld.getEndMillis() != endMillis || fOld.getEventId() != event.id) { mEventFragment = new EventInfoFragment(mActivity, event.id, startMillis, endMillis, Attendees.ATTENDEE_STATUS_NONE, false, EventInfoFragment.DIALOG_WINDOW_STYLE, null); ft.replace(R.id.agenda_event_info, mEventFragment); ft.commit(); } else { fOld.reloadEvents(); } } }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
protected void cleanSecondFragment() { Fragment second = getSecondFragment(); if (second != null) { FragmentTransaction tr = getSupportFragmentManager().beginTransaction(); tr.remove(second);//from w w w . j a v a2 s . c o m tr.commit(); } updateFragmentsVisibility(false); updateActionBarTitleAndHomeButton(null); }
From source file:android.support.v7.app.ActionBarImplBase.java
@Override public void selectTab(Tab tab) { if (getNavigationMode() != NAVIGATION_MODE_TABS) { mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION; return;/*ww w .j av a 2 s. com*/ } final FragmentTransaction trans = mActivity.getSupportFragmentManager().beginTransaction() .disallowAddToBackStack(); if (mSelectedTab == tab) { if (mSelectedTab != null) { mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans); mTabScrollView.animateToTab(tab.getPosition()); } } else { mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION); if (mSelectedTab != null) { mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans); } mSelectedTab = (TabImpl) tab; if (mSelectedTab != null) { mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans); } } if (!trans.isEmpty()) { trans.commit(); } }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
private void createMinFragments() { OCFileListFragment listOfFiles = new OCFileListFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.left_fragment_container, listOfFiles, TAG_LIST_OF_FILES); transaction.commit(); }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
/** * Replaces the second fragment managed by the activity with the received as * a parameter.//from w ww. j a v a 2s .c o m * <p/> * Assumes never will be more than two fragments managed at the same time. * * @param fragment New second Fragment to set. */ private void setSecondFragment(Fragment fragment) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.right_fragment_container, fragment, TAG_SECOND_FRAGMENT); transaction.commit(); }
From source file:com.android.gallery3d.v5.filtershow.FilterShowActivity.java
public void loadEditorPanel(FilterRepresentation representation, final Editor currentEditor) { if (representation.getEditorId() == ImageOnlyEditor.ID) { currentEditor.reflectCurrentFilter(); return;/* ww w .j a va 2 s .c om*/ } final int currentId = currentEditor.getID(); Runnable showEditor = new Runnable() { @Override public void run() { Log.i("Test", "showEditor"); EditorPanel panel = new EditorPanel(); panel.setEditor(currentId); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG)); transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG); transaction.commit(); } }; Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); boolean doAnimation = false; if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { doAnimation = true; } if (doAnimation && main != null && main instanceof MainPanel) { MainPanel mainPanel = (MainPanel) main; View container = mainPanel.getView().findViewById(R.id.category_panel_container); View bottom = mainPanel.getView().findViewById(R.id.bottom_panel); int panelHeight = container.getHeight() + bottom.getHeight(); ViewPropertyAnimator anim = mainPanel.getView().animate(); anim.translationY(panelHeight).start(); final Handler handler = new Handler(); handler.postDelayed(showEditor, anim.getDuration()); } else { showEditor.run(); } }
From source file:com.chatwing.whitelabel.activities.CommunicationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ChatWing.instance(getApplicationContext()).getChatwingGraph().plus(); setContentView(R.layout.activity_communication); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//w w w . ja va 2 s . c om getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); mBus.register(this); mContentView = findViewById(R.id.fragment_container); mProgressView = findViewById(R.id.progress_container); mProgressBar = (ProgressBar) mProgressView.findViewById(R.id.loading_view); mProgressText = (TextView) mProgressView.findViewById(R.id.progress_text); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mLoadingView = (ProgressBar) findViewById(R.id.progress_bar); mNewMessageSoundId = getSoundNewMessageId(); mChatboxModeManager.onCreate(savedInstanceState); mConversationModeManager.onCreate(savedInstanceState); stopRefreshAnimation(); //This mode is priority due to user action requesting open int actionMode = getActionMode(getIntent()); LogUtils.v("Intent to use actionMode mode " + actionMode); int pauseSavedMode = mCommunicationActivityManager.getInt(R.string.current_mode_state, 0); int currentMode = MODE_CHAT_BOX; //Default mode is chatbox if (pauseSavedMode != 0) { currentMode = pauseSavedMode; } if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_CURRENT_MODE)) { currentMode = savedInstanceState.getInt(EXTRA_CURRENT_MODE); } //Override current mode by priority mode if (actionMode != MODE_NONE) { currentMode = actionMode; } if (currentMode == MODE_CHAT_BOX) { setupChatboxMode(); } else { setupConversationMode(); } mIsCreated = true; String action = getIntent().getAction(); if (ACTION_STOP_MEDIA.equals(action)) { startService(new Intent(MusicService.ACTION_STOP)); } if (!mBuildManager.isOfficialChatWingApp() && userManager.getCurrentUser() == null) { startActivity(new Intent(this, WhiteLabelCoverActivity.class)); finish(); return; } String onlineFragmentTag = getString(R.string.fragment_tag_online_user); if (getSupportFragmentManager().findFragmentByTag(onlineFragmentTag) == null) { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.right_drawer_container, new OnlineUsersFragment(), onlineFragmentTag); fragmentTransaction.commit(); } String adsFragmentTag = getString(R.string.fragment_tag_ads); if (mBuildManager.isSupportedAds() && getSupportFragmentManager().findFragmentByTag(adsFragmentTag) == null) { getSupportFragmentManager().beginTransaction().add(R.id.ads_container, new AdFragment(), adsFragmentTag) .commit(); } //We start our lovely ChatService so that it listen to faye server startService(new Intent(this, ChatWingChatService.class)); }