List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java
/** * Re-attach a panel that has been detached previously. *//* w w w .j av a 2 s. co m*/ public void attachPanel(SplitPanel p) { Log.d(LOG, "ReaderActivity.attachPanel"); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.attach(p); fragmentTransaction.commit(); panelCount++; }
From source file:com.door43.translationstudio.ui.dialogs.BackupDialog.java
/** * this is to fix old method which when called in onResume() would create a * second dialog overlaying the first. The first was actually not removed. * Doing a commit after the remove() and starting a second FragmentTransaction * seems to fix the duplicate dialog bug. * * @param dialog//from w ww . j ava 2 s . c o m * @param tag */ private void showDialogFragment(android.app.DialogFragment dialog, String tag) { FragmentTransaction backupFt = getFragmentManager().beginTransaction(); Fragment backupPrev = getFragmentManager().findFragmentByTag(tag); if (backupPrev != null) { backupFt.remove(backupPrev); backupFt.commit(); // apply the remove backupFt = getFragmentManager().beginTransaction(); // start a new transaction } backupFt.addToBackStack(null); dialog.show(backupFt, tag); }
From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java
/** * Remove panel, but don't close the application if no panel is left. */// w ww.ja va 2s.c om public void removePanel(SplitPanel p) { Log.d(LOG, "ReaderActivity.removePanelWithoutClosing"); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.remove(p); fragmentTransaction.commit(); panelCount--; // Rethinks what menu items to display invalidateOptionsMenu(); }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
void addFragmentToStack() { mStackLevel++;//from ww w .java 2s . com // Instantiate a new fragment. Fragment newFragment = GetNewVehicalFragment.newInstance(GetAllVehicalDetails.this); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.animator.fragment_slide_left_enter, R.animator.fragment_slide_left_exit, R.animator.fragment_slide_right_enter, R.animator.fragment_slide_right_exit); ft.replace(R.id.fragment1, newFragment); // ft.addToBackStack(null); ft.commit(); }
From source file:com.evandroid.musica.MainLyricActivity.java
private LyricsViewFragment init(FragmentManager fragmentManager, boolean startEmpty) { LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) fragmentManager .findFragmentByTag(LYRICS_FRAGMENT_TAG); if (lyricsViewFragment == null || lyricsViewFragment.isDetached()) lyricsViewFragment = new LyricsViewFragment(); lyricsViewFragment.startEmpty(startEmpty); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (!lyricsViewFragment.isAdded()) { fragmentTransaction.add(R.id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG); }// w ww. j a v a 2 s. c o m Fragment[] activeFragments = getActiveFragments(); displayedFragment = getDisplayedFragment(activeFragments); for (Fragment fragment : activeFragments) if (fragment != null) { if (fragment != displayedFragment && !fragment.isHidden()) { fragmentTransaction.hide(fragment); fragment.onHiddenChanged(true); } else if (fragment == displayedFragment) fragmentTransaction.show(fragment); } fragmentTransaction.commit(); return lyricsViewFragment; }
From source file:fbla.hhs.eclat.Camera.Camera2BasicFragment.java
/** * Switch Fragments//from w w w . j a va 2s. com */ private void switchFrag() { ImagePreview fragment = new ImagePreview(); fragment.setImage(mFile, this, cameraType); FragmentManager fragmentManager = getActivity().getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.container, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); }
From source file:am.project.x.business.main.MainActivity.java
private void setFragment(String tag) { final String oldTag = mCurrent; mCurrent = tag;/*from w w w .j a v a2 s . c om*/ final FragmentManager manager = getFragmentManager(); final FragmentTransaction transaction = manager.beginTransaction(); if (!TextUtils.isEmpty(oldTag)) { final Fragment old = manager.findFragmentByTag(oldTag); if (old != null && old.isVisible()) { transaction.hide(old); } } Fragment target = manager.findFragmentByTag(tag); if (target != null && target.isVisible()) return; if (target == null) { switch (tag) { default: case TAG_WIDGETS: target = WidgetsFragment.newInstance(); break; case TAG_DRAWABLES: target = DrawablesFragment.newInstance(); break; case TAG_OTHERS: target = OthersFragment.newInstance(); break; case TAG_DEVELOP: target = DevelopFragment.newInstance(); break; } transaction.add(mVContent.getId(), target, tag); } transaction.show(target); transaction.commit(); }
From source file:com.hit.jj.mapshow.RoutingActivity.java
/** * ?//w ww. j ava 2 s .co m */ private void setListener() { /** * On single clicking the directions label, start a ListActivity to show * the list of all directions for this route. Selecting one of those * items will return to the map and highlight that segment. * */ directionsLabel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (mPaths == null) return; isStart = true; for (int i = 0; i < mPaths.size(); i++) { final Path path = mPaths.get(i);//? final int finalI = i; new Handler().postDelayed(new Runnable() { @Override public void run() { switch (path.getNextDirection()) { case 1: speak("?"); break; case 0: speak(""); break; case 2: speak("??"); break; } clearAll(); pathfingding(mPaths, finalI); } }, 10000); } } }); img_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clearAll(); } }); img_currLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.e("mLocation", mLocation.getX() + " " + mLocation.getY()); Point p = (Point) GeometryEngine.project(mLocation, egs, wm); map.zoomToResolution(p, 20.0); } }); img_getDirections.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); RoutingDialogFragment frag_dialog = new RoutingDialogFragment(); ft.add(frag_dialog, "Dialog"); ft.commit(); } }); img_speak.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); SpeakDialogFragment frag_dialog = new SpeakDialogFragment(); ft.add(frag_dialog, "SpeakDialog"); ft.commit(); } }); /** * On single tapping the map, query for a route segment and highlight * the segment and show direction summary in the label if a segment is * found. */ map.setOnSingleTapListener(new OnSingleTapListener() { private static final long serialVersionUID = 1L; public void onSingleTap(float x, float y) { // Get all the graphics within 20 pixels the click int[] indexes = hiddenSegmentsLayer.getGraphicIDs(x, y, 20); // Hide the currently selected segment hiddenSegmentsLayer.updateGraphic(selectedSegmentID, segmentHider); if (indexes.length < 1) { // If no segments were found but there is currently a route, // zoom to the extent of the full route if (curRoute != null) { map.setExtent(curRoute.getEnvelope(), 250); directionsLabel.setText(routeSummary); } return; } // Otherwise update our currently selected segment selectedSegmentID = indexes[0]; Graphic selected = hiddenSegmentsLayer.getGraphic(selectedSegmentID); // Highlight it on the map hiddenSegmentsLayer.updateGraphic(selectedSegmentID, segmentShower); String direction = ((String) selected.getAttributeValue("text")); double time = ((Double) selected.getAttributeValue("time")).doubleValue(); double length = ((Double) selected.getAttributeValue("length")).doubleValue(); // Update the label with this direction's information String label = String.format("%s%n%.1f minutes (%.1f miles)", direction, time, length); directionsLabel.setText(label); // Zoom to the extent of that segment map.setExtent(selected.getGeometry(), 50); } }); /** * On long pressing the map view, route from our current location to the * pressed location. * */ map.setOnLongPressListener(new OnLongPressListener() { private static final long serialVersionUID = 1L; public boolean onLongPress(final float x, final float y) { final Point loc = map.toMapPoint(x, y); // Point s1= new Point(26.0734997,119.3150024); Point s1 = new Point(26.1023006, 119.2789993); Point s2 = new Point(mLocation.getY(), mLocation.getX()); Point sp = new Point(loc.getY(), loc.getX()); pathfind(s2, sp);// // pathfind(s1,sp);// return true; } }); }
From source file:com.saarang.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case com.saarang.samples.apps.iosched.R.id.menu_captions: if (mIsFullscreen) { if (mFullscreenCaptions.getVisibility() == View.GONE) { mFullscreenCaptions.setVisibility(View.VISIBLE); SessionCaptionsFragment captionsFragment; captionsFragment = (SessionCaptionsFragment) getFragmentManager() .findFragmentByTag(TAG_CAPTIONS); if (captionsFragment == null) { captionsFragment = new SessionCaptionsFragment(); captionsFragment.setDarkTheme(true); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(com.saarang.samples.apps.iosched.R.id.fullscreen_captions, captionsFragment, TAG_CAPTIONS); ft.commit(); }//from w ww. j a va2s . c om captionsFragment.updateViews(mCaptionsUrl); return true; } } mFullscreenCaptions.setVisibility(View.GONE); break; case com.saarang.samples.apps.iosched.R.id.menu_share: if (mSessionShareData != null) { new SessionsHelper(this).shareSession(this, com.saarang.samples.apps.iosched.R.string.share_livestream_template, mSessionShareData.title, mSessionShareData.hashtag, mSessionShareData.sessionUrl); return true; } break; } return super.onOptionsItemSelected(item); }
From source file:com.orbar.pxdemo.ImageView.FivePXImageFragment.java
@Override public void onDestroyView() { Log.d(TAG, "onDestroyView"); super.onDestroyView(); Fragment fragment = (getFragmentManager().findFragmentById(R.id.map)); FragmentTransaction ft = getActivity().getFragmentManager().beginTransaction(); ft.remove(fragment);//from ww w. j av a2s.c o m ft.commit(); }