List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:com.android.dialer.DialtactsFragment.java
/** * Finishes hiding the dialpad fragment after any animations are completed. *///from ww w . ja va2s. c o m private void commitDialpadFragmentHide() { if (!mStateSaved && mDialpadFragment != null && !mDialpadFragment.isHidden()) { final FragmentTransaction ft = getChildFragmentManager().beginTransaction(); ft.hide(mDialpadFragment); ft.commit(); } mFloatingActionButtonController.scaleIn(AnimUtils.NO_DELAY); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showTermsCheck() { popBackStackFull();/*from w w w.java 2 s . c o m*/ final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, RMBTTermsCheckFragment.getInstance(null), AppConstants.PAGE_TITLE_TERMS_CHECK); ft.commit(); }
From source file:com.luan.thermospy.android.activities.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments onSectionAttached(position);//from w ww.jav a 2 s. c o m FragmentManager fragmentManager = getFragmentManager(); final ServerSettings serverSettings = Coordinator.getInstance().getServerSettings(); final AlarmSettings alarmSettings = Coordinator.getInstance().getAlarmSettings(); final String temperature = Coordinator.getInstance().getTemperature(); final String ip = serverSettings.getIpAddress(); final int port = serverSettings.getPort(); final boolean isAlarmSwitchChecked = alarmSettings.isAlarmSwitchEnabled(); final AlarmCondition condition = alarmSettings.getAlarmCondition(); final String alarm = alarmSettings.getAlarm(); FragmentTransaction transaction; if (position == 0) { if (ip.isEmpty() == false && port != -1) { Fragment fragment; if (isAlarmSwitchChecked) { fragment = MonitorFragment.newInstance(ip, port, alarm, temperature); } else { fragment = MonitorFragment.newInstance(ip, port, getString(R.string.not_enabled), temperature); } transaction = fragmentManager.beginTransaction().replace(R.id.container, fragment); } else { // No ip or port available. Show server setup fragment transaction = fragmentManager.beginTransaction().replace(R.id.container, SetupService.newInstance(ip, port)); } } else if (position == 1) { FragmentTransaction ft = fragmentManager.beginTransaction(); transaction = ft.replace(R.id.container, Alarm.newInstance(alarm, isAlarmSwitchChecked, Coordinator.getInstance().getServerSettings(), condition)); } else if (position == 2) { transaction = fragmentManager.beginTransaction().replace(R.id.container, SetupService.newInstance(ip, port)); } else if (position == 3) { Intent intent = new Intent(this, LogSessionActivity.class); startActivity(intent); return; } else { transaction = fragmentManager.beginTransaction(); } mLastSelected = position; transaction.commit(); }
From source file:finalproject.ece558.edu.pdx.ece.brailleblackjack.PlayBlackJackGameFragment.java
/** * Set-up button listeners. Restore the state of the fragment if the state was saved. If no * state to restore then go set-up the game. Finally inflate the layout of the fragment * @param inflater LayoutInflater object * @param container ViewGroup object// w ww. j av a 2 s .c o m * @param savedInstanceState Bundle object of saved instances * @return View to inflate the layout on the screen */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { v = inflater.inflate(R.layout.fragment_play_black_jack_game, container, false); // Bind views group = (ViewGroup) v.findViewById(R.id.playFragment); // Set up the card slots dealer_left_slot = (ImageView) v.findViewById(R.id.img_view_dealer_left_card); dealer_right_slot = (ImageView) v.findViewById(R.id.img_view_dealer_right_card); player_left_slot = (ImageView) v.findViewById(R.id.img_view_player_left_card); player_right_slot = (ImageView) v.findViewById(R.id.img_view_player_right_card); // Set up the total slots dealer_top_total_slot = (ImageView) v.findViewById(R.id.img_view_dealer_top_total); dealer_bot_total_slot = (ImageView) v.findViewById(R.id.img_view_dealer_bot_total); player_top_total_slot = (ImageView) v.findViewById(R.id.img_view_player_top_total); player_bot_total_slot = (ImageView) v.findViewById(R.id.img_view_player_bot_total); /* Hit button Listener */ button_hit = (Button) v.findViewById(R.id.button_hit); button_hit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { playerHits(); } }); /* Stand button Listener */ button_stand = (Button) v.findViewById(R.id.button_stand); button_stand.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { playerStands(); } }); /* Start Over buttonListener */ button_start_over = (Button) v.findViewById(R.id.button_start_over); button_start_over.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentTransaction fm = getFragmentManager().beginTransaction(); fm.replace(R.id.fragment_container, new PlayBlackJackGameFragment()); fm.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); fm.commit(); } }); /* Hint button Listener */ button_hint = (Button) v.findViewById(R.id.button_hint); button_hint.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hintDialog(); } }); // If activity recreated (such as from screen rotate), restore // the previous article selection set by onSaveInstanceState(). // This is primarily necessary when in the two-pane layout. if (savedInstanceState != null) { /* Restore Variables and Flags */ dealer_had_ace = savedInstanceState.getBoolean("DEALER_HAD_ACE"); player_had_ace = savedInstanceState.getBoolean("PLAYER_HAD_ACE"); dealer_turn = savedInstanceState.getBoolean("DEALER_TURN"); player_turn = savedInstanceState.getBoolean("PLAYER_TURN"); first_draw_spoken = savedInstanceState.getBoolean("IS_FIRST_DRAW_SPOKEN"); dealer_top_total_value = savedInstanceState.getInt("DEALER_TOP_TOTAL_VALUE"); dealer_bot_total_value = savedInstanceState.getInt("DEALER_BOT_TOTAL_VALUE"); player_top_total_value = savedInstanceState.getInt("PLAYER_TOP_TOTAL_VALUE"); dealer_bot_total_value = savedInstanceState.getInt("PLAYER_BOT_TOTAL_VALUE"); button_hit_state = savedInstanceState.getBoolean("BUTTON_HIT_STATE"); button_stand_state = savedInstanceState.getBoolean("BUTTON_STAND_STATE"); button_hint_state = savedInstanceState.getBoolean("BUTTON_HINT_STATE"); /* Set button Visibility */ changeAllButtonStates(button_hit_state, button_stand_state, button_hint_state, true); /* Restore Cards */ curDeck = new Deck(context); String d_left, d_right, p_left, p_right; boolean dealer_left_exists = savedInstanceState.getBoolean("DEALER_LEFT_EXISTS"); d_right = savedInstanceState.getString("DEALER_RIGHT_CARD"); p_left = savedInstanceState.getString("PLAYER_LEFT_CARD"); p_right = savedInstanceState.getString("PLAYER_RIGHT_CARD"); dealer_right_card = curDeck.getCard(d_right); player_left_card = curDeck.getCard(p_left); player_right_card = curDeck.getCard(p_right); /* Restore Views and Totals and Description for TalkBack */ dealer_left_slot.setContentDescription("Dealer left card is hidden until you stand"); dealer_right_slot .setContentDescription("Dealer right card is " + dealer_right_card.getCardDescription()); player_left_slot.setContentDescription("Your left card is " + player_left_card.getCardDescription()); player_right_slot.setContentDescription("Your right card is " + player_right_card.getCardDescription()); dealer_right_slot.setImageResource(dealer_right_card.getCardDrawable()); player_left_slot.setImageResource(player_left_card.getCardDrawable()); player_right_slot.setImageResource(player_right_card.getCardDrawable()); if (dealer_left_exists) { d_left = savedInstanceState.getString("DEALER_LEFT_CARD"); dealer_left_card = curDeck.getCard(d_left); dealer_left_slot.setImageResource(dealer_left_card.getCardDrawable()); dealer_left_slot .setContentDescription("Dealer left card is " + dealer_left_card.getCardDescription()); } dealer_top_total_slot.setImageResource(giveTotalDrawable(dealer_top_total_value)); dealer_top_total_slot .setContentDescription("Dealer has a total of" + String.valueOf(dealer_top_total_value)); player_top_total_slot.setImageResource(giveTotalDrawable(player_top_total_value)); player_top_total_slot .setContentDescription("You have a total of " + String.valueOf(player_top_total_value)); if (player_bot_total_value > 0) { player_bot_total_slot.setImageResource(giveTotalDrawable(player_bot_total_value)); player_bot_total_slot.setVisibility(v.VISIBLE); player_bot_total_slot.setContentDescription("Because of an ace you have an alternative total of" + String.valueOf(player_bot_total_value)); } else { player_bot_total_slot.setVisibility(v.INVISIBLE); player_bot_total_slot.setContentDescription(""); } if (dealer_bot_total_value > 0) { dealer_bot_total_slot.setImageResource(giveTotalDrawable(dealer_bot_total_value)); dealer_bot_total_slot.setVisibility(v.VISIBLE); dealer_top_total_slot.setContentDescription("Because of an ace dealer has an alternative total of" + String.valueOf(dealer_bot_total_value)); } else { dealer_bot_total_slot.setVisibility(v.INVISIBLE); dealer_top_total_slot.setContentDescription(""); } } else { // Start Android Wear App if its connected sendMessage(START_WEAR); gameSetup(); } // Inflate the layout for this fragment return v; }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void initApp(boolean duringCreate) { //check log directory and send log files to control server if available checkLogs(getApplicationContext(), new OnCompleteListener() { @Override/*from ww w . j a v a 2 s. com*/ public void onComplete(int flag, Object object) { //after log check: redirect system output to file if option is set redirectSystemOutput(ConfigHelper.isSystemOutputRedirectedToFile(RMBTMainActivity.this)); } }); popBackStackFull(); FragmentTransaction ft; ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, new RMBTMainMenuFragment(), AppConstants.PAGE_TITLE_MAIN); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); checkNews(getApplicationContext()); checkSettings(false, null); //checkIp(); waitForSettings(true, false, false); fetchMapOptions(); historyResultLimit = Config.HISTORY_RESULTLIMIT_DEFAULT; if (!duringCreate && geoLocation != null) geoLocation.start(); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showNdtCheck() { final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, RMBTCheckFragment.newInstance(CheckType.NDT), AppConstants.PAGE_TITLE_NDT_CHECK); ft.addToBackStack(AppConstants.PAGE_TITLE_NDT_CHECK); ft.commit(); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showAbout() { popBackStackFull();/*from w w w.ja v a 2 s . c o m*/ FragmentTransaction ft; ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, new RMBTAboutFragment(), AppConstants.PAGE_TITLE_ABOUT); ft.addToBackStack(AppConstants.PAGE_TITLE_ABOUT); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_ABOUT); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showResultsAfterTest(String testUuid) { popBackStackFull();//from w ww. j av a2 s . c om final RMBTResultPagerFragment fragment = new RMBTResultPagerFragment(); final Bundle args = new Bundle(); args.putString(RMBTResultPagerFragment.ARG_TEST_UUID, testUuid); fragment.setArguments(args); final FragmentManager fm = getFragmentManager(); final FragmentTransaction ft; ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_HISTORY_PAGER); ft.addToBackStack(AppConstants.PAGE_TITLE_HISTORY_PAGER); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_HISTORY_PAGER); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
/** * /*from www.j a v a2 s.c o m*/ * @param itemList * @param pos */ public void showHistoryPager(final int pos) { if (historyStorageList != null) { // final RMBTHistoryPagerFragment fragment = new RMBTHistoryPagerFragment(); final Bundle args = new Bundle(); final RMBTResultPagerFragment fragment = new RMBTResultPagerFragment(); String testUuid = historyStorageList.get(pos).get("test_uuid"); //testUuid = "842356d7-a863-48f9-8220-678125fb3a76"; //testUuid = "0d765559-ab16-4fa1-b776-4040e18bf134"; //testUuid = "dbf47f08-711f-4cfa-9fd9-78f06a7a7df3"; args.putString(RMBTResultPagerFragment.ARG_TEST_UUID, testUuid); fragment.setArguments(args); final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_HISTORY_PAGER); ft.addToBackStack(AppConstants.PAGE_TITLE_HISTORY_PAGER); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_HISTORY_PAGER); } }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
/** * information commissioner check/*from w ww . j ava 2 s .co m*/ */ public void showIcCheck() { final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, RMBTCheckFragment.newInstance(CheckType.INFORMATION_COMMISSIONER), AppConstants.PAGE_TITLE_CHECK_INFORMATION_COMMISSIONER); ft.addToBackStack(AppConstants.PAGE_TITLE_CHECK_INFORMATION_COMMISSIONER); ft.commit(); }