List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java
/** * Adds a panel to view for the first time. * @param p SplitPanel instance//from w w w.j a v a2s. c om */ public void addPanel(SplitPanel p) { Log.d(LOG, "ReaderActivity.addPanel"); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.PanelsLayout, p, p.getTag()); fragmentTransaction.commit(); panelCount++; // Rethinks what menu items to display invalidateOptionsMenu(); }
From source file:blackman.matt.infinitebrowser.InfinityBrowser.java
/** * Load a board using a variety of logics. *//*from ww w. j a v a 2s . co m*/ private void loadUpABoard() { // Load preferences for activity SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); Boolean ageAccept = preferences.getBoolean("age_guard_accept", false); // Checks if age guard has been accepted if (!ageAccept) { DialogFragment ageGuardDialog = new AgeGuardDialogFragment(); ageGuardDialog.show(getFragmentManager(), "ageGuardDialog"); } else { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Board newBoard; Intent intent = getIntent(); String defaultBoard = preferences.getString("default_board", "").toLowerCase(); if (intent.getData() != null || intent.getExtras() != null) { newBoard = loadFromIntent(intent); } else if (!defaultBoard.equals("")) { newBoard = Board.newInstance(defaultBoard); mTitle = "/" + defaultBoard.toLowerCase() + "/"; } else { newBoard = getFirstDrawerItem(); } if (newBoard != null) { fragmentTransaction.replace(R.id.container, newBoard, mTitle.toString()); findViewById(R.id.ll_help_add_boards).setVisibility(View.GONE); setTitle(mTitle); } fragmentTransaction.commit(); } }
From source file:com.cloudbees.gasp.activity.ReviewActivity.java
private void addGaspFragments() { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); mGaspReviewFragment = new GaspReviewFragment() { @Override/*from w w w . ja v a2s . com*/ public void onSuccess(String location) { try { Log.d(TAG, "Gasp! review added: " + location); addGaspEvent(mPlacesReference, new URL(location)); } catch (Exception e) { e.printStackTrace(); } } @Override public void onFailure() { Log.e(TAG, "Error adding Gasp! review"); } }; mAddEventFragment = new AddEventFragment() { @Override public void onSuccess(EventResponse eventResponse) { Log.d(TAG, "Event added: " + eventResponse.getEvent_id()); } @Override public void onFailure(String status) { Log.d(TAG, "Error adding event to Google Places API"); } }; ft.add(mGaspReviewFragment, "Gasp Review Fragment"); ft.add(mAddEventFragment, "Add Event Fragment"); ft.commit(); }
From source file:mobile_final.ChattingRoomActivity.java
private void initiateFragments() { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); // Check to see if we have retained the fragment which handles // asynchronous backend calls // processFragment = (CloudBackendFragment) fragmentManager // .findFragmentByTag(PROCESSING_FRAGMENT_TAG); // If not retained (or first time running), create a new one if (processFragment == null) { processFragment = new CloudBackendFragment(); processFragment.setRetainInstance(true); // fragmentTransaction.add(processFragment, // PROCESSING_FRAGMENT_TAG); }/* w w w . j av a 2 s .c o m*/ // // Add the splash screen fragment // mSplashFragment = new SplashFragment(); // fragmentTransaction.add(R.id.activity_main, mSplashFragment, // SPLASH_FRAGMENT_TAG); fragmentTransaction.commit(); }
From source file:org.chromium.chrome.browser.bookmark.ManageBookmarkActivity.java
/** * Creates and sets an action listener on the add/edit bookmark fragment. * @param addEditFragment The fragment that the listener should be attached to. *///from w w w. j a v a2 s. co m private void setActionListenerOnAddEdit(final AddEditBookmarkFragment addEditFragment) { addEditFragment.setOnActionListener(new AddEditBookmarkFragment.OnActionListener() { @Override public void onCancel() { finishAddEdit(); } @Override public void onNodeEdited(long id) { finishAddEdit(); } @Override public void onFolderCreated(long id, String name) { finishAddEdit(); if (getFragmentManager().getBackStackEntryCount() != 0) { ((SelectBookmarkFolderFragment) addEditFragment.getTargetFragment()).executeFolderSelection(id, name); } } @Override public void triggerFolderSelection() { FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); boolean isRoot = getFragmentManager().getBackStackEntryCount() == 0; SelectBookmarkFolderFragment selectFolder = SelectBookmarkFolderFragment.newInstance( // Only allow the root add/edit bookmark UI to create new bookmark // folders during selection. isRoot, addEditFragment.getParentFolderId(), addEditFragment.isFolder()); selectFolder.setTargetFragment(addEditFragment, 0); setActionListenerOnFolderSelection(selectFolder); String tag = isRoot ? BASE_SELECT_FOLDER_FRAGMENT_TAG : ADD_FOLDER_SELECT_FOLDER_FRAGMENT_TAG; fragmentTransaction.add(android.R.id.content, selectFolder, tag); fragmentTransaction.hide(addEditFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } @Override public void onRemove() { finishAddEdit(); } @Override public void setBackEnabled(boolean enabled) { mIsBackEnabled = enabled; } private void finishAddEdit() { if (getFragmentManager().getBackStackEntryCount() == 0) { finish(); } else { getFragmentManager().popBackStackImmediate(); } } }); }
From source file:org.symptomcheck.capstone.ui.MainActivityOld.java
private void openFragment(Fragment fragment, boolean addToBackStack) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (addToBackStack) { fragmentTransaction.addToBackStack(null).replace(R.id.content_frame, fragment); } else {//from w ww . ja v a 2 s. co m fragmentTransaction.replace(R.id.content_frame, fragment); } fragmentTransaction.commit(); }
From source file:com.nuvolect.securesuite.main.ContactListActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private ContactListFragment startContactListFragment() { boolean isDestroyed = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && m_act.isDestroyed()) isDestroyed = true;/* w ww .j a va 2 s . com*/ if (m_act == null || isDestroyed || m_act.isFinishing()) return null; ContactListFragment clf = new ContactListFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.contact_list_container, clf, CConst.CONTACT_LIST_FRAGMENT_TAG); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(null); ft.commit(); return clf; }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
@Override public void onDataComplete(int i, String image_path) { if (i == 1) { /* Bitmap bitmap = ((BitmapDrawable)car_image.getDrawable()).getBitmap(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes); File destination = new File(getCacheDir(),"car.jpg"); FileOutputStream fo;/* ww w .j av a 2s .co m*/ try { fo = new FileOutputStream(destination); fo.write(bytes.toByteArray()); fo.close(); } catch (IOException e) { e.printStackTrace(); } image_path=destination.getAbsolutePath(); // car_image.setImageBitmap(bitmap); newFragment.setImagePath(image_path);*/ } else if (i == 2) { /*car_image.setOnClickListener(null); car_image1.setOnClickListener(null);*/ // collapsingToolbarLayout.setVisibility(View.GONE); Fragment newFragment = UserAddNewVehicalSecond.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(); } else if (i == 3) { Fragment newFragment = UserAddNewVehicalThird.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(); } else if (i == 4) { Fragment newFragment = UserNewVehicalFourth.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(); } else if (i == 5) { Fragment newFragment = UserAddNewVehicalFifth.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(); } else if (i == 0) { Glide.with(GetAllVehicalDetails.this).load(image_path).asBitmap() .into(new SimpleTarget<Bitmap>(300, 300) { @Override public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { //setBackgroundImage(resource); // car_image.setImageBitmap(resource); // car_image1.setImageBitmap(resource); } }); } }
From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java
private void goFullscreen(boolean force) { isFullscreen = true;/* w w w . j a v a 2 s .c o m*/ setRequestedOrientation(force ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); VideoController videoControls = (VideoController) findViewById(R.id.controller); if (videoControls != null) { videoControls.setFullscreen(true); } ThumbnailWrapper videoContainer = (ThumbnailWrapper) findViewById(R.id.video_fragment_container); videoContainer.setMaintainAspectRatio(false); if (captionFragment != null) { FragmentTransaction tx = getFragmentManager().beginTransaction(); tx.remove(captionFragment); tx.commit(); } findViewById(R.id.detail_bottom_container).setVisibility(View.GONE); if (isBigScreen) { findViewById(R.id.detail_right_container).setVisibility(View.GONE); findViewById(R.id.detail_center_divider).setVisibility(View.GONE); } setNavVisibility(videoFragment == null || !videoFragment.isPlaying()); getDecorViewTreeObserver().addOnGlobalLayoutListener(layoutFixer); }
From source file:com.google.android.apps.forscience.whistlepunk.review.RunReviewFragment.java
@Override public void onAddNoteTimestampClicked(GoosciLabelValue.LabelValue selectedValue, int labelType, long selectedTimestamp) { AddNoteDialog addDialog = (AddNoteDialog) getChildFragmentManager().findFragmentByTag(AddNoteDialog.TAG); if (addDialog != null) { addDialog.dismiss();//from ww w. j ava 2s.c o m } // Show the timestamp edit window below the graph / over the notes getView().findViewById(R.id.embedded).setVisibility(View.VISIBLE); EditTimeDialog timeDialog = EditTimeDialog.newInstance(selectedValue, labelType, selectedTimestamp, mExperimentRun.getFirstTimestamp()); FragmentTransaction ft = getChildFragmentManager().beginTransaction(); ft.add(R.id.embedded, timeDialog, EditTimeDialog.TAG); ft.commit(); mRunReviewOverlay.setActiveTimestamp(selectedTimestamp); mRunReviewOverlay.setOnTimestampChangeListener(timeDialog); setTimepickerUi(getView(), true); }