List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:com.breadwallet.tools.animation.BRAnimator.java
public static void animateDecoderFragment() { try {/*from w ww .ja va 2 s .c o m*/ 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:cn.org.eshow.framwork.util.AbDialogUtil.java
/** * ??Fragment.//from ww w . ja v a 2 s . com * @param context the context */ public static void removeDialog(final Context context) { try { FragmentActivity activity = (FragmentActivity) context; FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); Fragment prev = activity.getFragmentManager().findFragmentByTag(dialogTag); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); ft.commit(); } catch (Exception e) { //?Activity?? e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
/** * Animate the transition on burgerButton/MenuButton pressed *///from w w w .ja v a2s . c o m public static void pressMenuButton(final MainActivity context) { try { if (context == null) return; ((BreadWalletApp) context.getApplication()).cancelToast(); final FragmentManager fragmentManager = context.getFragmentManager(); if (level == 0) { if (PLATFORM_ON) new Thread(new Runnable() { @Override public void run() { HTTPServer.startServer(); } }).start(); level++; CustomPagerAdapter.adapter.showFragments(false, context); context.setBurgerButtonImage(BRConstants.CLOSE); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); FragmentSettingsAll to = (FragmentSettingsAll) fragmentManager .findFragmentByTag(FragmentSettingsAll.class.getName()); if (to == null) to = new FragmentSettingsAll(); fragmentTransaction.add(R.id.main_layout, to, FragmentSettingsAll.class.getName()); fragmentTransaction.commit(); final FragmentSettingsAll finalTo = to; 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 = finalTo.getView(); if (view != null) view.startAnimation(trans); } }, 1); InputMethodManager keyboard = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); if (keyboard != null) keyboard.hideSoftInputFromWindow( CustomPagerAdapter.adapter.mainFragment.addressEditText.getWindowToken(), 0); } else if (level == 1) { if (PLATFORM_ON) new Thread(new Runnable() { @Override public void run() { HTTPServer.stopServer(); } }).start(); level--; context.setBurgerButtonImage(BRConstants.BURGER); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.to_bottom); FragmentSettingsAll fragmentSettingsAll = (FragmentSettingsAll) fragmentManager .findFragmentByTag(FragmentSettingsAll.class.getName()); fragmentTransaction.remove(fragmentSettingsAll); fragmentTransaction.commit(); CustomPagerAdapter.adapter.showFragments(true, context); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.ab.util.AbDialogUtil.java
/** * ??Fragment.//from w ww. j a va 2 s. c o m * @param context the context */ public static void removeDialog(Context context) { try { FragmentActivity activity = (FragmentActivity) context; FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); ft.commit(); } catch (Exception e) { //?Activity?? e.printStackTrace(); } }
From source file:com.tony.selene.dialog.AbDialogUtil.java
/** * ??Fragment./*www . j av a2s . co m*/ * * @param context * the context */ public static void removeDialog(final Context context) { try { FragmentActivity activity = (FragmentActivity) context; FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); Fragment prev = activity.getFragmentManager().findFragmentByTag(dialogTag); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); ft.commit(); } catch (Exception e) { // ?Activity?? e.printStackTrace(); } }
From source file:com.pszh.ablibrary.util.AbDialogUtil.java
/** * ??Fragment./*from w ww . j a v a 2 s . c o m*/ * @param context the context */ public static void removeDialog(Context context) { try { FragmentActivity activity = (FragmentActivity) context; FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); if (context != null) { ft.commit(); } } catch (Exception e) { //?Activity?? e.printStackTrace(); } }
From source file:com.webileapps.fragments.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Set status bar color if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(Color.BLACK); }//from w ww . j av a2s .c o m currentFragment = new CordovaFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(android.R.id.content, currentFragment); ft.commit(); }
From source file:com.williamcomartin.plexpyremote.AboutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); setupActionBar();/*from w w w . j a v a 2s . co m*/ LibsFragment fragment = new LibsBuilder().withLicenseShown(true).withAboutIconShown(true) .withAboutAppName(getString(R.string.app_name)).withVersionShown(true) .withAboutVersionString(BuildConfig.VERSION_NAME + "." + BuildConfig.VERSION_CODE) .withAboutDescription(getString(R.string.app_about_description)).fragment(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.about_frame_layout, fragment); fragmentTransaction.commit(); }
From source file:com.androidhacks7.fastcontactsloader.ContactsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_contacts); getActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.dark_green))); if (savedInstanceState == null) { contactListFragment = new ContactListFragment(); contactListFragment.setContactSelectionListener(this); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.container, contactListFragment); ft.commit(); }/* w ww . j a v a 2s .com*/ }
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(); FragmentTransaction ft2 = getFragmentManager().beginTransaction(); ft2.add(R.id.videoFragment, new VideoConsumptionExampleFragment(), VideoConsumptionExampleFragment.TAG); ft2.commit();//from ww w. j av a 2s . c o m }