List of usage examples for android.support.v4.app FragmentTransaction commit
public abstract int commit();
From source file:com.citrus.sample.UIActivity.java
@Override public void onUpdateProfileSelected() { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction() .setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right) .replace(R.id.container, UpdateProfileFragment.newInstance()); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); }
From source file:com.amaze.carbonfilemanager.activities.DbViewer.java
@Override public void onCreate(Bundle savedInstanceState) { this.checkStorage = false; super.onCreate(savedInstanceState); if (getAppTheme().equals(AppTheme.DARK)) { setTheme(R.style.appCompatDark); getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background)); }//from w w w . j a v a 2 s.co m setContentView(R.layout.activity_db_viewer); toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(), getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab))); setTaskDescription(taskDescription); } getSupportActionBar().setBackgroundDrawable( getColorPreference().getDrawable(ColorUsage.getPrimary(MainActivity.currentTab))); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (SDK_INT == 20 || SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor( getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab))); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (SDK_INT >= 21) { boolean colourednavigation = sharedPref.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(PreferenceUtils.getStatusColor( getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab)))); if (colourednavigation) window.setNavigationBarColor(PreferenceUtils.getStatusColor( getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab)))); } path = getIntent().getStringExtra("path"); pathFile = new File(path); listView = (ListView) findViewById(R.id.listView); load(pathFile); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); DbViewerFragment fragment = new DbViewerFragment(); Bundle bundle = new Bundle(); bundle.putString("table", arrayList.get(position)); fragment.setArguments(bundle); fragmentTransaction.add(R.id.content_frame, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } }); }
From source file:at.jclehner.rxdroid.BackupActivity.java
private void setContentFragment(String storageState, boolean calledFromOnCreate) { final Fragment content; if (!Intent.ACTION_VIEW.equals(getIntent().getAction())) { //getSupportActionBar().setDisplayShowHomeEnabled(true); //getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Backup.StorageStateListener.isReadable(storageState)) { content = new BackupFragment(); if (!Backup.DIRECTORY.exists()) Backup.DIRECTORY.mkdirs(); else if (!Backup.DIRECTORY.isDirectory()) { // Hackish, but simple - a full blown AlertDialog would be // overkill... final File newFile = new File(Backup.DIRECTORY + "___"); Backup.DIRECTORY.renameTo(newFile); Backup.DIRECTORY.mkdirs(); Toast.makeText(this, Backup.DIRECTORY + " -> " + newFile, Toast.LENGTH_LONG).show(); }//from www . ja v a2 s .c om } else { final DialogLike dialog = new DialogLike(); dialog.setTitle(getString(R.string._title_error)); dialog.setMessage(getString(R.string._msg_external_storage_not_readable)); dialog.setPositiveButtonText(getString(android.R.string.ok)); content = dialog; } } else content = new ImportDialog(); //setContentView(R.layout.simple_activity); final Fragment currentFragment = getSupportFragmentManager().findFragmentByTag("content"); final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if (currentFragment != null) { //ft.detach(currentFragment); ft.remove(currentFragment); } ft.replace(android.R.id.content, content, "content"); if (!calledFromOnCreate) ft.addToBackStack(null); ft.commit(); supportInvalidateOptionsMenu(); }
From source file:com.bushstar.htmlcoin_android_wallet.ui.AddressBookActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.address_book_content); final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); final FragmentManager fragmentManager = getSupportFragmentManager(); 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.j av a 2s . c om*/ 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 = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0; 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:com.ayuget.redface.ui.activity.TopicsActivity.java
protected void loadAnonymousTopic(Topic topic, int page, PagePosition pagePosition) { TopicFragment anonymousTopicFragment = new TopicFragmentBuilder(page, topic) .currentPagePosition(pagePosition).build(); int topicFragmentContainer = isTwoPaneMode() ? R.id.details_container : R.id.container; FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(topicFragmentContainer, anonymousTopicFragment); transaction.addToBackStack(null);//from w w w.jav a2s . com transaction.commit(); }
From source file:com.app.blockydemo.ui.fragment.FormulaEditorScriptListFragment.java
@Override public boolean onKey(DialogInterface d, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: getActivity().findViewById(R.id.bottom_bar).setVisibility(View.GONE); ((ScriptActivity) getActivity()).updateHandleAddButtonClickListener(); FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction(); fragmentTransaction.hide(this); FormulaEditorFragment formulaEditorFragment = (FormulaEditorFragment) getActivity() .getSupportFragmentManager() .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG); formulaEditorFragment.updateBrickView(); fragmentTransaction.show(formulaEditorFragment); fragmentTransaction.commit(); return true; default:/* w ww. ja va2 s . c om*/ break; } return false; }
From source file:cc.mintcoin.wallet.ui.AddressBookActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.address_book_content); final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); FragmentManager fragmentManager = getSupportFragmentManager(); walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT); sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT); FragmentTransaction remove = fragmentManager.beginTransaction(); if (walletAddressesFragment == null) { walletAddressesFragment = new WalletAddressesFragment(); } else {/*from w w w .j av a2 s . c o m*/ remove.remove(walletAddressesFragment); } if (sendingAddressesFragment == null) { sendingAddressesFragment = new SendingAddressesFragment(); } else { remove.remove(sendingAddressesFragment); } if (!remove.isEmpty()) { remove.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 = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0; 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:com.amaze.filemanager.activities.DbViewer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Sp = PreferenceManager.getDefaultSharedPreferences(this); theme = Integer.parseInt(Sp.getString("theme", "0")); theme1 = theme == 2 ? PreferenceUtils.hourOfDay() : theme; if (theme1 == 1) { setTheme(R.style.appCompatDark); getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.holo_dark_background)); }/*from w ww. j a v a 2 s .c o m*/ setContentView(R.layout.activity_db_viewer); toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); skin = PreferenceUtils.getPrimaryColorString(Sp); if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(), Color.parseColor(skin)); ((Activity) this).setTaskDescription(taskDescription); } skinStatusBar = PreferenceUtils.getStatusColor(skin); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); getSupportActionBar().setDisplayHomeAsUpEnabled(true); rootMode = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("rootmode", false); int sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { boolean colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor((PreferenceUtils.getStatusColor(skin))); if (colourednavigation) window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin))); } path = getIntent().getStringExtra("path"); pathFile = new File(path); listView = (ListView) findViewById(R.id.listView); load(pathFile); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); DbViewerFragment fragment = new DbViewerFragment(); Bundle bundle = new Bundle(); bundle.putString("table", arrayList.get(position)); fragment.setArguments(bundle); fragmentTransaction.add(R.id.content_frame, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } }); }
From source file:com.asksven.commandcenter.BasicMasterFragment.java
/** * Helper function to show the details of a selected item, either by * displaying a fragment in-place in the current UI, or starting a * whole new activity in which it is displayed. */// ww w .jav a2 s .c o m void showDetails(int key) { mCurCheckPosition = key; if (mDualPane) { // We can display everything in-place with fragments, so update // the list to highlight the selected item and show the data. getListView().setItemChecked(key, true); // Check what fragment is currently shown, replace if needed. BasicDetailsFragment details = (BasicDetailsFragment) getFragmentManager() .findFragmentById(R.id.details); if ((m_myCommand == null) || (details == null) || (details.getShownKey() != m_myCommand.getId())) { // Make new fragment to show this selection. details = BasicDetailsFragment.newInstance(key, m_strCollectionName); // Execute a transaction, replacing any existing fragment // with this one inside the frame. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.details, details); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } } else { // Otherwise we need to launch a new activity to display // the dialog fragment with selected text. Intent intent = new Intent(); intent.setClass(getActivity(), BasicDetailsActivity.class); intent.putExtra("index", key); intent.putExtra("collection", m_strCollectionName); startActivity(intent); } }
From source file:com.app.blockydemo.ui.ScriptActivity.java
public void switchToFragmentFromScriptFragment(int fragmentPosition) { ScriptActivityFragment scriptFragment = getFragment(ScriptActivity.FRAGMENT_SCRIPTS); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (scriptFragment.isVisible()) { fragmentTransaction.hide(scriptFragment); }/* ww w . j av a2 s. c o m*/ switch (fragmentPosition) { case FRAGMENT_LOOKS: break; case FRAGMENT_SOUNDS: break; } updateHandleAddButtonClickListener(); fragmentTransaction.commit(); }