List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:de.mrapp.android.preference.activity.PreferenceActivity.java
/** * Replaces the fragment, which is currently contained by a specific parent view, by an other * fragment./*from w w w . ja v a2 s . com*/ * * @param fragment * The fragment, which should replace the current fragment, as an instance of the class * {@link Fragment}. The fragment may not be null * @param parentViewId * The id of the parent view, which contains the fragment, that should be replaced, as * an {@link Integer} value * @param transition * The transition, which should be shown when replacing the fragment, as an {@link * Integer} value or 0, if no transition should be shown */ private void replaceFragment(@NonNull final Fragment fragment, final int parentViewId, final int transition) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setTransition(transition); transaction.replace(parentViewId, fragment); transaction.commit(); }
From source file:org.opendatakit.tables.activities.TableDisplayActivity.java
/** * Show the spreadsheet fragment./*from w w w. j a v a 2 s . c o m*/ * * @param createNew */ public void showSpreadsheetFragment(boolean createNew) { this.setCurrentFragmentType(ViewFragmentType.SPREADSHEET); this.updateChildViewVisibility(ViewFragmentType.SPREADSHEET); FragmentManager fragmentManager = this.getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); // Hide all the other fragments. this.hideAllOtherViewFragments(ViewFragmentType.SPREADSHEET, fragmentTransaction); // Try to retrieve one already there. SpreadsheetFragment spreadsheetFragment = (SpreadsheetFragment) fragmentManager .findFragmentByTag(Constants.FragmentTags.SPREADSHEET); if (spreadsheetFragment == null) { WebLogger.getLogger(getAppName()).d(TAG, "[showSpreadsheetFragment] no existing spreadshseet " + "fragment found"); } else { WebLogger.getLogger(getAppName()).d(TAG, "[showSpreadsheetFragment] existing spreadsheet fragment " + "found"); } WebLogger.getLogger(getAppName()).d(TAG, "[showSpreadsheetFragment] createNew is: " + createNew); if (spreadsheetFragment == null || createNew) { if (spreadsheetFragment != null) { WebLogger.getLogger(getAppName()).d(TAG, "[showSpreadsheetFragment] removing existing fragment"); // Get rid of the existing fragment fragmentTransaction.remove(spreadsheetFragment); } spreadsheetFragment = this.createSpreadsheetFragment(); fragmentTransaction.add(R.id.activity_table_display_activity_one_pane_content, spreadsheetFragment, Constants.FragmentTags.SPREADSHEET); } else { fragmentTransaction.show(spreadsheetFragment); } fragmentTransaction.commit(); }
From source file:org.appspot.apprtc.CallActivity.java
@Override public void onBackPressed() { if (chatFragment.isAdded()) { // Show in call fragment android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(chatFragment);/*from w ww . j av a 2 s . co m*/ ft.commit(); } else { super.onBackPressed(); } }
From source file:org.appspot.apprtc.CallActivity.java
@Override public void onStartConferenceCall(User user) { FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.call_fragment_container, callFragment); ft.commit(); if (!mVideoCallEnabled) { remoteUserImage.setVisibility(View.VISIBLE); }//from w w w. j a va 2s.co m callUser(user); updateVideoView(); if (mLocalSdp == null) { mWaitingToStartCall = true; } else { StartCall(mPeerId); } }
From source file:org.appspot.apprtc.CallActivity.java
@Override public boolean showUserList() { userListShown = !userListShown;//w w w . j av a2 s . co m if (userListShown) { // Show in call fragment FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.call_list_fragment_container, callListFragment); ft.commit(); } else { // Show in call fragment FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.remove(callListFragment); ft.commit(); } return userListShown; }
From source file:org.appspot.apprtc.CallActivity.java
@Override public void showChatMessages(String roomName, String fromId, User user) { if (!chatFragment.isAdded()) { // Show in call fragment android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.chat_fragment_container, chatFragment); ft.commit(); }//from w w w.j a v a 2 s. com }
From source file:org.appspot.apprtc.CallActivity.java
public void showChatMessages(User user) { if (!chatFragment.isAdded()) { // Show in call fragment android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.chat_fragment_container, chatFragment); ft.commit(); }/* w w w .ja v a 2 s. co m*/ chatFragment.setAvatarUrl(mService.getAvatarUrl()); Bundle args = chatFragment.getArguments(); args.putSerializable(WebsocketService.EXTRA_USER, user); chatFragment.setArguments(args); chatFragment.setUser(user); chatFragment.viewChat(user.Id); }
From source file:org.appspot.apprtc.CallActivity.java
@Override public void onAnswerCall() { AnswerIncomingCall(mPeerId);/*from w w w.j a v a2s . c o m*/ FragmentTransaction ft = getFragmentManager().beginTransaction(); if (!mVideoCallEnabled) { ft.add(R.id.call_list_fragment_container, callListFragment); } ft.replace(R.id.call_fragment_container, callFragment); ft.commit(); if (!mVideoCallEnabled) { remoteUserImage.setVisibility(View.VISIBLE); } }
From source file:org.appspot.apprtc.CallActivity.java
@Override public void onRemoteDescription(final SerializableSessionDescription sdp, final String token, String id, String conferenceId, final String fromId, final String roomName, String type) { final long delta = System.currentTimeMillis() - callStartedTimeMs; runOnUiThread(new Runnable() { @Override/*w w w. ja va 2 s .c o m*/ public void run() { if (peerConnectionClient == null) { Log.e(TAG, "Received remote SDP for non-initilized peer connection."); return; } //logAndToast("Received remote " + sdp.type + ", delay=" + delta + "ms"); SessionDescription sd = new SessionDescription(sdp.type, sdp.description); peerConnectionClient.setRemoteDescription(sd, token); if (!initiator) { //logAndToast("Creating ANSWER..."); // Create answer. Answer SDP will be sent to offering client in // PeerConnectionEvents.onLocalDescription event. peerConnectionClient.createAnswer(); } else if (sd.type == SessionDescription.Type.OFFER) { // tried to call SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); fmt.setTimeZone(TimeZone.getTimeZone("GMT")); String time = fmt.format(new Date()); String missedCall = String.format(getString(R.string.missed_call), mPeerName); mService.onChatMessage(missedCall, time, "", mOwnId, mPeerId, roomName); sendBye(fromId, "busy"); onCallHangUp(); } else { // Show in call fragment FragmentTransaction ft = getFragmentManager().beginTransaction(); if (!mVideoCallEnabled) { ft.add(R.id.call_list_fragment_container, callListFragment); } ft.replace(R.id.call_fragment_container, callFragment); ft.commit(); if (!mVideoCallEnabled) { remoteUserImage.setVisibility(View.VISIBLE); } } } }); }
From source file:org.appspot.apprtc.CallActivity.java
private void toggleCallControlFragmentVisibility() { updateVideoView();//from ww w . j a v a 2 s . c om if (!iceConnected || !callFragment.isAdded()) { return; } // Show/hide call control fragment callControlFragmentVisible = !callControlFragmentVisible; FragmentTransaction ft = getFragmentManager().beginTransaction(); if (callControlFragmentVisible) { ft.show(callFragment); ft.show(hudFragment); } else { ft.hide(callFragment); ft.hide(hudFragment); } ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); }