Java Code Examples for androidx.fragment.app.FragmentTransaction#setCustomAnimations()
The following examples show how to use
androidx.fragment.app.FragmentTransaction#setCustomAnimations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TVShowsActivity.java From Kore with Apache License 2.0 | 6 votes |
@TargetApi(21) private void startFragment(AbstractFragment fragment) { // Replace list fragment FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { fragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); fragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, fragment) .addToBackStack(null) .commit(); }
Example 2
Source File: AbsSearchBarActivity.java From call_manage with MIT License | 6 votes |
/** * Toggles the search bar according to it's current state */ public void toggleSearchBar(boolean isShow) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.slide_up, R.anim.slide_down); if (isShow) { mToggled = true; mSearchBarContainer.setVisibility(View.VISIBLE); ft.show(mSearchBarFragment); mSearchBarFragment.setFocus(); Utilities.toggleKeyboard(this, mSearchBarFragment.mSearchInput, true); } else { mToggled = false; mSearchBarContainer.setVisibility(View.GONE); ft.hide(mSearchBarFragment); Utilities.toggleKeyboard(this, mSearchBarFragment.mSearchInput, false); } ft.commit(); }
Example 3
Source File: BankAccCoinifyActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private void navigateToFragment(Fragment fragment) { getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.slide_up, R.anim.fade_out_animation, R.anim.fade_out_animation, R.anim.slide_down); fragmentTransaction.replace(R.id.fl_main_root, fragment); fragmentTransaction.commit(); }
Example 4
Source File: FragmentDemo.java From ShineButton with MIT License | 5 votes |
public void showFragment(final FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.setCustomAnimations( R.anim.fragmentv_slide_bottom_enter, 0, 0, R.anim.fragmentv_slide_top_exit); transaction.add(Window.ID_ANDROID_CONTENT, FragmentDemo.this, "FragmentDemo"); transaction.addToBackStack(null); transaction.commitAllowingStateLoss(); }
Example 5
Source File: BaseActivity.java From PHONK with GNU General Public License v3.0 | 5 votes |
public void addFragment(Fragment fragment, int fragmentPosition, boolean addToBackStack) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // FIXME: Because we have no tagging system we need to use the int as mContext // tag, which may cause collisions ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(fragmentPosition, fragment, String.valueOf(fragmentPosition)); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); if (addToBackStack) { ft.addToBackStack(null); } ft.commit(); }
Example 6
Source File: BaseActivity.java From PHONK with GNU General Public License v3.0 | 5 votes |
public void addFragment(Fragment fragment, int fragmentPosition, String tag, boolean addToBackStack) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(fragmentPosition, fragment, tag); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); if (addToBackStack) { ft.addToBackStack(null); } ft.commit(); }
Example 7
Source File: EditorActivity.java From PHONK with GNU General Public License v3.0 | 5 votes |
public void addFileManagerDrawer(Bundle savedInstance, boolean b) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_left); if (b) { if (savedInstance == null) { fileFragment = FileManagerFragment.newInstance(); Bundle bundle = new Bundle(); bundle.putString(FileManagerFragment.ROOT_FOLDER, mCurrentProject.getFullPath()); // we pass the initial route to hide bundle.putString(FileManagerFragment.PATH_HIDE_PATH_FROM, mCurrentProject.geFoldertPath()); fileFragment.setArguments(bundle); if (isTablet) { ft.add(R.id.fragmentFileManager, fileFragment, FRAGMENT_FILE_PREVIEWER); } else { ft.add(R.id.fragmentFileManager, fileFragment, FRAGMENT_FILE_PREVIEWER).addToBackStack("filemanager"); } } else { if (isTablet) { filePreviewerFragment = (FilePreviewerFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_FILE_PREVIEWER); } else { filePreviewerFragment = (FilePreviewerFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_FILE_PREVIEWER); } } } else { ft.remove(fileFragment); } ft.commit(); }
Example 8
Source File: Util.java From Snake with Apache License 2.0 | 5 votes |
public static void push(Fragment current, Fragment next, @IdRes int containerId) { FragmentTransaction ft = current.requireActivity().getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.snake_slide_in_right, R.anim.snake_slide_out_left, R.anim.snake_slide_in_left, R.anim.snake_slide_out_right); ft.add(containerId, next, next.getClass().getCanonicalName()).hide(current) .addToBackStack(current.getClass().getCanonicalName()); ft.commit(); }
Example 9
Source File: PVRActivity.java From Kore with Apache License 2.0 | 5 votes |
/** * Callback from list fragment when the channel guide should be displayed. * Setup action bar and repolace list fragment * @param channelId Channel selected * @param channelTitle Title */ @TargetApi(21) public void onChannelGuideSelected(int channelId, String channelTitle, boolean singleChannelGroup) { this.selectedChannelId = channelId; this.selectedChannelTitle = channelTitle; this.singleChannelGroup = singleChannelGroup; // Replace list fragment PVRChannelEPGListFragment pvrEPGFragment = PVRChannelEPGListFragment.newInstance(channelId); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { pvrEPGFragment.setEnterTransition( TransitionInflater.from(this) .inflateTransition(R.transition.media_details)); pvrEPGFragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, pvrEPGFragment) .addToBackStack(null) .commit(); updateActionBar(getActionBarTitle(), true); }
Example 10
Source File: HueFragment03.java From DeviceConnect-Android with MIT License | 5 votes |
private void moveNextFragment() { FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.setCustomAnimations(R.anim.fragment_slide_right_enter, R.anim.fragment_slide_left_exit, R.anim.fragment_slide_left_enter, R.anim.fragment_slide_right_exit); transaction.replace(R.id.fragment_frame, HueFragment04.newInstance(mAccessPoint)); transaction.commit(); }
Example 11
Source File: MainActivity.java From Passbook with Apache License 2.0 | 5 votes |
@Override public void onEdit(int categoryId, int accountId) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if(accountId < 0) { ft.setCustomAnimations(R.anim.slide_in_bottom, 0, 0, R.anim.slide_out_bottom); } ft.replace(R.id.detail_panel, EditFragment.create(categoryId, accountId), "edit") .addToBackStack("edit") .commitAllowingStateLoss(); mAds.setVisibility(View.GONE); }
Example 12
Source File: MainActivity.java From Passbook with Apache License 2.0 | 5 votes |
@Override public void onEdit(int categoryId, int accountId) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if(accountId < 0) { ft.setCustomAnimations(R.anim.slide_in_bottom, 0, 0, R.anim.slide_out_bottom); } ft.replace(R.id.detail_panel, EditFragment.create(categoryId, accountId), "edit") .addToBackStack("edit") .commitAllowingStateLoss(); }
Example 13
Source File: MainActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private void navigateToFragment(Fragment fragment) { if (isFinishing()) return; getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.slide_up, R.anim.fade_out_animation, R.anim.fade_out_animation, R.anim.slide_down); fragmentTransaction.replace(R.id.fl_main_root, fragment); fragmentTransaction.commit(); }
Example 14
Source File: EnterEmailToPurchaseActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
protected void navigateToFragment(Fragment fragment) { getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.slide_up, R.anim.fade_out_animation, R.anim.fade_out_animation, R.anim.slide_down); fragmentTransaction.add(fragment, PurchaseCoinsFragment.class.getSimpleName()); fragmentTransaction.commit(); }
Example 15
Source File: SettingsFragment.java From natrium-android-wallet with BSD 2-Clause "Simplified" License | 5 votes |
public void onClickContacts(View view) { if (getActivity() instanceof WindowControl) { FragmentTransaction ft = ((WindowControl) getActivity()).getFragmentUtility().getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right); ContactOverviewFragment fragment = ContactOverviewFragment.newInstance(); ft.replace(R.id.settings_frag_container, fragment, ContactOverviewFragment.TAG).addToBackStack(null).commit(); ((WindowControl) getActivity()).getFragmentUtility().getFragmentManager().executePendingTransactions(); } }
Example 16
Source File: SampleActivity.java From CircleIndicator with Apache License 2.0 | 5 votes |
private void navigateToFragment(String fragmentName) { Fragment fragment = getFragmentManager().getFragmentFactory() .instantiate(getContext().getClassLoader(), fragmentName); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out, android.R.anim.fade_in, android.R.anim.fade_out); fragmentTransaction.replace(R.id.fragment_container, fragment); fragmentTransaction.addToBackStack(fragmentName); fragmentTransaction.commit(); }
Example 17
Source File: WelcomeActivity.java From EdXposedManager with GNU General Public License v3.0 | 4 votes |
private void navigate(final int itemId) { final View elevation = findViewById(R.id.elevation); Fragment navFragment = null; switch (itemId) { case R.id.drawer_item_1: mPrevSelectedId = itemId; setTitle(R.string.app_name); navFragment = new AdvancedInstallerFragment(); break; case R.id.drawer_item_2: mPrevSelectedId = itemId; setTitle(R.string.nav_item_modules); navFragment = new ModulesFragment(); break; case R.id.drawer_item_3: mPrevSelectedId = itemId; setTitle(R.string.nav_item_download); navFragment = new DownloadFragment(); break; case R.id.drawer_item_4: mPrevSelectedId = itemId; setTitle(R.string.nav_item_logs); navFragment = new LogsFragment(); break; case R.id.nav_black_list: mPrevSelectedId = itemId; setTitle(R.string.nav_title_black_list); navFragment = new ApplicationFragment(); break; case R.id.nav_compat_list: mPrevSelectedId = itemId; setTitle(R.string.title_compat_list); navFragment = new CompatListFragment(); break; case R.id.drawer_item_5: startActivity(new Intent(this, SettingsActivity.class)); mNavigationView.getMenu().findItem(mPrevSelectedId).setChecked(true); return; case R.id.drawer_item_6: startActivity(new Intent(this, AboutActivity.class)); mNavigationView.getMenu().findItem(mPrevSelectedId).setChecked(true); return; } final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(4)); if (navFragment != null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out); try { transaction.replace(R.id.content_frame, navFragment).commit(); if (elevation != null) { params.topMargin = navFragment instanceof AdvancedInstallerFragment ? dp(48) : 0; Animation a = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { elevation.setLayoutParams(params); } }; a.setDuration(150); elevation.startAnimation(a); } } catch (IllegalStateException ignored) { } } }
Example 18
Source File: StageActivity.java From MHViewer with Apache License 2.0 | 4 votes |
private void finishScene(String tag, TransitionHelper transitionHelper) { FragmentManager fragmentManager = getSupportFragmentManager(); // Get scene Fragment scene = fragmentManager.findFragmentByTag(tag); if (scene == null) { Log.e(TAG, "finishScene: Can't find scene by tag: " + tag); return; } // Get scene index int index = mSceneTagList.indexOf(tag); if (index < 0) { Log.e(TAG, "finishScene: Can't find the tag in tag list: " + tag); return; } if (mSceneTagList.size() == 1) { // It is the last fragment, finish Activity now Log.i(TAG, "finishScene: It is the last scene, finish activity now"); finish(); return; } Fragment next = null; if (index == mSceneTagList.size() - 1) { // It is first fragment, show the next one next = fragmentManager.findFragmentByTag(mSceneTagList.get(index - 1)); } FragmentTransaction transaction = fragmentManager.beginTransaction(); if (next != null) { if (transitionHelper == null || !transitionHelper.onTransition( this, transaction, scene, next)) { // Clear shared item scene.setSharedElementEnterTransition(null); scene.setSharedElementReturnTransition(null); scene.setEnterTransition(null); scene.setExitTransition(null); next.setSharedElementEnterTransition(null); next.setSharedElementReturnTransition(null); next.setEnterTransition(null); next.setExitTransition(null); // Do not show animate if it is not the first fragment transaction.setCustomAnimations(R.anim.scene_close_enter, R.anim.scene_close_exit); } // Attach fragment transaction.attach(next); } transaction.remove(scene); transaction.commitAllowingStateLoss(); onTransactScene(); // Remove tag mSceneTagList.remove(index); // Return result if (scene instanceof SceneFragment) { ((SceneFragment) scene).returnResult(this); } }
Example 19
Source File: StageActivity.java From EhViewer with Apache License 2.0 | 4 votes |
private void finishScene(String tag, TransitionHelper transitionHelper) { FragmentManager fragmentManager = getSupportFragmentManager(); // Get scene Fragment scene = fragmentManager.findFragmentByTag(tag); if (scene == null) { Log.e(TAG, "finishScene: Can't find scene by tag: " + tag); return; } // Get scene index int index = mSceneTagList.indexOf(tag); if (index < 0) { Log.e(TAG, "finishScene: Can't find the tag in tag list: " + tag); return; } if (mSceneTagList.size() == 1) { // It is the last fragment, finish Activity now Log.i(TAG, "finishScene: It is the last scene, finish activity now"); finish(); return; } Fragment next = null; if (index == mSceneTagList.size() - 1) { // It is first fragment, show the next one next = fragmentManager.findFragmentByTag(mSceneTagList.get(index - 1)); } FragmentTransaction transaction = fragmentManager.beginTransaction(); if (next != null) { if (transitionHelper == null || !transitionHelper.onTransition( this, transaction, scene, next)) { // Clear shared item scene.setSharedElementEnterTransition(null); scene.setSharedElementReturnTransition(null); scene.setEnterTransition(null); scene.setExitTransition(null); next.setSharedElementEnterTransition(null); next.setSharedElementReturnTransition(null); next.setEnterTransition(null); next.setExitTransition(null); // Do not show animate if it is not the first fragment transaction.setCustomAnimations(R.anim.scene_close_enter, R.anim.scene_close_exit); } // Attach fragment transaction.attach(next); } transaction.remove(scene); transaction.commitAllowingStateLoss(); onTransactScene(); // Remove tag mSceneTagList.remove(index); // Return result if (scene instanceof SceneFragment) { ((SceneFragment) scene).returnResult(this); } }
Example 20
Source File: SimpleTransitionAnimation.java From Alligator with MIT License | 4 votes |
@Override public void applyBeforeFragmentTransactionExecuted(@NonNull FragmentTransaction transaction, @NonNull Fragment enteringFragment, @NonNull Fragment exitingFragment) { transaction.setCustomAnimations(mEnterAnimation, mExitAnimation); }