List of usage examples for android.app FragmentTransaction replace
public abstract FragmentTransaction replace(@IdRes int containerViewId, Fragment fragment, String tag);
From source file:com.breadwallet.tools.animation.BRAnimator.java
public static void animateSlideToRight(final MainActivity context) { try {/*from w ww. ja v a2s. c o m*/ if (!checkTheHorizontalSlideAvailability()) return; final Fragment tmp = previous.pop(); level--; if (level < 1) context.setBurgerButtonImage(BRConstants.BURGER); if (level == 1) context.setBurgerButtonImage(BRConstants.CLOSE); FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.main_layout, tmp, tmp.getClass().getName()); fragmentTransaction.commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(-MainActivity.screenParametersPoint.x, 0, 0, 0); trans.setDuration(horizontalSlideDuration); trans.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f)); View view = tmp.getView(); if (view != null) view.startAnimation(trans); } }, 1); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
/** * Animates the fragment transition on button_regular_blue "Settings" pressed *///w ww. ja v a 2 s. c om public static void animateSlideToLeft(final MainActivity context, final Fragment to, Fragment previousFragment) { try { if (!checkTheHorizontalSlideAvailability()) return; level++; if (level > 1) context.setBurgerButtonImage(BRConstants.BACK); FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.main_layout, to, to.getClass().getName()); if (previousFragment != null) previous.add(previousFragment); fragmentTransaction.commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(MainActivity.screenParametersPoint.x, 0, 0, 0); trans.setDuration(horizontalSlideDuration); trans.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f)); View view = to.getView(); if (view != null) view.startAnimation(trans); } }, 1); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
/** * Animate the transition on wipe wallet fragment *//*from w w w . j av a 2 s . co m*/ public static void pressWipeWallet(final MainActivity context, final Fragment to) { try { if (!wipeWalletOpen) { wipeWalletOpen = true; FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.main_layout, to, to.getClass().getName()); fragmentTransaction.commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(0, 0, 1920, 0); trans.setDuration(500); trans.setInterpolator(new DecelerateOvershootInterpolator(3f, 0.5f)); View view = to.getView(); if (view != null) view.startAnimation(trans); } }, 1); } else { wipeWalletOpen = false; FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.to_bottom); fragmentTransaction.replace(R.id.main_layout, new FragmentSettings(), FragmentSettings.class.getName()); fragmentTransaction.commit(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
public static void animateScanResultFragment() { try {/*from w w w . ja va 2 s .com*/ final MainActivity app = MainActivity.app; if (app == null || scanResultFragmentOn) return; CustomPagerAdapter.adapter.showFragments(false, app); scanResultFragmentOn = true; InputMethodManager keyboard = (InputMethodManager) app.getSystemService(Context.INPUT_METHOD_SERVICE); try { keyboard.hideSoftInputFromWindow( CustomPagerAdapter.adapter.mainFragment.addressEditText.getWindowToken(), 0); } catch (Exception e) { e.printStackTrace(); } app.setBurgerButtonImage(BRConstants.BACK); //Disabled inspection: <Expected resource type anim> final FragmentManager fragmentManager = app.getFragmentManager(); final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); final FragmentScanResult scanResult = new FragmentScanResult(); fragmentTransaction.replace(R.id.main_layout, scanResult, FragmentScanResult.class.getName()); fragmentTransaction.commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(MainActivity.screenParametersPoint.x, 0, 0, 0); trans.setDuration(500); trans.setInterpolator(new DecelerateOvershootInterpolator(3f, 0.5f)); View view = scanResult.getView(); if (view != null) view.startAnimation(trans); } }, 1); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
public static void animateDecoderFragment() { try {/* w w w. j av a2s . c om*/ MainActivity app = MainActivity.app; if (app == null) return; // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(app, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(app, Manifest.permission.CAMERA)) { ((BreadWalletApp) app.getApplication()).showCustomToast(app, app.getString(R.string.allow_camera_access), MainActivity.screenParametersPoint.y / 2, Toast.LENGTH_LONG, 0); } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(app, new String[] { Manifest.permission.CAMERA }, BRConstants.CAMERA_REQUEST_ID); } } else { if (BRAnimator.level > 0) BRAnimator.pressMenuButton(app); decoderFragmentOn = true; app.activityButtonsEnable(false); CustomPagerAdapter.adapter.showFragments(false, app); //Disabled inspection: <Expected resource type anim> FragmentTransaction fragmentTransaction = app.getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.from_bottom, R.animator.to_top); FragmentDecoder fragmentDecoder = new FragmentDecoder(); fragmentTransaction.replace(R.id.main_layout, fragmentDecoder, FragmentDecoder.class.getName()); int temp = fragmentTransaction.commit(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:android.support.v17.leanback.supportleanbackshowcase.app.media.VideoExampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_example); FragmentTransaction ft1 = getFragmentManager().beginTransaction(); ft1.replace(R.id.videoFragment, new VideoSurfaceFragment(), VideoSurfaceFragment.TAG); ft1.commit();//from ww w. ja v a2 s . co m FragmentTransaction ft2 = getFragmentManager().beginTransaction(); ft2.add(R.id.videoFragment, new VideoConsumptionExampleFragment(), VideoConsumptionExampleFragment.TAG); ft2.commit(); }
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.LevelOneActivity.java
private void setFragment(Fragment fragment, String fragmentTag) { Log.d(TAG, "setFragment: " + fragmentTag); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.content_frame_level_one, fragment, fragmentTag); transaction.addToBackStack(null);/*from w ww . j a v a 2 s . c om*/ transaction.commit(); }
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.video.SignSearchVideoActivity.java
private void showSignVideoFragment(SignVideoFragment signVideoFragment) { final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.searchVideoActivityContentFrame, signVideoFragment, "SIGN_VIDEO_TAG"); transaction.addToBackStack(null);/*from ww w . ja v a 2 s . c o m*/ transaction.commit(); }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
public static void add(FragmentManager fm, SettingsLayoutFragment f) { boolean hasDialog = fm.findFragmentByTag(TAG_LEAN_BACK_DIALOG_FRAGMENT) != null; FragmentTransaction ft = fm.beginTransaction(); if (hasDialog) { ft.setCustomAnimations(ANIMATION_FRAGMENT_ENTER, ANIMATION_FRAGMENT_EXIT, ANIMATION_FRAGMENT_ENTER_POP, ANIMATION_FRAGMENT_EXIT_POP); ft.addToBackStack(null);//from w w w . j a v a 2s . co m } ft.replace(android.R.id.content, f, TAG_LEAN_BACK_DIALOG_FRAGMENT).commit(); }
From source file:com.liferay.social.activity.MainActivity.java
private void _replaceRightFragment(Fragment fragment, String tag) { FragmentManager manager = getFragmentManager(); Fragment replacement = manager.findFragmentByTag(tag); if (replacement == null) { replacement = fragment;//from w w w. jav a 2s. com } FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.right_fragment, replacement, tag); transaction.commit(); _drawer.closeDrawers(); }