List of usage examples for android.app FragmentTransaction replace
public abstract FragmentTransaction replace(@IdRes int containerViewId, Fragment fragment);
From source file:de.sourcestream.movieDB.controller.TVList.java
/** * Callback method to be invoked when an item in this AdapterView has been clicked. * * @param parent The AdapterView where the click happened. * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) * @param position The position of the view in the adapter. * @param id The row id of the item that was clicked. *//*from ww w . ja v a 2 s. c o m*/ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { activity.resetMovieDetailsBundle(); activity.setRestoreMovieDetailsAdapterState(true); activity.setRestoreMovieDetailsState(false); activity.setOrientationChanged(false); activity.resetCastDetailsBundle(); activity.resetTvDetailsBundle(); if (tvDetails != null && lastVisitedTV == tvList.get(position).getId() && tvDetails.getTimeOut() == 0) { // Old movie details retrieve info and re-init component else crash tvDetails.onSaveInstanceState(new Bundle()); Bundle bundle = new Bundle(); bundle.putInt("id", tvList.get(position).getId()); Bundle save = tvDetails.getSave(); tvDetails = new TVDetails(); tvDetails.setTimeOut(0); tvDetails.setSave(save); tvDetails.setArguments(bundle); } else tvDetails = new TVDetails(); lastVisitedTV = tvList.get(position).getId(); tvDetails.setTitle(tvList.get(position).getTitle()); FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle bundle = new Bundle(); bundle.putInt("id", tvList.get(position).getId()); tvDetails.setArguments(bundle); transaction.replace(R.id.frame_container, tvDetails); // add the current transaction to the back stack: transaction.addToBackStack("TVList"); transaction.commit(); fragmentActive = true; activity.getTvSlideTab().showInstantToolbar(); }
From source file:org.eyeseetea.malariacare.DashboardActivity.java
public void replaceFragment(int layout, Fragment fragment) { FragmentTransaction ft = getFragmentTransaction(); ft.replace(layout, fragment); ft.commit();/* ww w . ja v a 2s.c o m*/ }
From source file:org.eyeseetea.malariacare.DashboardActivity.java
public void replaceListFragment(int layout, ListFragment fragment) { FragmentTransaction ft = getFragmentTransaction(); ft.replace(layout, fragment); ft.commit();//from ww w. j av a 2 s . c o m }
From source file:org.bohrmeista.chan.ui.activity.BoardActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ChanApplication.getBoardManager().addListener(this); boardLoadable = new Loadable(); threadLoadable = new Loadable(); boardFragment = ThreadFragment.newInstance(this); setBoardFragmentViewMode();//from w w w . j a v a2 s . co m threadFragment = ThreadFragment.newInstance(this); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.left_pane, boardFragment); ft.replace(R.id.right_pane, threadFragment); ft.commitAllowingStateLoss(); final ActionBar actionBar = getActionBar(); boardSpinner = new Spinner(actionBar.getThemedContext()); spinnerAdapter = new BoardSpinnerAdapter(this, boardSpinner); boardSpinner.setAdapter(spinnerAdapter); boardSpinner.setOnItemSelectedListener(this); actionBar.setCustomView(boardSpinner); actionBar.setDisplayShowCustomEnabled(true); updatePaneState(); Intent startIntent = getIntent(); Uri startUri = startIntent.getData(); if (savedInstanceState != null) { threadLoadable.readFromBundle(this, "thread", savedInstanceState); startLoadingThread(threadLoadable); // Reset page etc. Loadable tmp = new Loadable(); tmp.readFromBundle(this, "board", savedInstanceState); startLoadingBoard(new Loadable(tmp.board)); } else { if (startUri != null) { handleIntentURI(startUri); } if (boardLoadable.mode == Loadable.Mode.INVALID) { List<Board> savedValues = ChanApplication.getBoardManager().getSavedBoards(); if (savedValues.size() > 0) { startLoadingBoard(new Loadable(savedValues.get(0).value)); } } } if (startIntent.getExtras() != null) { handleExtraBundle(startIntent.getExtras()); } ignoreNextOnItemSelected = true; }
From source file:com.hijacker.MainActivity.java
static void isolate(String mac) { is_ap = getAPByMac(mac);/*ww w. j a v a2 s . c o m*/ if (is_ap != null) { IsolatedFragment.exit_on = mFragmentManager.getBackStackEntryCount(); FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.replace(R.id.fragment1, new IsolatedFragment()); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commitAllowingStateLoss(); } Tile.filter(); if (debug) { if (is_ap == null) Log.d("HIJACKER/Main", "No AP isolated"); else Log.d("HIJACKER/Main", "AP with MAC " + mac + " isolated"); } }
From source file:co.taqat.call.assistant.AssistantActivity.java
private void changeFragment(Fragment newFragment) { hideKeyboard();//from w w w . j a va2 s. c om FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_container, newFragment); transaction.commitAllowingStateLoss(); }
From source file:de.sourcestream.movieDB.controller.MovieList.java
/** * Callback method to be invoked when an item in this AdapterView has been clicked. * * @param parent The AdapterView where the click happened. * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) * @param position The position of the view in the adapter. * @param id The row id of the item that was clicked. *//*from w w w. j ava 2 s . co m*/ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { activity.setLastVisitedSimMovie(0); activity.resetMovieDetailsBundle(); activity.setRestoreMovieDetailsAdapterState(true); activity.setRestoreMovieDetailsState(false); activity.setOrientationChanged(false); activity.resetCastDetailsBundle(); if (movieDetails != null && lastVisitedMovie == moviesList.get(position).getId() && movieDetails.getTimeOut() == 0) { // Old movie details retrieve info and re-init component else crash movieDetails.onSaveInstanceState(new Bundle()); Bundle bundle = new Bundle(); bundle.putInt("id", moviesList.get(position).getId()); Bundle save = movieDetails.getSave(); movieDetails = new MovieDetails(); movieDetails.setTimeOut(0); movieDetails.setSave(save); movieDetails.setArguments(bundle); } else movieDetails = new MovieDetails(); lastVisitedMovie = moviesList.get(position).getId(); movieDetails.setTitle(moviesList.get(position).getTitle()); FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle bundle = new Bundle(); bundle.putInt("id", moviesList.get(position).getId()); movieDetails.setArguments(bundle); transaction.replace(R.id.frame_container, movieDetails); // add the current transaction to the back stack: transaction.addToBackStack("movieList"); transaction.commit(); fragmentActive = true; activity.getMovieSlideTab().showInstantToolbar(); /* ValueAnimator anim = ValueAnimator.ofFloat(0, 1); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float slideOffset = (Float) valueAnimator.getAnimatedValue(); activity.getmDrawerToggle().onDrawerSlide(activity.getmDrawerLayout(), slideOffset); } }); anim.setInterpolator(new DecelerateInterpolator()); // You can change this duration to more closely match that of the default animation. anim.setDuration(700); anim.start();*/ }
From source file:com.benlinskey.greekreference.MainActivity.java
/** * Replaces the currently displayed fragment(s) with the specified fragment(s). * @param listFragment the {@link BaseListFragment} to swap in * @param detailFragment the {@link DetailFragment} to swap in, or null if the app is in * one-pane mode/*from www. j a va 2s. com*/ */ private void swapInFragments(Fragment listFragment, Fragment detailFragment) { // TODO: Check for invalid null arguments. if (mTwoPane) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.item_list_container, listFragment); transaction.replace(R.id.item_detail_container, detailFragment); transaction.commit(); } else { FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.item_list_container, listFragment); transaction.commit(); } }
From source file:com.mastercard.masterpasswallet.fragments.MainCardFragment.java
private void setupViewpagerIndicator(int currentItem) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Bundle data = new Bundle(); data.putInt(ViewpagerIndicatorFragment.EXTRA_COUNT, mCards.size()); data.putInt(ViewpagerIndicatorFragment.EXTRA_CURRENT_ITEM, currentItem); mViewpagerIndicator = new ViewpagerIndicatorFragment(); mViewpagerIndicator.setArguments(data); ft.replace(R.id.lay_indicator_container, mViewpagerIndicator); ft.commit();//from w w w.j a v a2 s. c om }
From source file:com.benlinskey.greekreference.MainActivity.java
/** * Displays the specified Overview of Greek Syntax section in a {@link SyntaxDetailFragment}. * @param section the selected section's title * @param xml the selected section's XML *//*from w w w .ja v a 2 s . c o m*/ void displaySyntaxSection(String section, String xml) { if (mTwoPane) { Bundle arguments = new Bundle(); arguments.putString(SyntaxDetailFragment.ARG_XML, xml); SyntaxDetailFragment fragment = new SyntaxDetailFragment(); fragment.setArguments(arguments); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.item_detail_container, fragment); transaction.commitAllowingStateLoss(); } else { SyntaxListFragment fragment = (SyntaxListFragment) getFragmentManager() .findFragmentById(R.id.item_list_container); int syntaxId = fragment.getSelectedSyntaxId(); Intent intent = new Intent(this, SyntaxDetailActivity.class); intent.putExtra(SyntaxDetailFragment.ARG_XML, xml); intent.putExtra(SyntaxDetailActivity.ARG_SYNTAX_ID, syntaxId); intent.putExtra(SyntaxDetailActivity.ARG_SECTION, section); startActivity(intent); } }