List of usage examples for android.app FragmentTransaction show
public abstract FragmentTransaction show(Fragment fragment);
From source file:org.kymjs.kjframe.KJActivity.java
/** * Fragment?//from ww w. j a va 2 s . com * * @param resView ?? * @param targetFragment ??Fragment */ public void changeFragment(int resView, KJFragment targetFragment) { if (targetFragment.equals(currentKJFragment)) { return; } FragmentTransaction transaction = getFragmentManager().beginTransaction(); if (!targetFragment.isAdded()) { transaction.add(resView, targetFragment, targetFragment.getClass().getName()); } if (targetFragment.isHidden()) { transaction.show(targetFragment); targetFragment.onChange(); } if (currentKJFragment != null && currentKJFragment.isVisible()) { transaction.hide(currentKJFragment); } currentKJFragment = targetFragment; transaction.commit(); }
From source file:org.kymjs.kjframe.KJActivity.java
/** * Fragment?//from w ww . j av a2s . c om * * @param resView ?? * @param targetFragment ??Fragment * @param isBack ??true */ public void changeFragment(int resView, KJFragment targetFragment, boolean isBack) { if (targetFragment.equals(currentKJFragment)) { return; } FragmentTransaction transaction = getFragmentManager().beginTransaction(); if (!targetFragment.isAdded()) { transaction.add(resView, targetFragment, targetFragment.getClass().getName()); } if (targetFragment.isHidden()) { transaction.show(targetFragment); targetFragment.onChange(); } if (currentKJFragment != null && currentKJFragment.isVisible()) { transaction.hide(currentKJFragment); } if (isBack) { transaction.addToBackStack(null); } currentKJFragment = targetFragment; transaction.commit(); }
From source file:org.kymjs.kjframe.KJActivity.java
/** * Fragment?/*w w w .j av a 2 s . co m*/ * * @param resView ?? * @param targetFragment ??Fragment * @param isBack ??true */ public void changeFragment(int resView, SupportFragment targetFragment, boolean isBack) { if (targetFragment.equals(currentSupportFragment)) { return; } android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (!targetFragment.isAdded()) { transaction.add(resView, targetFragment, targetFragment.getClass().getName()); } if (targetFragment.isHidden()) { transaction.show(targetFragment); targetFragment.onChange(); } if (currentSupportFragment != null && currentSupportFragment.isVisible()) { transaction.hide(currentSupportFragment); } if (isBack) { transaction.addToBackStack(null); } currentSupportFragment = targetFragment; transaction.commit(); }
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//from ww w. jav a 2 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 { // 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.telestax.restcomm_olympus.CallActivity.java
public void onClick(View view) { if (view.getId() == R.id.button_hangup) { if (pendingConnection != null) { // incoming ringing lblStatus.setText("Rejecting Call..."); pendingConnection.reject();//from ww w. j a v a2s . c o m pendingConnection = null; } else { if (connection != null) { // incoming established or outgoing any state (pending, connecting, connected) lblStatus.setText("Disconnecting Call..."); connection.disconnect(); connection = null; pendingConnection = null; } else { Log.e(TAG, "Error: not connected/connecting/pending"); } } finish(); } else if (view.getId() == R.id.button_answer) { if (pendingConnection != null) { lblStatus.setText("Answering Call..."); btnAnswer.setVisibility(View.INVISIBLE); btnAnswerAudio.setVisibility(View.INVISIBLE); acceptParams = new HashMap<String, Object>(); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, true); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, findViewById(R.id.local_video_layout)); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO, findViewById(R.id.remote_video_layout)); // Check permissions asynchronously and then accept the call handlePermissions(true); } } else if (view.getId() == R.id.button_answer_audio) { if (pendingConnection != null) { lblStatus.setText("Answering Call..."); btnAnswer.setVisibility(View.INVISIBLE); btnAnswerAudio.setVisibility(View.INVISIBLE); acceptParams = new HashMap<String, Object>(); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, false); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, findViewById(R.id.local_video_layout)); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO, findViewById(R.id.remote_video_layout)); // Check permissions asynchronously and then accept the call handlePermissions(false); } } else if (view.getId() == R.id.button_keypad) { keypadFragment.setConnection(connection); // show keypad FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(keypadFragment); ft.commit(); } else if (view.getId() == R.id.button_mute_audio) { if (connection != null) { if (!muteAudio) { btnMuteAudio.setImageResource(R.drawable.audio_muted_50x50); } else { btnMuteAudio.setImageResource(R.drawable.audio_active_50x50); } muteAudio = !muteAudio; connection.setAudioMuted(muteAudio); } } else if (view.getId() == R.id.button_mute_video) { if (connection != null) { if (!muteVideo) { btnMuteVideo.setImageResource(R.drawable.video_muted_50x50); } else { btnMuteVideo.setImageResource(R.drawable.video_active_50x50); } muteVideo = !muteVideo; connection.setVideoMuted(muteVideo); } } }
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 ww .j a v a 2 s . c o m fragmentTransaction.commitAllowingStateLoss(); }
From source file:com.ppgllrd.alfil.MainActivity.java
private void selectCourse(int position) { Log.d("ppgllrd", "selectCourse" + position + " " + drawerSelectedIdx); boolean isSelectable = drawerItems.get(position) instanceof DrawerCourse; if (isSelectable) { final DrawerCourse drawerCourse = (DrawerCourse) drawerItems.get(position); FragmentManager fragmentManager = getFragmentManager(); Log.d("ppgllrd", "Count:" + fragmentManager.getBackStackEntryCount()); if (position != drawerSelectedIdx) { Log.d("ppgllrd", "YES"); drawerSelectedIdx = position; studentsListFragment = new StudentsListFragment(); Bundle args = new Bundle(); args.putParcelable(StudentsListFragment.ARG_GROUP_STUDENTS_COURSE, drawerCourse.getCourse()); studentsListFragment.setArguments(args); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.list_Fragment_Placeholder, studentsListFragment, StudentsListFragment.FragmentTag); //ft.addToBackStack(StudentInfoFragment.FragmentTag); ft.commit();//from w w w. j a va2 s . co m } Log.d("ppgllrd", "YYY"); actionBarTitleController.closeDrawer(); if (studentInfoFragment.isShown()) { FragmentManager fm = getFragmentManager(); if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); } } FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(studentsListFragment); ft.hide(studentInfoFragment); // ft.addToBackStack(StudentInfoFragment.FragmentTag); ft.commit(); } Log.d("ppgllrd", "ZZZ"); }
From source file:com.github.chenxiaolong.dualbootpatcher.MainActivity.java
private void showFragment() { FragmentManager fm = getFragmentManager(); Fragment prevRoms = fm.findFragmentByTag(SwitcherListFragment.TAG); Fragment prevPatchFile = fm.findFragmentByTag(PatchFileFragment.TAG); Fragment prevFreeSpace = fm.findFragmentByTag(FreeSpaceFragment.TAG); Fragment prevAbout = fm.findFragmentByTag(AboutFragment.TAG); FragmentTransaction ft = fm.beginTransaction(); ft.setCustomAnimations(R.animator.fragment_in, 0); switch (mFragment) { case FRAGMENT_ROMS: mTitle = R.string.title_roms;/*from w ww .jav a 2s. com*/ updateTitle(); if (prevRoms == null) { Fragment f = SwitcherListFragment.newInstance(); ft.add(R.id.content_frame, f, SwitcherListFragment.TAG); } else { ft.show(prevRoms); } break; case FRAGMENT_PATCH_FILE: mTitle = R.string.title_patch_zip; updateTitle(); if (prevPatchFile == null) { Fragment f = PatchFileFragment.newInstance(); ft.add(R.id.content_frame, f, PatchFileFragment.TAG); } else { ft.show(prevPatchFile); } break; case FRAGMENT_FREE_SPACE: mTitle = R.string.title_free_space; updateTitle(); if (prevFreeSpace == null) { Fragment f = FreeSpaceFragment.newInstance(); ft.add(R.id.content_frame, f, FreeSpaceFragment.TAG); } else { ft.show(prevFreeSpace); } break; case FRAGMENT_ABOUT: mTitle = BuildConfig.APP_NAME_RESOURCE; updateTitle(); if (prevAbout == null) { Fragment f = AboutFragment.newInstance(); ft.add(R.id.content_frame, f, AboutFragment.TAG); } else { ft.show(prevAbout); } break; default: throw new IllegalStateException("Invalid fragment ID"); } ft.commit(); }
From source file:us.shandian.blacklight.ui.main.MainActivity.java
private void switchTo(int id) { FragmentTransaction ft = mManager.beginTransaction(); ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out, android.R.animator.fade_in, android.R.animator.fade_out); for (int i = 0; i < mFragments.length; i++) { Fragment f = mFragments[i];/*w w w . ja va 2 s . c om*/ if (f != null) { if (i != id) { ft.hide(f); } else { ft.show(f); } } } ft.commit(); mCurrent = id; mNext = id; }
From source file:org.restcomm.android.olympus.CallActivity.java
public void onClick(View view) { if (view.getId() == R.id.button_hangup) { if (pendingConnection != null) { // incoming ringing lblStatus.setText("Rejecting Call..."); pendingConnection.reject();//from www.j a v a2s . co m pendingConnection = null; } else { if (connection != null) { // incoming established or outgoing any state (pending, connecting, connected) lblStatus.setText("Disconnecting Call..."); connection.disconnect(); connection = null; pendingConnection = null; } else { Log.e(TAG, "Error: not connected/connecting/pending"); } } finish(); } else if (view.getId() == R.id.button_answer) { if (pendingConnection != null) { lblStatus.setText("Answering Call..."); btnAnswer.setVisibility(View.INVISIBLE); btnAnswerAudio.setVisibility(View.INVISIBLE); acceptParams = new HashMap<String, Object>(); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, true); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, (PercentFrameLayout) findViewById(R.id.local_video_layout)); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO, (PercentFrameLayout) findViewById(R.id.remote_video_layout)); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, audioCodecString2Enum( prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, ""))); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC, videoCodecString2Enum( prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC, ""))); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION, resolutionString2Enum(prefs .getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION, ""))); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE, frameRateString2Enum(prefs .getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE, ""))); acceptParams.put(RCConnection.ParameterKeys.DEBUG_CONNECTION_CANDIDATE_TIMEOUT, Integer.parseInt( prefs.getString(RCConnection.ParameterKeys.DEBUG_CONNECTION_CANDIDATE_TIMEOUT, "0"))); // Check permissions asynchronously and then accept the call handlePermissions(true); } } else if (view.getId() == R.id.button_answer_audio) { if (pendingConnection != null) { lblStatus.setText("Answering Call..."); btnAnswer.setVisibility(View.INVISIBLE); btnAnswerAudio.setVisibility(View.INVISIBLE); acceptParams = new HashMap<String, Object>(); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, false); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, (PercentFrameLayout) findViewById(R.id.local_video_layout)); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO, (PercentFrameLayout) findViewById(R.id.remote_video_layout)); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, audioCodecString2Enum( prefs.getString(RCConnection.ParameterKeys.CONNECTION_PREFERRED_AUDIO_CODEC, ""))); acceptParams.put(RCConnection.ParameterKeys.DEBUG_CONNECTION_CANDIDATE_TIMEOUT, Integer.parseInt( prefs.getString(RCConnection.ParameterKeys.DEBUG_CONNECTION_CANDIDATE_TIMEOUT, "0"))); // Check permissions asynchronously and then accept the call handlePermissions(false); } } else if (view.getId() == R.id.button_keypad) { keypadFragment.setConnection(connection); View rootView = getWindow().getDecorView().findViewById(android.R.id.content); // show keypad FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(keypadFragment); ft.commit(); } else if (view.getId() == R.id.button_mute_audio) { if (connection != null) { if (!muteAudio) { btnMuteAudio.setImageResource(R.drawable.audio_muted); } else { btnMuteAudio.setImageResource(R.drawable.audio_unmuted); } muteAudio = !muteAudio; connection.setAudioMuted(muteAudio); } } else if (view.getId() == R.id.button_mute_video) { if (connection != null) { muteVideo = !muteVideo; if (muteVideo) { btnMuteVideo.setImageResource(R.drawable.video_muted); //connection.detachVideo(); } else { btnMuteVideo.setImageResource(R.drawable.video_unmuted); //connection.reattachVideo((PercentFrameLayout)findViewById(R.id.local_video_layout), (PercentFrameLayout)findViewById(R.id.remote_video_layout)); } connection.setVideoMuted(muteVideo); } } }