List of usage examples for android.support.v4.app FragmentManager executePendingTransactions
public abstract boolean executePendingTransactions();
From source file:org.mythdroid.activities.Recordings.java
@Override protected void resetContentView() { final FragmentManager fm = getSupportFragmentManager(); ArrayList<String> backStackFrags = new ArrayList<String>(); // At this stage dualPane reflects the old configuration boolean dualPane = findViewById(R.id.recdetails) != null; /* The old backstack is useless now, save the relevant entries */ int backStackSize = fm.getBackStackEntryCount(); for (int i = 0; i < backStackSize; i++) { Fragment lf = fm.findFragmentById(R.id.reclistframe); Fragment df = fm.findFragmentById(R.id.recdetails); Fragment f = (!dualPane || df == null ? lf : df); backStackFrags.add(0, f.getClass().getName()); fm.popBackStackImmediate();// w w w . java 2 s . co m } setContentView(R.layout.recordings); dualPane = findViewById(R.id.recdetails) != null; // Now dualPane reflects the new configuration listFragment = new RecListFragment(); fm.beginTransaction().replace(R.id.reclistframe, listFragment).commitAllowingStateLoss(); fm.executePendingTransactions(); listFragment.setAdapter(recordings); // Restore the backstack for (String frag : backStackFrags) { // RecListFragment has handled this.. if (dualPane && frag.equals(RecDetailFragment.class.getName())) continue; try { FragmentTransaction ft = fm.beginTransaction(); Fragment f = (Fragment) Class.forName(frag).newInstance(); ft.replace((dualPane ? R.id.recdetails : R.id.reclistframe), f, f.getClass().getSimpleName()) .addToBackStack(null).commitAllowingStateLoss(); } catch (Exception e) { ErrUtil.reportErr(this, e); return; } } fm.executePendingTransactions(); }
From source file:it.sasabz.android.sasabus.fragments.OnlineSearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.inflater_glob = inflater; result = inflater.inflate(R.layout.online_search_layout, container, false); Date datum = new Date(); SimpleDateFormat simple = new SimpleDateFormat("dd.MM.yyyy HH:mm"); TextView datetime = (TextView) result.findViewById(R.id.time); String datetimestring = ""; datetimestring = simple.format(datum); datetime.setText(datetimestring);//from w ww . j a v a 2s . c om Button search = (Button) result.findViewById(R.id.search); search.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AutoCompleteTextView from = (AutoCompleteTextView) result.findViewById(R.id.from_text); AutoCompleteTextView to = (AutoCompleteTextView) result.findViewById(R.id.to_text); TextView datetime = (TextView) result.findViewById(R.id.time); String from_txt = getThis().getResources().getString(R.string.from_txt); if ((!from.getText().toString().trim().equals("") || !from.getHint().toString().trim().equals(from_txt)) && !to.getText().toString().trim().equals("")) { //Intent getSelect = new Intent(getThis().getActivity(), OnlineSelectStopActivity.class); String fromtext = ""; if (from.getText().toString().trim().equals("")) fromtext = from.getHint().toString(); else fromtext = from.getText().toString(); String totext = to.getText().toString(); fromtext = "(" + fromtext.replace(" -", ")"); totext = "(" + totext.replace(" -", ")"); Fragment fragment = new OnlineSelectFragment(fromtext, totext, datetime.getText().toString()); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); Fragment old = fragmentManager.findFragmentById(R.id.onlinefragment); if (old != null) { ft.remove(old); } ft.add(R.id.onlinefragment, fragment); ft.addToBackStack(null); ft.commit(); fragmentManager.executePendingTransactions(); } } }); datetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getThis().getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); TextView dt = (TextView) result.findViewById(R.id.time); String datetimestring = dt.getText().toString(); SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date datetime = null; try { datetime = datetimeformat.parse(datetimestring); } catch (Exception e) { ; } mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes()); mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate()); // Check is system is set to use 24h time (this doesn't seem to // work as expected though) final String timeS = android.provider.Settings.System.getString( getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); String datetimestring = ""; int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH); int month = mDateTimePicker.get(Calendar.MONTH) + 1; int year = mDateTimePicker.get(Calendar.YEAR); int hour = 0; int min = 0; int append = 0; if (mDateTimePicker.is24HourView()) { hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY); min = mDateTimePicker.get(Calendar.MINUTE); } else { hour = mDateTimePicker.get(Calendar.HOUR); min = mDateTimePicker.get(Calendar.MINUTE); if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) { append = 1; } else { append = 2; } } if (day < 10) { datetimestring += "0"; } datetimestring += (day + "."); if (month < 10) { datetimestring += "0"; } datetimestring += (month + "." + year + " "); if (hour < 10) { datetimestring += "0"; } datetimestring += (hour + ":"); if (min < 10) { datetimestring += "0"; } datetimestring += min; switch (append) { case 1: datetimestring += " AM"; break; case 2: datetimestring += " PM"; break; } TextView time = (TextView) result.findViewById(R.id.time); time.setText(datetimestring); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is // clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); ImageButton datepicker = (ImageButton) result.findViewById(R.id.datepicker); datepicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getThis().getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); TextView dt = (TextView) result.findViewById(R.id.time); String datetimestring = dt.getText().toString(); SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date datetime = null; try { datetime = datetimeformat.parse(datetimestring); } catch (Exception e) { ; } mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes()); mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate()); // Check is system is set to use 24h time (this doesn't seem to // work as expected though) final String timeS = android.provider.Settings.System.getString( getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); // Update demo TextViews when the "OK" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); String datetimestring = ""; int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH); int month = mDateTimePicker.get(Calendar.MONTH) + 1; int year = mDateTimePicker.get(Calendar.YEAR); int hour = 0; int min = 0; int append = 0; if (mDateTimePicker.is24HourView()) { hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY); min = mDateTimePicker.get(Calendar.MINUTE); } else { hour = mDateTimePicker.get(Calendar.HOUR); min = mDateTimePicker.get(Calendar.MINUTE); if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) { append = 1; } else { append = 2; } } if (day < 10) { datetimestring += "0"; } datetimestring += (day + "."); if (month < 10) { datetimestring += "0"; } datetimestring += (month + "." + year + " "); if (hour < 10) { datetimestring += "0"; } datetimestring += (hour + ":"); if (min < 10) { datetimestring += "0"; } datetimestring += min; switch (append) { case 1: datetimestring += " AM"; break; case 2: datetimestring += " PM"; break; } TextView time = (TextView) result.findViewById(R.id.time); time.setText(datetimestring); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is // clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); from = (AutoCompleteTextView) result.findViewById(R.id.from_text); to = (AutoCompleteTextView) result.findViewById(R.id.to_text); from.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(from.getWindowToken(), 0); } }); to.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(to.getWindowToken(), 0); } }); LocationManager locman = (LocationManager) this.getActivity().getSystemService(Context.LOCATION_SERVICE); Location lastloc = locman.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (MySQLiteDBAdapter.exists(this.getActivity())) { if (lastloc == null) { lastloc = locman.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } if (lastloc != null) { try { Palina palina = PalinaList.getPalinaGPS(lastloc); if (palina != null) { from.setHint(palina.toString()); } } catch (Exception e) { Log.e("HomeActivity", "Fehler bei der Location", e); } } else { Log.v("HomeActivity", "No location found!!"); } Vector<DBObject> palinalist = PalinaList.getNameList(); MyAutocompleteAdapter adapterfrom = new MyAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, palinalist); MyAutocompleteAdapter adapterto = new MyAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, palinalist); from.setAdapter(adapterfrom); to.setAdapter(adapterto); InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(from.getWindowToken(), 0); mgr.hideSoftInputFromWindow(to.getWindowToken(), 0); } Button favorites = (Button) result.findViewById(R.id.favorites); favorites.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SelectFavoritenDialog dialog = new SelectFavoritenDialog(getThis()); dialog.show(); } }); Button mappicker = (Button) result.findViewById(R.id.map); mappicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MapSelectActivity.class); startActivityForResult(intent, REQUESTCODE_ACTIVITY); } }); return result; }
From source file:net.vivekiyer.GAL.CorporateAddressBook.java
private void resetAndHideDetails(final FragmentManager fragmentManager) { CorporateAddressBookFragment list = (CorporateAddressBookFragment) fragmentManager .findFragmentById(R.id.main_fragment); CorporateContactRecordFragment details = (CorporateContactRecordFragment) fragmentManager .findFragmentById(R.id.contact_fragment); if (details != null && details.isInLayout() && !this.isPaused) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); //ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); // Below does not work since it clears the detail fragment before anim starts, // making it look rather weird. Better off w/o anims, unfortunately. //ft.setCustomAnimations(R.anim.slide_in, R.anim.slide_out); ft.hide(details);// w w w .ja v a2 s .co m ft.commit(); fragmentManager.executePendingTransactions(); details.clear(); } list.setViewBackground(false); selectedContact = null; }
From source file:com.ovrhere.android.careerstack.ui.MainActivity.java
/** Re-attaches the last fragment. And resets back button. */ private void reattachLastFragment() { //first, always check tablet fragment. checkTabletFrag();/*from ww w . j a v a 2 s .c om*/ String currentTag = fragTagStack.peek(); FragmentManager fm = getSupportFragmentManager(); Log.d("Main", "currentTag: " + currentTag); if (currentTag != null) { if (inTabletMode()) { //TODO re-arrange fragments accordingly Fragment careerItem = fm.findFragmentByTag(TAG_CAREER_ITEM_FRAG); //if the regular mode item is a career item if (TAG_CAREER_ITEM_FRAG.equals(currentTag)) { fm.beginTransaction().remove(careerItem).commit(); //pop to search result fragment onSupportNavigateUp(); fm.executePendingTransactions(); loadTabletFragment(careerItem, TAG_CAREER_ITEM_FRAG); } else if (careerItem == null) { resetTabletContainerMessage(); } } else if (TAG_SEARCH_RESULTS_FRAG.equals(currentTag)) { //if we are in search mode, the we may have a lingering careeritem //TODO re-arrange fragments accordingly Fragment careerItem = fm.findFragmentByTag(TAG_CAREER_ITEM_FRAG); //re-attach careeritem if (careerItem != null) { fm.beginTransaction().remove(careerItem).commit(); fm.executePendingTransactions(); loadFragment(careerItem, TAG_CAREER_ITEM_FRAG, true); } } else { Fragment frag = fm.findFragmentByTag(currentTag); fm.beginTransaction().attach(frag).commit(); } } checkHomeButtonBack(); }
From source file:com.topfeeds4j.sample.app.activities.MainActivity.java
/** * Select a provider under "single-page" mode. * * @param position//from w ww. jav a 2s .com */ private void selectSingleModePage(int position) { FragmentManager frgMgr = getSupportFragmentManager(); Fragment frg = mSinglePages.get(position); boolean newOne = false; if (frg == null) { //New page that ever been seen before. newOne = true; int dynamicTotal = Prefs.getInstance().getBloggerNames().length; if (position < dynamicTotal) { long[] ids = Prefs.getInstance().getBloggerIds(); frg = BloggerPageFragment.newInstance(App.Instance, ids[position]); } else { frg = com.topfeeds4j.sample.utils.Utils.getFragment(App.Instance, position - dynamicTotal); } } if (frg != null) { String tag = frg.getClass().getSimpleName(); frgMgr.beginTransaction() .setCustomAnimations(R.anim.slide_in_from_right, R.anim.slide_out_to_right, R.anim.slide_in_from_right, R.anim.slide_out_to_right) .replace(R.id.single_page_container, frg, tag).commit(); frgMgr.executePendingTransactions(); if (newOne) { mSinglePages.put(position, frg); } TopFeedsFragment topFeedsFrg = (TopFeedsFragment) frg; if (!(topFeedsFrg instanceof BookmarkListPageFragment)) { //Except the bookmark-list all other pages should be loaded after be created. //Bookmark-list can load itself when created. topFeedsFrg.getNewsList(); } } }
From source file:it.sasabz.android.sasabus.classes.dialogs.ConnectionDialog.java
private void fillData() { MyXMLConnectionAdapter adapter = new MyXMLConnectionAdapter(list); ListView listv = (ListView) findViewById(android.R.id.list); listv.setAdapter(adapter);// w w w . j a va 2 s .co m listv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> l, View v, int position, long id) { XMLConnection conn = (XMLConnection) list.get(position); if (conn instanceof XMLJourney) { SimpleDateFormat simple = new SimpleDateFormat("HH:mm"); String fromtext = "(" + conn.getDeparture().getStation().getHaltestelle().replace(" -", ")"); String totext = "(" + conn.getArrival().getStation().getHaltestelle().replace(" -", ")"); FragmentManager fragmentManager = fragment.getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); Fragment old = fragmentManager.findFragmentById(R.id.onlinefragment); if (old != null) { ft.remove(old); } Fragment fragment = null; try { fragment = new WayFragment(((XMLJourney) conn).getAttribut("NUMBER"), fromtext, totext, simple.format(conn.getDeparture().getArrtime()), simple.format(conn.getArrival().getArrtime())); } catch (Exception e) { fragment = old; AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setCancelable(false); builder.setMessage(R.string.error_connection); builder.setTitle(R.string.error); builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create(); builder.show(); fragmentManager.popBackStack(); } ft.add(R.id.onlinefragment, fragment); ft.addToBackStack(null); ft.commit(); fragmentManager.executePendingTransactions(); dismiss(); } } }); }
From source file:com.android.calendar.EventInfoFragment.java
private void showEventColorPickerDialog() { if (mColorPickerDialog == null) { mColorPickerDialog = EventColorPickerDialog.newInstance(mColors, mCurrentColor, mCalendarColor, mIsTabletConfig);//from w w w. ja v a 2 s . c om mColorPickerDialog.setOnColorSelectedListener(this); } final FragmentManager fragmentManager = getFragmentManager(); fragmentManager.executePendingTransactions(); if (!mColorPickerDialog.isAdded()) { mColorPickerDialog.show(fragmentManager, COLOR_PICKER_DIALOG_TAG); } }
From source file:org.totschnig.myexpenses.activity.ExpenseEdit.java
private void setup() { mAmountText.setFractionDigits(Money.getFractionDigits(mTransaction.getAmount().getCurrency())); linkInputsWithLabels();/* w w w . jav a 2s .c o m*/ if (mTransaction instanceof SplitTransaction) { mAmountText.addTextChangedListener(new MyTextWatcher() { @Override public void afterTextChanged(Editable s) { findSplitPartList().updateBalance(); } }); } if (mOperationType == MyExpenses.TYPE_TRANSFER) { mAmountText.addTextChangedListener(new LinkedTransferAmountTextWatcher(true)); mTransferAmountText.addTextChangedListener(new LinkedTransferAmountTextWatcher(false)); } // Spinner for account and transfer account mAccountsAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, null, new String[] { KEY_LABEL }, new int[] { android.R.id.text1 }, 0); mAccountsAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item); mAccountSpinner.setAdapter(mAccountsAdapter); if (mTransaction instanceof SplitPartCategory || mTransaction instanceof SplitPartTransfer) { disableAccountSpinner(); } mIsMainTransactionOrTemplate = mOperationType != MyExpenses.TYPE_TRANSFER && !(mTransaction instanceof SplitPartCategory); if (mIsMainTransactionOrTemplate) { // Spinner for methods mMethodsAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, null, new String[] { KEY_LABEL }, new int[] { android.R.id.text1 }, 0); mMethodsAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item); mMethodSpinner.setAdapter(mMethodsAdapter); } else { findViewById(R.id.PayeeRow).setVisibility(View.GONE); View MethodContainer = findViewById(R.id.MethodRow); MethodContainer.setVisibility(View.GONE); } View categoryContainer = findViewById(R.id.CategoryRow); if (categoryContainer == null) categoryContainer = findViewById(R.id.Category); TextView accountLabelTv = (TextView) findViewById(R.id.AccountLabel); if (mOperationType == MyExpenses.TYPE_TRANSFER) { mTypeButton.setVisibility(View.GONE); categoryContainer.setVisibility(View.GONE); View accountContainer = findViewById(R.id.TransferAccountRow); if (accountContainer == null) accountContainer = findViewById(R.id.TransferAccount); accountContainer.setVisibility(View.VISIBLE); accountLabelTv.setText(R.string.transfer_from_account); mTransferAccountsAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, null, new String[] { KEY_LABEL }, new int[] { android.R.id.text1 }, 0); mTransferAccountsAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item); mTransferAccountSpinner.setAdapter(mTransferAccountsAdapter); } mManager.initLoader(ACCOUNTS_CURSOR, null, this); if (mTransaction instanceof Template) { findViewById(R.id.TitleRow).setVisibility(View.VISIBLE); if (!calendarPermissionPermanentlyDeclined()) { //if user has denied access and checked that he does not want to be asked again, we do not //bother him with a button that is not working setPlannerRowVisibility(View.VISIBLE); RecurrenceAdapter recurrenceAdapter = new RecurrenceAdapter(this, false); mReccurenceSpinner.setAdapter(recurrenceAdapter); mReccurenceSpinner.setOnItemSelectedListener(this); mPlanButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (mPlan == null) { showDialog(DATE_DIALOG_ID); } else if (Utils.IS_ANDROID) { launchPlanView(); } } }); } mAttachPictureButton.setVisibility(View.GONE); setTitle(getString( mTransaction.getId() == 0 ? R.string.menu_create_template : R.string.menu_edit_template) + " (" + getString( mOperationType == MyExpenses.TYPE_TRANSFER ? R.string.transfer : R.string.transaction) + ")"); helpVariant = mOperationType == MyExpenses.TYPE_TRANSFER ? HelpVariant.templateTransfer : HelpVariant.templateCategory; } else if (mTransaction instanceof SplitTransaction) { setTitle(mNewInstance ? R.string.menu_create_split : R.string.menu_edit_split); //SplitTransaction are always instantiated with status uncommitted, //we save them to DB as uncommitted, before working with them //when the split transaction is saved the split and its parts are committed categoryContainer.setVisibility(View.GONE); //add split list if (findSplitPartList() == null) { FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction().add(R.id.OneExpense, SplitPartList.newInstance(mTransaction.getId(), mTransaction.accountId), SPLIT_PART_LIST) .commit(); fm.executePendingTransactions(); } helpVariant = HelpVariant.split; } else { if (mTransaction instanceof SplitPartCategory) { setTitle(mTransaction.getId() == 0 ? R.string.menu_create_split_part_category : R.string.menu_edit_split_part_category); helpVariant = HelpVariant.splitPartCategory; mTransaction.status = STATUS_UNCOMMITTED; } else if (mTransaction instanceof SplitPartTransfer) { setTitle(mTransaction.getId() == 0 ? R.string.menu_create_split_part_transfer : R.string.menu_edit_split_part_transfer); helpVariant = HelpVariant.splitPartTransfer; mTransaction.status = STATUS_UNCOMMITTED; } else { //Transfer or Template, we can suggest to create a plan if (!calendarPermissionPermanentlyDeclined()) { //we set adapter even if spinner is not immediately visible, since it might become visible //after SAVE_AND_NEW action RecurrenceAdapter recurrenceAdapter = new RecurrenceAdapter(this, true); mReccurenceSpinner.setAdapter(recurrenceAdapter); Plan.Recurrence cachedRecurrence = (Plan.Recurrence) getIntent() .getSerializableExtra(KEY_CACHED_RECURRENCE); if (cachedRecurrence != null) { mReccurenceSpinner.setSelection( ((ArrayAdapter) mReccurenceSpinner.getAdapter()).getPosition(cachedRecurrence)); } mReccurenceSpinner.setOnItemSelectedListener(this); findViewById(R.id.PlannerRow).setVisibility(View.VISIBLE); if (mTransaction.originTemplate != null && mTransaction.originTemplate.getPlan() != null) { mReccurenceSpinner.getSpinner().setVisibility(View.GONE); mPlanButton.setVisibility(View.VISIBLE); mPlanButton.setText(Plan.prettyTimeInfo(this, mTransaction.originTemplate.getPlan().rrule, mTransaction.originTemplate.getPlan().dtstart)); mPlanButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { PlanMonthFragment .newInstance(mTransaction.originTemplate.getTitle(), mTransaction.originTemplate.getId(), mTransaction.originTemplate.planId, getCurrentAccount().color, true) .show(getSupportFragmentManager(), TemplatesList.CALDROID_DIALOG_FRAGMENT_TAG); } }); } } if (mTransaction instanceof Transfer) { setTitle(mTransaction.getId() == 0 ? R.string.menu_create_transfer : R.string.menu_edit_transfer); helpVariant = HelpVariant.transfer; } else if (mTransaction instanceof Transaction) { setTitle(mTransaction.getId() == 0 ? R.string.menu_create_transaction : R.string.menu_edit_transaction); helpVariant = HelpVariant.transaction; } } } if (mClone) { setTitle(R.string.menu_clone_transaction); } if (mTransaction instanceof Template || mTransaction instanceof SplitPartCategory || mTransaction instanceof SplitPartTransfer) { findViewById(R.id.DateTimeRow).setVisibility(View.GONE); } else { //noinspection SetTextI18n ((TextView) findViewById(R.id.DateTimeLabel)) .setText(getString(R.string.date) + " / " + getString(R.string.time)); mDateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(DATE_DIALOG_ID); } }); mTimeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(TIME_DIALOG_ID); } }); } //when we have a savedInstance, fields have already been populated if (!mSavedInstance) { populateFields(); } if (!(mTransaction instanceof SplitPartCategory || mTransaction instanceof SplitPartTransfer)) { setDateTime(); } //after setdatetime, so that the plan info can override the date configurePlan(); if (mType == INCOME && mOperationType == MyExpenses.TYPE_TRANSFER) { switchAccountViews(); } setCategoryButton(); if (mOperationType != MyExpenses.TYPE_TRANSFER) { mCategoryButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startSelectCategory(); } }); } }
From source file:org.kontalk.ui.ComposeMessageFragment.java
private AudioFragment getAudioFragment() { AudioFragment fragment = findAudioFragment(); if (fragment == null) { fragment = new AudioFragment(); FragmentManager fm = getActivity().getSupportFragmentManager(); fm.beginTransaction().add(fragment, "audio").commit(); // commit immediately please fm.executePendingTransactions(); }//from www . j av a2 s . c om return fragment; }
From source file:org.mozilla.gecko.BrowserApp.java
private void showBrowserSearch() { if (mBrowserSearch.getUserVisibleHint()) { return;/* www .j a v a 2 s . co m*/ } mBrowserSearchContainer.setVisibility(View.VISIBLE); // Prevent overdraw by hiding the underlying HomePager View. mHomePagerContainer.setVisibility(View.INVISIBLE); final FragmentManager fm = getSupportFragmentManager(); // In certain situations, showBrowserSearch() can be called immediately after hideBrowserSearch() // (see bug 925012). Because of an Android bug (http://code.google.com/p/android/issues/detail?id=61179), // calling FragmentTransaction#add immediately after FragmentTransaction#remove won't add the fragment's // view to the layout. Calling FragmentManager#executePendingTransactions before re-adding the fragment // prevents this issue. fm.executePendingTransactions(); fm.beginTransaction().add(R.id.search_container, mBrowserSearch, BROWSER_SEARCH_TAG) .commitAllowingStateLoss(); mBrowserSearch.setUserVisibleHint(true); // We want to adjust the window size when the keyboard appears to bring the // SearchEngineBar above the keyboard. However, adjusting the window size // when hiding the keyboard results in graphical glitches where the keyboard was // because nothing was being drawn underneath (bug 933422). This can be // prevented drawing content under the keyboard (i.e. in the Window). // // We do this here because there are glitches when unlocking a device with // BrowserSearch in the foreground if we use BrowserSearch.onStart/Stop. getActivity().getWindow().setBackgroundDrawableResource(android.R.color.white); }