List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:cmput301.f13t01.readstory.ReadFragmentActivity.java
/** * Using a fragment manager, this function creates and commits a new * ReadFragmentView fragment to be displayed for this view. This replaces * whatever the old fragment is, thus giving the readers a new view on the * new content.//w w w.j av a2s . c o m * * @param storyId * the UUID of the story * @param fragmentId * the story fragment to be displayed */ public void commitFragment(Integer fragmentId) { if (fragmentId == null) { return; } this.fragmentId = fragmentId; // prepare for the fragment FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); // prepare bundle to pass arguments Bundle bundle = new Bundle(); bundle.putInt(getResources().getString(R.string.destination_id), fragmentId); // create the fragment and pass the bundle to the fragment ReadFragmentView newFragment = new ReadFragmentView(); newFragment.setArguments(bundle); fragmentTransaction.replace(R.id.read_fragment_activity, newFragment); fragmentTransaction.commit(); }
From source file:itcr.gitsnes.MainActivity.java
/** Inflates mainFrame/ListView with the next params from advanced_search layout: * - name: if name isn't null//from w ww. java 2s . c o m * - category: if category is different to empty */ public void searching(View view) { EditText name = (EditText) this.findViewById(R.id.src_name); EditText category = (EditText) this.findViewById(R.id.src_category); MasterGames new_fragment = new MasterGames(json_arr); new_fragment.setQname(name.getText().toString()); new_fragment.setQcat(category.getText().toString()); RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback); rl.setBackgroundColor(Color.parseColor("#009f28")); authButton.setVisibility(View.INVISIBLE); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.placeholder, new_fragment); transaction.addToBackStack(null); transaction.commit(); }
From source file:itcr.gitsnes.MainActivity.java
public void goList(MenuItem item) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);// w ww . j av a 2 s. co m String input = new BackendHandler().readJSON(); try { json_arr = new JSONArray(input); } catch (JSONException e) { Log.i(TAG, e.toString()); } RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback); rl.setBackgroundColor(Color.parseColor("#009f28")); authButton.setVisibility(View.INVISIBLE); MasterGames new_fragment = new MasterGames(json_arr); new_fragment.setQtype("all"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.placeholder, new_fragment); transaction.addToBackStack(null); transaction.commit(); }
From source file:itcr.gitsnes.MainActivity.java
/** * Method to go mainFrame//from ww w. j a v a2 s . c o m */ public void back_stage() { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); String input = new BackendHandler().readJSON(); try { json_arr = new JSONArray(input); } catch (JSONException e) { Log.i(TAG, e.toString()); Log.i(TAG, e.toString()); } RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback); rl.setBackgroundColor(Color.parseColor("#009f28")); authButton.setVisibility(View.INVISIBLE); MasterGames new_fragment = new MasterGames(json_arr); new_fragment.setQtype("all"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.placeholder, new_fragment); transaction.addToBackStack(null); transaction.commit(); }
From source file:itcr.gitsnes.MainActivity.java
public void adminMenu(MenuItem item) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);/* w w w.j av a 2 s.com*/ String input = new BackendHandler().readJSON(); try { json_arr = new JSONArray(input); } catch (JSONException e) { Log.i(TAG, e.toString()); } RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback); rl.setBackgroundColor(Color.parseColor("#d0ff00")); authButton.setVisibility(View.INVISIBLE); AdminFrame new_fragment = new AdminFrame(json_arr); new_fragment.setQtype("all"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.placeholder, new_fragment); transaction.addToBackStack(null); transaction.commit(); }
From source file:itcr.gitsnes.MainActivity.java
/** Create a frame with the favorites games of the user * call moreliked GET method *//* ww w . j av a 2s .c om*/ public void getFavorites(MenuItem item) { /* Async mode*/ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); /* Build json*/ String input = new BackendHandler().getFavorites(); try { json_arr = new JSONArray(input); } catch (JSONException e) { Log.i(TAG, e.toString()); } /* Commit fragment transaction (master view)*/ RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback); rl.setBackgroundColor(Color.parseColor("#70d4b0")); authButton.setVisibility(View.INVISIBLE); MasterGames new_fragment = new MasterGames(json_arr); new_fragment.setQtype("all"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.placeholder, new_fragment); transaction.addToBackStack(null); transaction.commit(); }
From source file:de.sourcestream.movieDB.controller.MovieDetailsInfo.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 .j a v a 2 s . c o m*/ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { activity.setRestoreMovieDetailsAdapterState(true); activity.setRestoreMovieDetailsState(false); if (activity.getMovieDetailsSimFragment() != null && activity.getLastVisitedSimMovie() == similarList.get(position).getId() && activity.getMovieDetailsSimFragment().getTimeOut() == 0) { // Old movie details retrieve info and re-init component else crash activity.getMovieDetailsSimFragment().onSaveInstanceState(new Bundle()); Bundle bundle = new Bundle(); bundle.putInt("id", similarList.get(position).getId()); Bundle save = activity.getMovieDetailsSimFragment().getSave(); // Re-init movie details and set save information movieDetails = new MovieDetails(); movieDetails.setTimeOut(0); movieDetails.setSave(save); movieDetails.setArguments(bundle); } else movieDetails = new MovieDetails(); activity.setLastVisitedSimMovie(similarList.get(position).getId()); activity.getMovieDetailsFragment().setAddToBackStack(true); activity.getMovieDetailsFragment().onSaveInstanceState(new Bundle()); if (activity.getSearchViewCount()) activity.incSearchMovieDetails(); activity.setMovieDetailsFragment(null); activity.setSaveInMovieDetailsSimFragment(true); movieDetails.setTitle(similarList.get(position).getTitle()); FragmentManager manager = getActivity().getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle bundle = new Bundle(); bundle.putInt("id", similarList.get(position).getId()); movieDetails.setArguments(bundle); transaction.replace(R.id.frame_container, movieDetails); // add the current transaction to the back stack: transaction.addToBackStack("similarDetails"); transaction.commit(); }
From source file:itcr.gitsnes.MainActivity.java
/** Create a frame with the favorites games of the user * call recomended GET method *///from w ww . ja v a2 s .c om public void getRecomended(MenuItem item) { /* Async mode*/ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); /* Build json*/ String input = new BackendHandler().get_Recommended(new KeyStore().getCurrent_user()); try { json_arr = new JSONArray(input); } catch (JSONException e) { Log.i(TAG, e.toString()); } /* Commit fragment transaction (master view)*/ RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback); rl.setBackgroundColor(Color.parseColor("#e7df00")); authButton.setVisibility(View.INVISIBLE); MasterGames new_fragment = new MasterGames(json_arr); new_fragment.setQtype("all"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.placeholder, new_fragment); transaction.addToBackStack(null); transaction.commit(); }
From source file:com.greatspeeches.slides.ScreenSlidePageFragment.java
public void playYutubeVideo() { fragmentsLayout.setVisibility(View.VISIBLE); videoRel.setVisibility(View.VISIBLE); if (mPersonObj.getVideourl().length() > 0) { int indexPos = mPersonObj.getVideourl().indexOf("="); if (indexPos > 0) { videoId = mPersonObj.getVideourl().substring(indexPos + 1, mPersonObj.getVideourl().length()); }/*from w w w . j a va2 s . c om*/ android.app.FragmentTransaction fts = getChildFragmentManager().beginTransaction(); YouTubePlayerFragment youTubePlayerFragment = new YouTubePlayerFragment(); // YouTubePlayerSupportFragment youTubePlayerFragment = YouTubePlayerSupportFragment.newInstance(); // FragmentTransaction fts = myContext.getSupportFragmentManager().beginTransaction(); fts.add(R.id.video_container, youTubePlayerFragment); fts.addToBackStack(null); fts.commit(); myContext.getSupportFragmentManager().executePendingTransactions(); youTubePlayerFragment.initialize(GreateSpeechesUtil.yOUTUBEdEVELOPERkEY, new OnInitializedListener() { @Override public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) { // Play, cue or whatever you want to do with the player activePlayer = player; activePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT); activePlayer.setPlayerStateChangeListener(videoListener); activePlayer.setFullscreen(false); activePlayer.setShowFullscreenButton(false); if (!wasRestored) { activePlayer.loadVideo(videoId, 0); } } @Override public void onInitializationFailure(Provider arg0, YouTubeInitializationResult arg1) { // TODO Auto-generated method stub } }); } }
From source file:com.jlabs.peepaid.searchviewlay.SearchViewLayout.java
private void showContentFragment() { if (mFragmentManager != null) { final android.app.FragmentTransaction transaction = mFragmentManager.beginTransaction(); transaction.setCustomAnimations(R.animator.fade_in_object_animator, R.animator.fade_out_object_animator); transaction.replace(R.id.search_expanded_content, mExpandedContentFragment); transaction.commit(); } else if (mSupportFragmentManager != null) { final android.support.v4.app.FragmentTransaction transaction = mSupportFragmentManager .beginTransaction();/* w w w . j a v a 2s . co m*/ transaction.setCustomAnimations(R.anim.fade_in_anim_set, R.anim.fade_out_anim_set); transaction.replace(R.id.search_expanded_content, mExpandedContentSupportFragment); transaction.commit(); } }