List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:org.restcomm.android.olympus.CallActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set window styles for fullscreen-window size. Needs to be done before // adding content. requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); setContentView(R.layout.activity_call); // Initialize UI btnHangup = (ImageButton) findViewById(R.id.button_hangup); btnHangup.setOnClickListener(this); btnAnswer = (ImageButton) findViewById(R.id.button_answer); btnAnswer.setOnClickListener(this); btnAnswerAudio = (ImageButton) findViewById(R.id.button_answer_audio); btnAnswerAudio.setOnClickListener(this); btnMuteAudio = (ImageButton) findViewById(R.id.button_mute_audio); btnMuteAudio.setOnClickListener(this); btnMuteVideo = (ImageButton) findViewById(R.id.button_mute_video); btnMuteVideo.setOnClickListener(this); btnKeypad = (ImageButton) findViewById(R.id.button_keypad); btnKeypad.setOnClickListener(this); lblCall = (TextView) findViewById(R.id.label_call); lblStatus = (TextView) findViewById(R.id.label_status); lblTimer = (TextView) findViewById(R.id.label_timer); alertDialog = new AlertDialog.Builder(CallActivity.this, R.style.SimpleAlertStyle).create(); PreferenceManager.setDefaultValues(this, "preferences.xml", MODE_PRIVATE, R.xml.preferences, false); prefs = PreferenceManager.getDefaultSharedPreferences(this); // Get Intent parameters. final Intent intent = getIntent(); if (intent.getAction().equals(RCDevice.ACTION_OUTGOING_CALL)) { btnAnswer.setVisibility(View.INVISIBLE); btnAnswerAudio.setVisibility(View.INVISIBLE); } else {/*w w w.j a v a 2 s. c om*/ btnAnswer.setVisibility(View.VISIBLE); btnAnswerAudio.setVisibility(View.VISIBLE); } keypadFragment = new KeypadFragment(); lblTimer.setVisibility(View.INVISIBLE); // these might need to be moved to Resume() btnMuteAudio.setVisibility(View.INVISIBLE); btnMuteVideo.setVisibility(View.INVISIBLE); btnKeypad.setVisibility(View.INVISIBLE); activityVisible = true; // open keypad FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.keypad_fragment_container, keypadFragment); ft.hide(keypadFragment); ft.commit(); }
From source file:com.hit.jj.mapshow.RoutingActivity.java
/** * Updates the UI after a successful rest response has been received. *//*from w w w . j a v a 2 s . c o m*/ void updateUI() { dialog.dismiss(); img_cancel.setVisibility(View.VISIBLE); FragmentManager fm = getFragmentManager(); if (fm.findFragmentByTag("Nav Drawer") == null) { FragmentTransaction ft = fm.beginTransaction(); RoutingListFragment frag = new RoutingListFragment(this); ft.add(frag, "Nav Drawer"); ft.commit(); } else { FragmentTransaction ft = fm.beginTransaction(); ft.remove(fm.findFragmentByTag("Nav Drawer")); RoutingListFragment frag = new RoutingListFragment(this); ft.add(frag, "Nav Drawer"); ft.commit(); } //img_showDirections.setVisibility(View.VISIBLE); }
From source file:com.dvn.vindecoder.ui.seller.GetAllVehicalSellerDetails.java
void addFragmentToStack() { mStackLevel++;//from w ww . j a va2 s . c o m // Instantiate a new fragment. Fragment newFragment = GetNewVehicalFragment.newInstance(GetAllVehicalSellerDetails.this); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.animator.fragment_slide_left_enter, R.animator.fragment_slide_left_exit, R.animator.fragment_slide_right_enter, R.animator.fragment_slide_right_exit); ft.replace(R.id.fragment1, newFragment); // ft.addToBackStack(null); ft.commit(); }
From source file:com.murati.oszk.audiobook.ui.MusicPlayerActivity.java
private void navigateToBrowser(String mediaId) { //TODO: maybe place navigate block here LogHelper.d(TAG, "navigateToBrowser, mediaId=" + mediaId); MediaBrowserFragment fragment = getBrowseFragment(); updateBookButtons(mediaId);// w w w .j av a 2s. c o m if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) { // Create Transaction FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.animator.slide_in_from_right, R.animator.slide_out_to_left, R.animator.slide_in_from_left, R.animator.slide_out_to_right); // Create Backstack // Not an empty, root or the same where we are currently, for refresh retries if (fragment != null && mediaId != null && mediaId != getMediaId()) { transaction.addToBackStack(null); } //Create new fragment and navigate fragment = new MediaBrowserFragment(); fragment.setMediaId(mediaId); transaction.replace(R.id.container, fragment, FRAGMENT_TAG); //Do it transaction.commit(); } }
From source file:com.zte.permissioncontrol.ui.PermissionControlPageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.permission_control_pages); mEmptyView = (FrameLayout) findViewById(R.id.empty_view); mSavedInstanceState = savedInstanceState; // add the switch on Action bar LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mSwitch = (Switch) inflater.inflate(R.layout.imageswitch_layout, null); final int padding = getResources().getDimensionPixelSize(R.dimen.action_bar_switch_padding); mSwitch.setPadding(0, 0, padding, 0); getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM); getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.END)); mSwitch.setOnCheckedChangeListener(this); // hide fragment firstly , then update it in onResume() according to switch status final FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); mPermissionsFragment = (PermissionsFragment) fragmentManager.findFragmentByTag(mPermissionsTag); mAppsFragment = (AppsFragment) fragmentManager.findFragmentByTag(mAppsTag); if (mPermissionsFragment == null) { mPermissionsFragment = new PermissionsFragment(); mAppsFragment = new AppsFragment(); transaction.add(R.id.tab_pager, mPermissionsFragment, mPermissionsTag); transaction.add(R.id.tab_pager, mAppsFragment, mAppsTag); }/* w w w. jav a2 s . com*/ transaction.hide(mPermissionsFragment); transaction.hide(mAppsFragment); transaction.commit(); fragmentManager.executePendingTransactions(); // set page adapter mTabPager = (ViewPager) findViewById(R.id.tab_pager); mTabPagerAdapter = new TabPagerAdapter(); mTabPager.setAdapter(mTabPagerAdapter); mTabPager.setOnPageChangeListener(mTabPagerListener); // Configure action bar mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar()); boolean isShow = PermControlUtils.isPermControlOn(this); Log.d(TAG, "oncreate(), isShow " + isShow); }
From source file:by.zatta.pilight.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { /*/* ww w .j a va 2s . c o m*/ * The action bar home/up should open or close the drawer. ActionBarDrawerToggle will take care of this. */ publishList(); if (mDrawerToggle.onOptionsItemSelected(item)) { return true; } FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); switch (item.getItemId()) { case R.id.menu_about: openDialogFragment(AboutDialog.newInstance()); return true; case R.id.menu_settings: Fragment pref = fm.findFragmentByTag("prefs"); if (pref == null) { ft.replace(R.id.fragment_main, new PrefFragment(), "prefs"); fm.popBackStack(); ft.addToBackStack(null); ft.commit(); } else { ft.remove(fm.findFragmentByTag("prefs")); ft.commit(); fm.popBackStack(); } return true; default: break; } // Handle your other action bar items... return super.onOptionsItemSelected(item); }
From source file:com.dsna.android.main.MainActivity.java
private void openFragment(BaseFragment baseFragment) { if (baseFragment != null) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.fragment_main, baseFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); if (baseFragment.getTitleResourceId() > 0) mCurrentTitle = baseFragment.getTitleResourceId(); }//from ww w.j a va 2s.com }
From source file:com.google.cloud.solutions.cloudadventure.GameActivity.java
/** * Shows the {@link PreGameFragment} game lobby screen and creates a new {@link Player}. This * method is called almost immediately, within the Activity's onCreate(). *///w w w . j ava2 s . c o m private void joinGame() { // Show the pre-game lobby screen FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); mPreGameFragment = new PreGameFragment(); fragmentTransaction.add(R.id.game_activity, mPreGameFragment); fragmentTransaction.commit(); new JoinGame().execute(mGameId, mHandle); }
From source file:com.sintef_energy.ubisolar.activities.DrawerActivity.java
/** * Helper method to add fragments to the view. * * @param fragment Fragment to swap in/*from w w w .ja v a 2s .co m*/ * @param animate True if swap shall have an animation * @param addToBackStack True if the Fragment shall go to the back stack * @param tag String for the back stack */ public void addFragment(Fragment fragment, boolean animate, boolean addToBackStack, String tag) { FragmentManager manager = getFragmentManager(); FragmentTransaction ft = manager.beginTransaction(); if (animate) { ft.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right, // Pop enter android.R.anim.fade_in, android.R.anim.fade_out); } if (addToBackStack) { ft.addToBackStack(tag); } ft.replace(R.id.container, fragment, tag); ft.commit(); }
From source file:de.sourcestream.movieDB.controller.CastDetailsInfo.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { activity.getCastDetailsFragment().showInstantToolbar(); activity.setCastDetailsFragment(null); activity.setRestoreMovieDetailsAdapterState(true); activity.setRestoreMovieDetailsState(false); if (knownList.get(position).getMediaType().equals("movie")) { if (activity.getMovieDetailsFragment() != null && activity.getLastVisitedMovieInCredits() == knownList.get(position).getId() && activity.getMovieDetailsFragment().getTimeOut() == 0) { // Old movie details retrieve info and re-init component else crash activity.getMovieDetailsFragment().onSaveInstanceState(new Bundle()); Bundle bundle = new Bundle(); bundle.putInt("id", knownList.get(position).getId()); Bundle save = activity.getMovieDetailsFragment().getSave(); // Re-init movie details and set save information movieDetails = new MovieDetails(); movieDetails.setTimeOut(0);//from w w w. j av a2 s.com movieDetails.setSave(save); movieDetails.setArguments(bundle); } else movieDetails = new MovieDetails(); } if (knownList.get(position).getMediaType().equals("tv")) { if (activity.getTvDetailsFragment() != null && activity.getLastVisitedMovieInCredits() == knownList.get(position).getId() && activity.getTvDetailsFragment().getTimeOut() == 0) { // Old movie details retrieve info and re-init component else crash activity.getTvDetailsFragment().onSaveInstanceState(new Bundle()); Bundle bundle = new Bundle(); bundle.putInt("id", knownList.get(position).getId()); Bundle save = activity.getTvDetailsFragment().getSave(); // Re-init movie details and set save information tvDetails = new TVDetails(); tvDetails.setTimeOut(0); tvDetails.setSave(save); tvDetails.setArguments(bundle); } else tvDetails = new TVDetails(); } activity.setLastVisitedMovieInCredits(knownList.get(position).getId()); ((CastDetails) getParentFragment()).setAddToBackStack(true); getParentFragment().onSaveInstanceState(new Bundle()); if (activity.getSearchViewCount()) activity.incSearchCastDetails(); FragmentManager manager = getActivity().getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle bundle = new Bundle(); bundle.putInt("id", knownList.get(position).getId()); if (knownList.get(position).getMediaType().equals("movie")) { movieDetails.setTitle(knownList.get(position).getTitle()); movieDetails.setArguments(bundle); transaction.replace(R.id.frame_container, movieDetails); } if (knownList.get(position).getMediaType().equals("tv")) { tvDetails.setTitle(knownList.get(position).getTitle()); tvDetails.setArguments(bundle); transaction.replace(R.id.frame_container, tvDetails); } // add the current transaction to the back stack: transaction.addToBackStack("castDetails"); transaction.commit(); }