List of usage examples for android.support.v4.app FragmentTransaction commit
public abstract int commit();
From source file:com.app.blockydemo.ui.fragment.FormulaEditorVariableListFragment.java
public void showFragment(Context context) { FragmentActivity activity = (FragmentActivity) context; FragmentManager fragmentManager = activity.getSupportFragmentManager(); FragmentTransaction fragTransaction = fragmentManager.beginTransaction(); Fragment formulaEditorFragment = fragmentManager .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG); fragTransaction.hide(formulaEditorFragment); BottomBar.showBottomBar(activity);/*from ww w . j a v a 2 s. c o m*/ BottomBar.hidePlayButton(activity); fragTransaction.show(this); fragTransaction.commit(); if (adapter != null) { initializeUserVariableAdapter(); } }
From source file:can.yrt.onebusaway.ArrivalsListActivity.java
@Override protected void onResume() { super.onResume(); boolean newFrag = mNewFragment; mNewFragment = false;//ww w .ja v a 2 s.c om if (newFrag) { FragmentManager fm = getSupportFragmentManager(); ArrivalsListFragment list = new ArrivalsListFragment(); list.setArguments(FragmentUtils.getIntentArgs(getIntent())); FragmentTransaction ft = fm.beginTransaction(); ft.replace(android.R.id.content, list); // This is a bit of a hack, but if there's a backstack // it means people navigated away from this activity while // in a report problem fragment. // In this case, we *want* to be a part of the backstack; // otherwise we just want to clear everything out. if (fm.getBackStackEntryCount() > 0) { ft.addToBackStack(null); } ft.commit(); } }
From source file:com.billooms.harppedals.HarpPedalsActivity.java
/** * Launch a new ChordFragment.// w w w . j a va2s .c om */ private void launchChordFragment() { // Create fragment ChordFragment chordFragment = new ChordFragment(); // set arguments for any previously saved Chord if (savedChordArray != null) { Bundle args = new Bundle(); args.putIntArray(ARG_CHORD, savedChordArray); args.putBooleanArray(ARG_CHORDADD, savedChordAddArray); chordFragment.setArguments(args); } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment transaction.replace(R.id.fragment_container, chordFragment, NO_SWIPE); // and add the transaction to the back stack so the user can navigate back transaction.addToBackStack(null); // Commit the transaction transaction.commit(); }
From source file:biz.easymenu.easymenung.EasymenuNGActivity.java
public void leftMenuClicked(View v) { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft; Fragment f = null;//from w w w. ja va2 s . c om switch (v.getId()) { case R.id.btnMenu: f = new FoodMenuFragment(false); if (fm.findFragmentByTag("rightfragment") != null) { ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.remove(fm.findFragmentByTag("rightfragment")); ft.commit(); } ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(R.id.rightcontent, f, "rightfragment"); ft.commit(); break; case R.id.btnDrinks: f = new FoodMenuFragment(true); if (fm.findFragmentByTag("rightfragment") != null) { ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.remove(fm.findFragmentByTag("rightfragment")); ft.commit(); } ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(R.id.rightcontent, f, "rightfragment"); ft.commit(); break; case R.id.btnOrder: f = new ReviewPlaceFragment(); if (fm.findFragmentByTag("rightfragment") != null) { ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.remove(fm.findFragmentByTag("rightfragment")); ft.commit(); } ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(R.id.rightcontent, f, "rightfragment"); ft.commit(); break; case R.id.btnBill: f = new PayBillFragment(); if (fm.findFragmentByTag("rightfragment") != null) { ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.remove(fm.findFragmentByTag("rightfragment")); ft.commit(); } ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(R.id.rightcontent, f, "rightfragment"); ft.commit(); break; case R.id.btnWaiter: if (rpc.callWaiter(emp.getSid())) { ft = fm.beginTransaction(); ErrorFragment ferr = new ErrorFragment(getResources().getString(R.string.waiterNotified)); Fragment prev = fm.findFragmentByTag("errorDialog"); if (prev != null) { ft.remove(prev); ft.commit(); } ferr.show(ft, "errorDialog"); } break; case R.id.btnConfig: f = new SettingsFragment(); if (fm.findFragmentByTag("rightfragment") != null) { ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.remove(fm.findFragmentByTag("rightfragment")); ft.commit(); } ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(R.id.rightcontent, f, "rightfragment"); ft.commit(); break; default: break; } }
From source file:com.ayuget.redface.ui.activity.TopicsActivity.java
@Override public void onMyTopicsClicked() { currentCategory = categoriesStore.getMetaCategory(); Log.d(LOG_TAG, String.format("Loading meta category, with topicFilter='%s'", getSettings().getDefaultTopicFilter().toString())); TopicListFragment topicListFragment = new MetaPageFragmentBuilder(currentCategory) .topicFilter(getSettings().getDefaultTopicFilter()).build(); topicListFragment.addOnTopicClickedListener(this); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.container, topicListFragment, TOPICS_FRAGMENT_TAG); transaction.commit(); }
From source file:com.ayuget.redface.ui.activity.TopicsActivity.java
@Override public void onCategoryClicked(Category category) { currentCategory = category;/*w w w .jav a2 s . c o m*/ Log.d(LOG_TAG, String.format("Loading category '%s', with topicFilter='%s'", category.getName(), getSettings().getDefaultTopicFilter().toString())); TopicListFragment topicListFragment = new TopicListFragmentBuilder(category) .topicFilter(getSettings().getDefaultTopicFilter()).build(); topicListFragment.addOnTopicClickedListener(this); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.container, topicListFragment, TOPICS_FRAGMENT_TAG); transaction.commit(); }
From source file:com.amaze.filemanager.activities.DatabaseViewerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); if (getAppTheme().equals(AppTheme.DARK)) { setTheme(R.style.appCompatDark); getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background)); } else if (getAppTheme().equals(AppTheme.BLACK)) { setTheme(R.style.appCompatBlack); getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, android.R.color.black)); }// w w w . j a va 2s. c o m setContentView(R.layout.activity_db_viewer); toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); @ColorInt int primaryColor = ColorPreferenceHelper.getPrimary(getCurrentColorPreference(), MainActivity.currentTab); if (SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(), primaryColor); setTaskDescription(taskDescription); } getSupportActionBar().setBackgroundDrawable(new ColorDrawable(primaryColor)); boolean useNewStack = sharedPref.getBoolean(PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK, false); getSupportActionBar().setDisplayHomeAsUpEnabled(!useNewStack); if (SDK_INT == 20 || SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor( ColorPreferenceHelper.getPrimary(getCurrentColorPreference(), 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) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(PreferenceUtils.getStatusColor(primaryColor)); if (getBoolean(PREFERENCE_COLORED_NAVIGATION)) window.setNavigationBarColor(PreferenceUtils.getStatusColor(primaryColor)); } path = getIntent().getStringExtra("path"); pathFile = new File(path); listView = findViewById(R.id.listView); load(pathFile); listView.setOnItemClickListener((parent, view, position, 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:cf.obsessiveorange.rhcareerfairlayout.ui.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; // Pull using: adb pull /sdcard/RHCareerFairLayoutTrace.trace "D:\1. Work\Workspaces\Java Workspace\RHCareerFairLayout\android\RHCareerFairLayout" // Debug.startMethodTracing("RHCareerFairLayoutTrace"); setContentView(R.layout.activity_main); DBManager.setupDBAdapterIfNeeded(this); // Setup search, without suggestions, and defaulting to last searched string. search = (SearchBox) findViewById(R.id.searchbox); search.enableVoiceRecognition(this); search.setSearchWithoutSuggestions(true); search.setSearchString(getSearchString()); // Setup toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* w w w . java 2 s . c om*/ // Setup title Term term = DBManager.getTerm(); if (term == null) { reloadData(); return; } else { ((TextView) findViewById(R.id.main_txt_title)) .setText(getString(R.string.career_fair_format, term.getQuarter(), term.getYear())); } // Setup parent fragment with tabPager FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentByTag(RHCareerFairLayout.PARENT_FRAGMENT_TAG) == null) { FragmentTransaction ft = fm.beginTransaction(); ft.add(R.id.main_frg_body, new VPParentFragment(), RHCareerFairLayout.PARENT_FRAGMENT_TAG); ft.commit(); fm.executePendingTransactions(); } }
From source file:com.bjerva.tsplex.fragments.SignCategoryFragment.java
private void loadCategories() { if (ma == null) { Log.d(TAG, "Null activity"); return;/*ww w . j a va2 s . co m*/ } Log.d(TAG, "Loading categories!"); gsonCats = new ArrayList<SimpleGson>(ma.getGsonSignsLite().size()); for (SimpleGson simpleG : ma.getGsonSignsLite()) { gsonCats.add(simpleG); } Collections.sort(gsonCats, new CustomComparator()); List<Map<String, String>> groupData = new ArrayList<Map<String, String>>(); List<List<Map<String, SimpleGson>>> childData = new ArrayList<List<Map<String, SimpleGson>>>(); final ArrayList<Integer> groupSizes = new ArrayList<Integer>(); groupSizes.add(0); int count = 0; int size = gsonCats.size(); int groupCount = 0; String currCat = ""; String innerCat = ""; while (count < size) { currCat = gsonCats.get(count).getTag(); innerCat = gsonCats.get(count).getTag(); Map<String, String> curGroupMap = new HashMap<String, String>(); groupData.add(curGroupMap); if (currCat.equals("")) { curGroupMap.put(NAME, "Okategoriserat"); } else { curGroupMap.put(NAME, currCat); } List<Map<String, SimpleGson>> children = new ArrayList<Map<String, SimpleGson>>(); do { Map<String, SimpleGson> curChildMap = new HashMap<String, SimpleGson>(); children.add(curChildMap); curChildMap.put(IS_EVEN, gsonCats.get(count)); count++; groupCount++; if (count < size) { innerCat = gsonCats.get(count).getTag(); } } while (currCat.equals(innerCat) && count < size); childData.add(children); groupSizes.add(groupCount); } // Set up our adapter mAdapter = new SimpleExpandableSignListAdapter(getActivity(), groupData, android.R.layout.simple_expandable_list_item_1, new String[] { NAME }, new int[] { android.R.id.text1, android.R.id.text2 }, childData, R.layout.list_child, new String[] { IS_EVEN }, new int[] { R.id.list_child_title }); setListAdapter(mAdapter); //Set listener getExpandableListView().setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(android.widget.ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { ma.showLoader(); ma.checkConnection(); int signPosition = groupSizes.get(groupPosition) + childPosition; mGaTracker.sendEvent("sign", "category_click", gsonCats.get(signPosition).getWord(), 1L); //Update position ma.loadSingleJson(gsonCats.get(signPosition).getId()); if (!ma.isOnline()) { ma.connectionError(); ma.hideLoader(); return true; } if (ma.getDetFragment() == null) { //Create detail fragment SignDetailFragment newFragment = new SignDetailFragment(); //Add to container FragmentTransaction transaction = ma.getSupportFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.anim.slide_fragment_in_on_replace, R.anim.slide_fragment_out_on_replace); transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); transaction.commit(); } else { ma.getDetFragment().startUpHelper(ma.getCurrentSign()); } return true; } }); getExpandableListView().setFastScrollEnabled(true); }
From source file:com.chintanrathod.fragmenttabbackstack.MainActivity.java
@Override public void onBackPressed() { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); setFragmentFinishAnimation(ft);//w w w . j a v a 2 s .c o m if (radioGroup.getCheckedRadioButtonId() == rbFirst.getId()) { if (firstStack.size() > 1) { firstStack.lastElement().onPause(); ft.remove(firstStack.pop()); firstStack.lastElement().onResume(); ft.show(firstStack.lastElement()); ft.commit(); } else { super.onBackPressed(); } } else if (radioGroup.getCheckedRadioButtonId() == rbSecond.getId()) { if (secondStack.size() > 1) { ft.remove(secondStack.pop()); secondStack.lastElement().onResume(); ft.show(secondStack.lastElement()); ft.commit(); } else { super.onBackPressed(); } } else { if (thirdStack.size() > 1) { thirdStack.lastElement().onPause(); ft.remove(thirdStack.pop()); thirdStack.lastElement().onResume(); ft.show(thirdStack.lastElement()); ft.commit(); } else { super.onBackPressed(); } } System.gc(); }