Java Code Examples for android.app.FragmentTransaction#setTransition()
The following examples show how to use
android.app.FragmentTransaction#setTransition() .
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: PreferenceActivity.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void switchToHeaderInner(String fragmentName, Bundle args) { getFragmentManager().popBackStack(BACK_STACK_PREFS, FragmentManager.POP_BACK_STACK_INCLUSIVE); if (!isValidFragment(fragmentName)) { throw new IllegalArgumentException("Invalid fragment for this activity: " + fragmentName); } Fragment f = Fragment.instantiate(this, fragmentName, args); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setTransition(mSinglePane ? FragmentTransaction.TRANSIT_NONE : FragmentTransaction.TRANSIT_FRAGMENT_FADE); transaction.replace(com.android.internal.R.id.prefs, f); transaction.commitAllowingStateLoss(); if (mSinglePane && mPrefsContainer.getVisibility() == View.GONE) { // We are transitioning from headers to preferences panel in single-pane so we need // to hide headers and show the prefs container. mPrefsContainer.setVisibility(View.VISIBLE); mHeadersContainer.setVisibility(View.GONE); } }
Example 2
Source File: CallActivity.java From Yahala-Messenger with MIT License | 6 votes |
private void toggleCallControlFragmentVisibility() { 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(); }
Example 3
Source File: MainActivity.java From HeadFirstAndroid with MIT License | 6 votes |
@Override public void itemClicked(long id) { View fragmentContainer = findViewById(R.id.fragment_container); if (fragmentContainer != null) { WorkoutDetailFragment details = new WorkoutDetailFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); details.setWorkout(id); ft.replace(R.id.fragment_container, details); ft.addToBackStack(null); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } else { Intent intent = new Intent(this, DetailActivity.class); intent.putExtra(DetailActivity.EXTRA_WORKOUT_ID, (int)id); startActivity(intent); } }
Example 4
Source File: PBServerListPreference.java From client-android with GNU General Public License v2.0 | 6 votes |
private void clickedAtPosition(int position) { // store the preference as the position final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(PBApplication.getApp()); preferences.edit().putString(PBConstants.PREF_SERVER, servers[position].toString()).apply(); // build new preference fragment from server position in list Bundle fragmentArguments = new Bundle(1); fragmentArguments.putString(PBServerPreferenceFragment.PREF_SERVER_NAME, servers[position].toString()); PBServerPreferenceFragment fragment = new PBServerPreferenceFragment(); fragment.setArguments(fragmentArguments); // put it on back stack final Activity activity = (Activity) context; FragmentTransaction transaction = activity.getFragmentManager().beginTransaction(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.replace(android.R.id.content, fragment); transaction.addToBackStack(null); transaction.commit(); }
Example 5
Source File: MainActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { FragmentManager manager = getFragmentManager(); switch (item.getItemId()) { case R.id.actionadd1: FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.fragmentcontainer1, new MyListFragment()); transaction .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.commit(); break; case R.id.actionadd2: transaction = manager.beginTransaction(); transaction.add(R.id.fragmentcontainer2, new DetailFragment()); transaction.commit(); break; default: break; } // transaction = getFragmentManager().beginTransaction(); // transaction.add(R.id.fragmentcontainer2, new DetailFragment()); // transaction.commit(); return true; }
Example 6
Source File: AccessTokenListActivity.java From DeviceConnect-Android with MIT License | 6 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.access_token); if (getActionBar() != null) { getActionBar().setDisplayHomeAsUpEnabled(true); } if (savedInstanceState == null) { AccessTokenListFragment f = new AccessTokenListFragment(); FragmentManager fm = getFragmentManager(); FragmentTransaction t = fm.beginTransaction(); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); t.add(android.R.id.content, f, "continar"); t.commit(); } }
Example 7
Source File: Utilities.java From rss with GNU General Public License v3.0 | 5 votes |
private static void switchToFragment(Fragment fragment, boolean addToBackStack) { if(fragment.isHidden()) { Fragment[] fragments = { s_fragmentFavourites, s_fragmentManage, s_fragmentFeeds, s_fragmentSettings }; FragmentTransaction transaction = s_fragmentManager.beginTransaction(); for(Fragment frag : fragments) { if(frag.isVisible()) { transaction.hide(frag); } } transaction.show(fragment); if(addToBackStack) { transaction.addToBackStack(null); // Set the default transition for adding to the stack. transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); } transaction.commit(); s_fragmentManager.executePendingTransactions(); fragment.getActivity().invalidateOptionsMenu(); } }
Example 8
Source File: FragmentStack.java From android-test with Apache License 2.0 | 5 votes |
void addFragmentToStack() { stackLevel++; // Instantiate a new fragment. Fragment newFragment = CountingFragment.newInstance(stackLevel); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.simple_fragment, newFragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commit(); }
Example 9
Source File: OverviewFragment.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
private void replaceDetailFragment(DetailFragment detail, String noteUID, String notebookUID, ActiveAccount account) { FragmentTransaction ft = getFragmentManager(). beginTransaction(); ft.replace(R.id.details_fragment, detail); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { ft.commitNow(); detail.updateFragmentDataWithNewNoteSelection(noteUID, notebookUID, account); }else{ ft.commit(); getFragmentManager().executePendingTransactions(); detail.updateFragmentDataWithNewNoteSelection(noteUID, notebookUID, account); } }
Example 10
Source File: OverviewFragment.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
public void displayBlankFragment(){ Log.d("displayBlankFragment", "tabletMode:" + tabletMode); if(tabletMode){ BlankFragment blank = BlankFragment.newInstance(); FragmentTransaction ft = getFragmentManager(). beginTransaction(); ft.replace(R.id.details_fragment, blank); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); ((OnFragmentCallback)activity).fragementAttached(this); } }
Example 11
Source File: IRKitVirtualDeviceListActivity.java From DeviceConnect-Android with MIT License | 5 votes |
/** * Fragment の遷移. * @param f Fragment */ private void moveFragment(final Fragment f) { FragmentManager fm = getFragmentManager(); FragmentTransaction t = fm.beginTransaction(); t.setTransition(FragmentTransaction.TRANSIT_NONE); t.replace(android.R.id.content, f); t.addToBackStack(null); t.commit(); }
Example 12
Source File: MainActivity.java From HeadFirstAndroid with MIT License | 5 votes |
private void selectItem(int position) { // update the main content by replacing fragments currentPosition = position; Fragment fragment; switch(position) { case 1: fragment = new PizzaFragment(); break; case 2: fragment = new PastaFragment(); break; case 3: fragment = new StoresFragment(); break; default: fragment = new TopFragment(); } FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.content_frame, fragment, "visible_fragment"); ft.addToBackStack(null); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); //Set the action bar title setActionBarTitle(position); //Close drawer drawerLayout.closeDrawer(drawerList); }
Example 13
Source File: AccessTokenListActivity.java From DeviceConnect-Android with MIT License | 5 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.access_token); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState == null) { AccessTokenListFragment f = new AccessTokenListFragment(); FragmentManager fm = getFragmentManager(); FragmentTransaction t = fm.beginTransaction(); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); t.add(android.R.id.content, f, "continar"); t.commit(); } }
Example 14
Source File: SettingActivity.java From Toutiao with Apache License 2.0 | 5 votes |
private void setupFragment(String fragmentName, Bundle args) { Fragment fragment = Fragment.instantiate(this, fragmentName, args); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); transaction.replace(R.id.container, fragment); transaction.commitAllowingStateLoss(); }
Example 15
Source File: PreferenceActivity.java From ticdesign with Apache License 2.0 | 5 votes |
/** * Start a new fragment. * * @param fragment The fragment to start * @param push If true, the current fragment will be pushed onto the back stack. If false, * the current fragment will be replaced. */ public void startPreferenceFragment(Fragment fragment, boolean push) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.prefs, fragment); if (push) { transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.addToBackStack(BACK_STACK_PREFS); } else { transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); } transaction.commitAllowingStateLoss(); }
Example 16
Source File: MainActivity.java From v2ex-daily-android with Apache License 2.0 | 5 votes |
@Override public void onNavigationDrawerItemSelected(final int position) { // update the main content by replacing fragments FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); switch (position){ case 0: if(mNewestNodeFragment == null){ mNewestNodeFragment = new NewestNodeFragment(); } fragmentTransaction.replace(R.id.container, mNewestNodeFragment); break; case 1: if(mAllNodeFragment == null){ mAllNodeFragment = new AllNodeFragment(); } fragmentTransaction.replace(R.id.container, mAllNodeFragment); break; case 2: fragmentTransaction.replace(R.id.container, new CollectionFragment()); break; case 3: if(mNotificationFragment == null){ mNotificationFragment = new NotificationFragment(); } fragmentTransaction.replace(R.id.container, mNotificationFragment); break; case 4: if(mSettingFragment == null){ mSettingFragment = new SettingFragment(); } fragmentTransaction.replace(R.id.container, mSettingFragment); break; } fragmentTransaction.commit(); }
Example 17
Source File: PreferenceFragment.java From material-preferences with MIT License | 5 votes |
public boolean onPreferenceScreenClick(@NonNull PreferenceScreen preference) { final Dialog dialog = preference.getDialog(); if (dialog != null) { //It might be null if PreferenceScreen contains an intent //Close the default view without mp_toolbar and create our own Fragment version dialog.dismiss(); NestedPreferenceFragment fragment = new NestedPreferenceFragment(); //Save the preference screen so it can bet set when the transaction is done fragment.savePreferenceScreen(preference); FragmentTransaction transaction = getFragmentManager().beginTransaction(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { transaction.replace(R.id.content, fragment); } else { transaction.replace(android.R.id.content, fragment); } //TODO make animation optional (or give methods to animate it) transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.addToBackStack(preference.getKey()); transaction.commitAllowingStateLoss(); return true; }else if(preference.getIntent() != null) { startActivity(preference.getIntent()); return true; } return false; }
Example 18
Source File: BasicActivity.java From uPods-android with Apache License 2.0 | 5 votes |
@Override public void showFragment(int id, Fragment fragment, String tag, IFragmentsManager.FragmentOpenType openType, IFragmentsManager.FragmentAnimationType animationType) { android.app.FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); if (animationType == IFragmentsManager.FragmentAnimationType.BOTTOM_TOP) { ft.setCustomAnimations(R.animator.animation_fragment_bototm_top, R.animator.animation_fragment_top_bototm, R.animator.animation_fragment_bototm_top, R.animator.animation_fragment_top_bototm); } if (openType == IFragmentsManager.FragmentOpenType.OVERLAY) { ft.add(id, fragment, tag); if (this instanceof IOverlayable) { ((IOverlayable) this).toggleOverlay(); } } else { ft.replace(id, fragment, tag); } ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); if (fragment instanceof IControlStackHistory) {//Decide ether fragment should be added to stack history if (((IControlStackHistory) fragment).shouldBeAddedToStack()) { ft.addToBackStack(tag); } } else { ft.addToBackStack(tag); } ft.commitAllowingStateLoss(); }
Example 19
Source File: FragmentLayout.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
/** * Helper function to show the details of a selected item, either by * displaying a fragment in-place in the current UI, or starting a * whole new activity in which it is displayed. */ void showDetails(int index) { mCurCheckPosition = index; if (mDualPane) { // We can display everything in-place with fragments, so update // the list to highlight the selected item and show the data. getListView().setItemChecked(index, true); // Check what fragment is currently shown, replace if needed. DetailsFragment details = (DetailsFragment) getFragmentManager().findFragmentById(R.id.details); if (details == null || details.getShownIndex() != index) { // Make new fragment to show this selection. details = DetailsFragment.newInstance(index); // Execute a transaction, replacing any existing fragment // with this one inside the frame. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.details, details); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } } else { // Otherwise we need to launch a new activity to display // the dialog fragment with selected text. Intent intent = new Intent(); intent.setClass(getActivity(), DetailsActivity.class); intent.putExtra("index", index); startActivity(intent); } }
Example 20
Source File: MainActivity.java From android-kernel-tweaker with GNU General Public License v3.0 | 4 votes |
@Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub Fragment f = null; Fragment glo = null; switch(arg2) { case 1: f = new TimeInState(); glo = new CpuGlossaryFragment(); break; case 2: f = new CPUInfo(); glo = new CpuGlossaryFragment(); break; case 4: f = new CpuPreferenceFragment(); glo = new CpuGlossaryFragment(); break; case 5: f = new GpuPreferenceFragment(); glo = new GpuGlossaryFragment(); break; case 6: f = new UvPreferenceFragment(); glo = new UvGlossaryFragment(); break; case 8: f = new KernelPreferenceFragment(); glo = new KernelGlossaryFragment(); break; case 9: f = new LowMemoryKillerFragment(); glo = new LmkGlossaryFragment(); break; case 10: f = new VM(); glo = new VmGlossaryFragment(); break; case 12: f = new ReviewBootPreferenceFragment(); glo = new CpuGlossaryFragment(); break; case 14: f = new FileManagerFragment(); glo = new CpuGlossaryFragment(); break; case 15: f = new BackupFragment(); glo = new CpuGlossaryFragment(); break; case 16: f = new CustomRecoveryCommandFragment(); glo = new CpuGlossaryFragment(); break; case 18: f = new PropModder(); glo = new CpuGlossaryFragment(); break; case 19: f = new InitD(); glo = new CpuGlossaryFragment(); break; case 20: f = new WallpaperEffectsFragment(); glo = new CpuGlossaryFragment(); break; case 22: f = new SettingsFragment(); glo = new CpuGlossaryFragment(); break; case 23: f = new infos(); glo = new CpuGlossaryFragment(); //showCredits(); break; } FragmentTransaction ft = getFragmentManager().beginTransaction(); // This adds the newly created Preference fragment to my main layout, shown below ft.replace(R.id.activity_container,f); ft.replace(R.id.menu_frame, glo); // By hiding the main fragment, transparency isn't an issue ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack("TAG"); ft.commit(); //menu.toggle(true); }