List of usage examples for android.support.v4.app DialogFragment show
public int show(FragmentTransaction transaction, String tag)
From source file:name.gumartinm.weather.information.activity.MainTabsActivity.java
@Override public void onResume() { super.onResume(); final SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences(this.getApplicationContext()); final String APPID = sharedPreferences.getString(this.getString(R.string.weather_preferences_app_id_key), "");/*w ww.j av a2 s .c o m*/ final String noticeKeyPreference = this.getString(R.string.api_id_key_notice_preference_key); final boolean notice = sharedPreferences.getBoolean(noticeKeyPreference, true); if (notice && APPID.isEmpty()) { final FragmentManager fm = this.getSupportFragmentManager(); final Fragment buttonsFragment = fm.findFragmentByTag("noticeDialog"); if (buttonsFragment == null) { final DialogFragment newFragment = APIKeyNoticeDialogFragment .newInstance(R.string.api_id_key_notice_title); newFragment.setRetainInstance(true); newFragment.setCancelable(false); newFragment.show(fm, "noticeDialog"); } } final ActionBar actionBar = this.getActionBar(); // 1. Update title. final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); if (weatherLocation != null) { final String[] array = new String[2]; array[0] = weatherLocation.getCity(); array[1] = weatherLocation.getCountry(); final MessageFormat message = new MessageFormat("{0},{1}", Locale.US); final String cityCountry = message.format(array); actionBar.setTitle(cityCountry); } else { actionBar.setTitle(this.getString(R.string.text_field_no_chosen_location)); } // 2. Update forecast tab text. final String keyPreference = this.getString(R.string.weather_preferences_day_forecast_key); final String value = sharedPreferences.getString(keyPreference, ""); String humanValue = ""; if (value.equals(this.getString(R.string.weather_preferences_day_forecast_five_day))) { humanValue = this.getString(R.string.text_tab_five_days_forecast); } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_ten_day))) { humanValue = this.getString(R.string.text_tab_ten_days_forecast); } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_fourteen_day))) { humanValue = this.getString(R.string.text_tab_fourteen_days_forecast); } actionBar.getTabAt(1).setText(humanValue); }
From source file:biz.easymenu.easymenung.TableListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.menupager, container, false); ((TextView) v.findViewById(R.id.menuTitle)).setText(R.string.tableList); GridView gridview = (GridView) v.findViewById(R.id.gridview); adapter = new ItemAdapter(getActivity()); gridview.setAdapter(adapter);/* w ww . j ava2 s . co m*/ gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { //Toast.makeText(context, "" + position, Toast.LENGTH_SHORT).show(); FragmentManager fm = getActivity().getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); DialogFragment f = new LoginFragment(adapter.itemsList.get(position)); Fragment prev = fm.findFragmentByTag("loginDialog"); if (prev != null) { ft.remove(prev); ft.commit(); } f.show(ft, "loginDialog"); /*DEMO Locale pLocale = new Locale("it"); Resources res = getActivity().getBaseContext().getResources(); DisplayMetrics dm = getActivity().getBaseContext().getResources().getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = pLocale; res.updateConfiguration(conf, dm); getActivity().finish(); startActivity(getActivity().getIntent()); END DEMO */ } }); return v; }
From source file:com.example.android.pantry.scanner.BarcodeScannerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { case R.id.menu_flash: mFlash = !mFlash;/* ww w . j a v a2s. c o m*/ if (mFlash) { item.setTitle(R.string.flash_on); } else { item.setTitle(R.string.flash_off); } mScannerView.setFlash(mFlash); return true; case R.id.menu_auto_focus: mAutoFocus = !mAutoFocus; if (mAutoFocus) { item.setTitle(R.string.auto_focus_on); } else { item.setTitle(R.string.auto_focus_off); } mScannerView.setAutoFocus(mAutoFocus); return true; case R.id.menu_formats: DialogFragment fragment = FormatSelectorDialogFragment.newInstance(this, mSelectedIndices); fragment.show(getSupportFragmentManager(), "format_selector"); return true; case R.id.menu_camera_selector: mScannerView.stopCamera(); DialogFragment cFragment = CameraSelectorDialogFragment.newInstance(this, mCameraId); cFragment.show(getSupportFragmentManager(), "camera_selector"); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.darshancomputing.BatteryIndicator.CurrentInfoFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: mStartActivity(SettingsActivity.class); return true; case R.id.menu_close: DialogFragment df = new ConfirmCloseDialogFragment(); df.show(getFragmentManager(), "TODO: What is this string for?2"); return true; case R.id.menu_help: mStartActivity(HelpActivity.class); return true; case R.id.menu_show_notification: toggleShowNotification();/* w w w.j a va 2 s. c om*/ return true; case R.id.menu_rate_and_review: try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.darshancomputing.BatteryIndicator"))); } catch (Exception e) { Toast.makeText(activity.getApplicationContext(), "Sorry, can't launch Market!", Toast.LENGTH_SHORT) .show(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.iutiao.sdk.fragments.BaseFragment.java
public void showDialog(DialogFragment dialog) { dialog.setTargetFragment(this, DIALOG_FRAGMENT); FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment frag = getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG); if (frag != null) { ft.remove(frag);/* w w w . j a v a 2 s .c o m*/ Log.i("BaseFragment", "prev fragment " + frag + " will be dismissed"); ((DialogFragment) frag).dismiss(); } // ft.addToBackStack(null); dialog.show(ft, DIALOG_FRAGMENT_TAG); }
From source file:com.m2dl.mini_projet.mini_projet_android.MainActivity.java
@Override public boolean onMarkerClick(Marker marker) { mMap.moveCamera(CameraUpdateFactory.newLatLng(marker.getPosition())); Photo myPhoto = myPhotoMarkers.get(marker); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Fragment prev = getSupportFragmentManager().findFragmentByTag("dialogMarker"); if (prev != null) { ft.remove(prev);//from w ww.j ava 2s . c om } ft.addToBackStack(null); DialogFragment newFragment = MarkerDialogFragment.newInstance(myPhoto); newFragment.show(ft, "dialogMarker"); return true; }
From source file:com.mattprecious.notisync.profile.PrimaryCustomProfileActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed();/*from w w w. j a va 2 s.co m*/ return true; case R.id.menu_save: validate(); if (errorFlags > 0) { Crouton.showText(this, R.string.custom_profile_fix_errors, Style.ALERT); } else { if (save()) { boolean pushProfile = getPreferences(MODE_PRIVATE).getBoolean(PREFERENCES_KEY_PUSH_PROFILE, true); if (pushProfile && profile.getId() == 0) { SherlockDialogFragment dialogFragment = new PushConfirmDialogFragment(); dialogFragment.show(getSupportFragmentManager(), null); } else { finishOk(); } } else { Crouton.showText(this, R.string.custom_profile_error, Style.ALERT); } } return true; case R.id.menu_discard: setResult(RESULT_CANCELED); finish(); return true; case R.id.menu_delete: if (delete()) { setResult(MainActivity.RESULT_CODE_PROFILE_DELETED, getIntent()); finish(); } else { Crouton.showText(this, R.string.custom_profile_error, Style.ALERT); } return true; case R.id.menu_push: // TODO: remove duplication validate(); if (errorFlags > 0) { Crouton.showText(this, R.string.custom_profile_fix_errors, Style.ALERT); } else { if (save()) { pushProfile(); finishOk(); } else { Crouton.showText(this, R.string.custom_profile_error, Style.ALERT); } } return true; case R.id.menu_help: DialogFragment helpFragment = new CustomHelpDialogFragment(); helpFragment.show(getSupportFragmentManager(), null); return true; } return super.onOptionsItemSelected(item); }
From source file:com.example.android.pantry.scanner.BarcodeScannerActivity.java
private void buildInventoryItemAndShowMessageDialog(String productInfo, Product product, long productId) { String quantityString = ""; InventoryItem item = null;/*from w ww . j a va 2 s . c o m*/ if (product != null) { item = InventoryTable.getInventoryItemByProductId(mDb, productId); String quantity = "0"; if (item != null) { quantity = String.valueOf(item.getQuantity()); } else { // TODO: how to enter initial value for location and expiration date?? // if known product, create new inventory item and fill entries if (product.isKnownProduct()) { Log.v(TAG, "productid: " + product.getProductId() + ", brand: " + product.getBrand() + ", name: " + product.getBrand()); item = new InventoryItem(0, "new", 0, 0, 0, 0, product); } // id, location, quantity, expiration date, purchase date, price, product } quantityString = "\nYou have = " + quantity + " of it."; // save a copy for inventory update mLastInventoryItem = item; } // mDb handle kept open after network search // the mDb handle will be close as part of message dialog String locations[] = LocationsTable.getAllLocations(mDb); String message = "Barcode = " + mLastBarcodeValue + " (" + mLastBarcodeType + ")" + "\nProduct = " + productInfo + " " + quantityString; DialogFragment fragment = MessageDialogFragment.newInstance("Scan Results", message, locations, item, this); fragment.show(getSupportFragmentManager(), "search_request"); }
From source file:in.ac.iiitd.esya.HomeScreenActivity.java
public void eventDialog(String eventName) { eventName = "event_dialog_" + eventName; int layoutId = getResources().getIdentifier(eventName, "layout", HomeScreenActivity.PACKAGE_NAME); FragmentManager fm = getSupportFragmentManager(); DialogFragment newFragment = new EventDialog(layoutId); newFragment.show(fm, "EventDialog"); }
From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java
private void showCategoryDeleteDialog() { DialogFragment dialog = new CategoryDeleteDialog(); dialog.setTargetFragment(CategoryListFragment.this, CATEGORY_DELETE_DIALOG_REQUEST); dialog.show(getActivity().getSupportFragmentManager(), null); }