List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:io.demiseq.jetreader.activities.MainActivity.java
public void GetDownloaded() { DownloadedFragment fragment = new DownloadedFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "DOWNLOADED"); fragmentTransaction.commit(); removeSpinner();/*from ww w .ja v a2 s. c o m*/ setTitle(downloaded); }
From source file:tw.example.robert.myapplication.bluetoothchat.BluetoothChatFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);//from w ww . j a v a 2 s .c o m FragmentManager ft = getFragmentManager(); FragmentTransaction transaction = ft.beginTransaction(); MapsActivity fragment = new MapsActivity(); transaction.replace(R.id.googleMaps, fragment); transaction.commit(); startTime = System.currentTimeMillis(); handler.removeCallbacks(updateTimer); //Delay handler.postDelayed(updateTimer, 1000); handler.removeCallbacks(ahead); //Delay handler.postDelayed(ahead, 1000); // Get local Bluetooth adapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { FragmentActivity activity = (FragmentActivity) getActivity(); Toast.makeText(activity, "Bluetooth is not available", Toast.LENGTH_LONG).show(); activity.finish(); } // No bluetooth service registerBrocast(); sensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE); }
From source file:io.demiseq.jetreader.activities.MainActivity.java
private void GetFavoriteMangas() { MainFragment fragment = new MainFragment(); Bundle args = new Bundle(); args.putInt("manga_type", 2); fragment.setArguments(args);// w w w .java2s. com FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "FAVOURITE"); fragmentTransaction.commit(); removeSpinner(); setTitle(favorite); }
From source file:com.ffmpeger.card.MainNativeActivity.java
private void openFragment(BaseFragment baseFragment) { if (baseFragment != null) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(com.ffmpeger.card.R.id.fragment_main, baseFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); if (baseFragment.getTitleResourceId() > 0) mCurrentTitle = baseFragment.getTitleResourceId(); }/* w w w . j a va2 s . co m*/ }
From source file:io.demiseq.jetreader.activities.MainActivity.java
private void GetCategories(Category c) { if (spinnerContainer == null) setUpSpinner();/*from w w w . j a v a 2 s .com*/ CategoryFragment fragment = new CategoryFragment(); Bundle bundle = new Bundle(); bundle.putString("url", c.getUrl()); bundle.putInt("max_page", c.getPage()); bundle.putInt("position", categories.indexOf(c)); fragment.setArguments(bundle); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "CATEGORY"); fragmentTransaction.commit(); }
From source file:systems.soapbox.ombuds.client.ui.AddressBookActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.address_book_content); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); super.setAnimateOnPause(true); final FragmentManager fragmentManager = getFragmentManager(); walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT); sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT); final FragmentTransaction removal = fragmentManager.beginTransaction(); if (walletAddressesFragment == null) walletAddressesFragment = new WalletAddressesFragment(); else/*w ww . ja v a2 s .c o m*/ removal.remove(walletAddressesFragment); if (sendingAddressesFragment == null) sendingAddressesFragment = new SendingAddressesFragment(); else removal.remove(sendingAddressesFragment); if (!removal.isEmpty()) { removal.commit(); fragmentManager.executePendingTransactions(); } final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager); if (pager != null) { pager.setAdapter( new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment)); final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs); pagerTabs.addTabLabels(R.string.address_book_list_receiving_title, R.string.address_book_list_sending_title); pager.setOnPageChangeListener(pagerTabs); final int position = 1; pager.setCurrentItem(position); pager.setPageMargin(2); pager.setPageMarginDrawable(R.color.bg_less_bright); pagerTabs.onPageSelected(position); pagerTabs.onPageScrolled(position, 0, 0); } else { fragmentManager.beginTransaction() .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT) .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit(); } updateFragments(); }
From source file:biz.wiz.android.wallet.ui.AddressBookActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.address_book_content); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); final FragmentManager fragmentManager = getFragmentManager(); walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT); sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT); final FragmentTransaction removal = fragmentManager.beginTransaction(); if (walletAddressesFragment == null) walletAddressesFragment = new WalletAddressesFragment(); else/* w ww .ja va2s . co m*/ removal.remove(walletAddressesFragment); if (sendingAddressesFragment == null) sendingAddressesFragment = new SendingAddressesFragment(); else removal.remove(sendingAddressesFragment); if (!removal.isEmpty()) { removal.commit(); fragmentManager.executePendingTransactions(); } final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager); if (pager != null) { pager.setAdapter( new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment)); final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs); pagerTabs.addTabLabels(R.string.address_book_list_receiving_title, R.string.address_book_list_sending_title); pager.setOnPageChangeListener(pagerTabs); final int position = 1; pager.setCurrentItem(position); pager.setPageMargin(2); pager.setPageMarginDrawable(R.color.bg_less_bright); pagerTabs.onPageSelected(position); pagerTabs.onPageScrolled(position, 0, 0); } else { fragmentManager.beginTransaction() .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT) .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit(); } updateFragments(); }
From source file:produvia.com.lights.SmartLightsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mErrorOccurred = false;/* w w w . ja v a 2 s. c o m*/ mErrorMessage = ""; setContentView(R.layout.activity_smart_lights); listFragment = new SmartLightsFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_fragment, listFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); //Start running the discovery service in the background //any discovered services will be reported on the onTaskUpdate callback: if (RUN_DISCOVERY) { WeaverSdkApi.discoveryService(this, true); } //fetch the services that have already been discovered in previous scans //these services will be returned in the onTaskCompleted callback: WeaverSdkApi.servicesGet(this, null); }
From source file:it.gmariotti.cardslib.demo.extras.MainActivity.java
private void openFragment(BaseFragment baseFragment) { if (baseFragment != null) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); //fragmentTransaction.setCustomAnimations(R.animator.carddemo_fag_fade_in,R.animator.carddemo_frag_fade_out); fragmentTransaction.replace(R.id.fragment_main_extras, baseFragment); //fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); if (baseFragment.getTitleResourceId() > 0) mCurrentTitle = baseFragment.getTitleResourceId(); }//from w w w.j a v a2 s.c o m }
From source file:com.learnit.LearnIt.activities.MainActivity.java
public void onArticleSelected(int position) { // Create a new listOfFragments MySmartFragment fragment;/*w w w . j a v a 2 s .c o m*/ switch (position) { case ADD_WORDS_FRAGMENT: fragment = new AddWordFragment(); fragment.identifier = ADD_WORDS_FRAGMENT; Log.d(LOG_TAG, "Created AddWordFragment with tag " + fragment.identifier); break; case DICTIONARY_FRAGMENT: fragment = new DictFragment(); fragment.identifier = DICTIONARY_FRAGMENT; Log.d(LOG_TAG, "Created Dictionary Fragment with tag " + fragment.identifier); break; case LEARN_WORDS_FRAGMENT: fragment = new LearnCasualFragment(); fragment.identifier = LEARN_WORDS_FRAGMENT; Log.d(LOG_TAG, "Created LearnFragment with tag " + fragment.identifier); break; default: fragment = null; } // Update the layout FragmentManager fm = getFragmentManager(); if (fm.findFragmentByTag("android:switcher:" + 0 + ":" + position) == null) { FragmentTransaction ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); ft.replace(R.id.view_group_id, fragment, "android:switcher:" + 0 + ":" + position); Log.d(LOG_TAG, "current fragment id = " + fragment.getId() + " and tag = " + fragment.getTag() + ((Object) fragment).getClass().getName()); ft.commit(); } _currentItemShown = position; Log.d(LOG_TAG, "onArticleSelected current item set to " + _currentItemShown); }