List of usage examples for android.support.v4.app FragmentTransaction commit
public abstract int commit();
From source file:at.alladin.rmbt.android.terms.RMBTTermsActivity.java
public void showLoopModeCheck() { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment_content, RMBTCheckFragment.newInstance(CheckType.LOOP_MODE), AppConstants.PAGE_TITLE_LOOP_MODE_CHECK); ft.addToBackStack(AppConstants.PAGE_TITLE_LOOP_MODE_CHECK); ft.commit(); setTitle(AppConstants.PAGE_TITLE_LOOP_MODE_CHECK); }
From source file:br.com.mybaby.contatos.ContactDetailActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/* w w w .jav a2 s . c o m*/ protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // Enable strict mode checks when in debug modes Util.enableStrictMode(); } super.onCreate(savedInstanceState); // This activity expects to receive an intent that contains the uri of a contact if (getIntent() != null) { // For OS versions honeycomb and higher use action bar if (Util.hasHoneycomb()) { // Enables action bar "up" navigation getActionBar().setDisplayHomeAsUpEnabled(false); } // Fetch the data Uri from the intent provided to this activity final Uri uri = getIntent().getData(); // Checks to see if fragment has already been added, otherwise adds a new // ContactDetailFragment with the Uri provided in the intent if (getSupportFragmentManager().findFragmentByTag(TAG) == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Adds a newly created ContactDetailFragment that is instantiated with the // data Uri ft.add(android.R.id.content, ContactDetailFragment.newInstance(uri), TAG); ft.commit(); } } else { // No intent provided, nothing to do so finish() finish(); } }
From source file:com.ces.cloudnote.app.contactslist.ContactDetailActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override// w w w.ja va2 s . c o m protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // Enable strict mode checks when in debug modes Utils.enableStrictMode(); } super.onCreate(savedInstanceState); // This activity expects to receive an intent that contains the uri of a contact if (getIntent() != null) { // For OS versions honeycomb and higher use action bar if (Utils.hasHoneycomb()) { // Enables action bar "up" navigation getSupportActionBar().setDisplayHomeAsUpEnabled(true); } // Fetch the data Uri from the intent provided to this activity final Uri uri = getIntent().getData(); // Checks to see if fragment has already been added, otherwise adds a new // ContactDetailFragment with the Uri provided in the intent if (getSupportFragmentManager().findFragmentByTag(TAG) == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Adds a newly created ContactDetailFragment that is instantiated with the // data Uri ft.add(android.R.id.content, ContactDetailFragment.newInstance(uri), TAG); ft.commit(); } } else { // No intent provided, nothing to do so finish() finish(); } }
From source file:co.dilaver.quoter.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* www.j a va 2s.c om*/ if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_QOD)); } drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawerLayout.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); fragment = new QODFragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.mainFrame, fragment); ft.commit(); }
From source file:brian.chisholm.test.helloworldmap.MainActivity.java
public void getLocationDetails(OfficeLocation officeLocation) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(officeLocation.getName()); LocationDetailsFragment ldf = new LocationDetailsFragment(); Bundle args = new Bundle(); args.putSerializable("location", officeLocation); ldf.setArguments(args);/*from w w w . ja v a 2 s .c om*/ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.anim.slide_in, R.anim.slide_out, R.anim.pop_slide_in, R.anim.pop_slide_out); ; transaction.replace(R.id.container, ldf); transaction.addToBackStack(null); transaction.commit(); }
From source file:com.actionbarsherlock.whmine.book.MainActivity.java
/** Called when the activity is first created. */ @Override//from ww w . ja v a2 s. c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ActionBar ab = getSupportActionBar(); // set defaults for logs & home up ab.setDisplayHomeAsUpEnabled(showHomeUp); ab.setDisplayUseLogoEnabled(useLogo); String[] sections = getResources().getStringArray(R.array.sections); for (int i = 0; i < sections.length; i++) { ab.addTab(ab.newTab().setText(sections[i]).setTabListener(this)); } // set up list nav ab.setListNavigationCallbacks( ArrayAdapter.createFromResource(this, R.array.sections, R.layout.sherlock_spinner_dropdown_item), new OnNavigationListener() { public boolean onNavigationItemSelected(int itemPosition, long itemId) { // FIXME add proper implementation rotateLeftFrag(); return false; } }); showTabsNav(); // create a couple of simple fragments as placeholders final int MARGIN = 16; leftFrag = new RoundedColourFragment(getResources().getColor(R.color.android_green), 1f, MARGIN, MARGIN / 2, MARGIN, MARGIN); muneFrag = new RoundedColourFragment(getResources().getColor(R.color.honeycombish_blue), 2f, MARGIN / 2, MARGIN, MARGIN, MARGIN); rightFrag = new RoundedColourFragment(getResources().getColor(R.color.honeycombish_blue), 4f, MARGIN / 2, MARGIN, MARGIN, MARGIN); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.root, leftFrag); ft.add(R.id.root, muneFrag); ft.add(R.id.root, rightFrag); ft.commit(); }
From source file:com.acomminos.morlunk.MorlunkHomeActivity.java
@Override public void onBlogPostSelected(MorlunkBlogPost post) { Bundle arguments = new Bundle(); arguments.putParcelable("post", post); MorlunkBlogPostFragment postFragment = new MorlunkBlogPostFragment(); postFragment.setArguments(arguments); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.container, postFragment); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); transaction.addToBackStack(null);/*from w w w.j a v a2 s. c om*/ transaction.commit(); }
From source file:com.aniruddhc.acemusic.player.NowPlayingQueueActivity.NowPlayingQueueActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mContext = this; sharedPreferences = getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); //Get the screen's parameters. DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels; //Set the UI theme. if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_THEME") || sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME") .equals("DARK_CARDS_THEME")) { setTheme(R.style.AppTheme);/*from w ww.j a v a 2 s .c om*/ } else { setTheme(R.style.AppThemeLight); } super.onCreate(savedInstanceState); if (getOrientation().equals("PORTRAIT")) { //Finish this activity and relaunch the activity that called this one. Intent intent = new Intent(this, (Class<?>) getIntent().getSerializableExtra("CALLING_CLASS")); intent.putExtras(getIntent()); intent.putExtra("NEW_PLAYLIST", false); intent.putExtra("CALLED_FROM_FOOTER", true); intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); finish(); startActivity(intent); return; } else { setContentView(R.layout.activity_now_playing_queue); final Fragment nowPlayingQueueFragment = new NowPlayingQueueFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.now_playing_queue_container, nowPlayingQueueFragment, "nowPlayingQueueFragment"); transaction.commit(); SpannableString s = new SpannableString(getResources().getString(R.string.current_queue)); s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // Update the action bar title with the TypefaceSpan instance. ActionBar actionBar = getActionBar(); actionBar.setTitle(s); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.holo_gray_selector)); } }
From source file:co.dilaver.quoter.activities.MainActivity.java
@Override public void onBackPressed() { if (drawerLayout.isDrawerOpen(GravityCompat.START)) { drawerLayout.closeDrawer(GravityCompat.START); } else {//from ww w. j av a2s .c o m if (fragment instanceof QODFragment) { super.onBackPressed(); return; } if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.str_QOD)); } qodFavorite.setVisible(true); qodShare.setVisible(true); qodCopy.setVisible(true); wyoDone.setVisible(false); wyoShare.setVisible(false); pqInfo.setVisible(false); fragment = new QODFragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.mainFrame, fragment); ft.commit(); } }
From source file:at.jclehner.rxdroid.DoseHistoryActivity.java
void updateLogFragment() { int flags = 0; if (Settings.getBoolean(Keys.LOG_SHOW_MISSED, true)) flags |= DoseLogFragment.SHOW_MISSED; if (Settings.getBoolean(Keys.LOG_SHOW_SKIPPED, true)) flags |= DoseLogFragment.SHOW_SKIPPED; if (Settings.getBoolean(Keys.LOG_SHOW_TAKEN, true)) flags |= DoseLogFragment.SHOW_TAKEN; final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction ft = fm.beginTransaction(); final DoseLogFragment f = DoseLogFragment.newInstance(mDrug, flags); ft.replace(android.R.id.content, f, "log"); ft.commit(); if (!Settings.getBoolean(Keys.LOG_IS_ALL_COLLAPSED, true)) f.expandAll(false);/* www . j av a2s . com*/ else f.collapseAll(); if (Version.SDK_IS_HONEYCOMB_OR_NEWER) { RxDroid.runInMainThread(new Runnable() { @Override public void run() { supportInvalidateOptionsMenu(); } }); } }