List of usage examples for android.support.v4.app DialogFragment setArguments
public void setArguments(Bundle args)
From source file:eu.trentorise.smartcampus.jp.MonitorJourneyFragment.java
@Override protected void setUpTimingControls() { fromTime = (EditText) getView().findViewById(R.id.recur_time_from); toTime = (EditText) getView().findViewById(R.id.recur_time_to); fromDate = (EditText) getView().findViewById(R.id.recur_date_from); toDate = (EditText) getView().findViewById(R.id.recur_date_to); alwaysCheckbox = (CheckBox) getView().findViewById(R.id.always_checkbox); Date newDate = new Date(); if (params.getData().getParameters().getTime() != null) { try {//from w ww .ja va 2s . c o m Date d = Config.FORMAT_TIME_SMARTPLANNER.parse(params.getData().getParameters().getTime()); fromTime.setText(Config.FORMAT_TIME_UI.format(d)); d.setTime(d.getTime() + params.getData().getParameters().getInterval()); toTime.setText(Config.FORMAT_TIME_UI.format(d)); } catch (ParseException e) { } } else { fromTime.setTag(newDate); fromTime.setText(Config.FORMAT_TIME_UI.format(newDate)); // toTime is set to now + intervalhour Calendar cal = Calendar.getInstance(); cal.setTime(newDate); cal.add(Calendar.HOUR_OF_DAY, INTERVALHOUR); Date interval = cal.getTime(); toTime.setTag(interval); toTime.setText(Config.FORMAT_TIME_UI.format(interval)); } Date d = params.getData().getParameters().getFromDate() > 0 ? new Date(params.getData().getParameters().getFromDate()) : newDate; Date today = new Date(); if (d.before(today)) d = today; fromDate.setText(Config.FORMAT_DATE_UI.format(d)); Calendar cal = Calendar.getInstance(); cal.setTime(today); cal.add(Calendar.DATE, INTERVALDAY); newDate = cal.getTime(); d = params.getData().getParameters().getToDate() > 0 ? new Date(params.getData().getParameters().getToDate()) : newDate; if (params.getData().getParameters().getToDate() != Config.ALWAYS_DATE) toDate.setText(Config.FORMAT_DATE_UI.format(d)); else { // mettilo a domani e always mettilo a true alwaysCheckbox.setChecked(true); d = newDate; toDate.setEnabled(false); } fromTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = TimePickerDialogFragment.newInstance((EditText) v); newFragment.setArguments(TimePickerDialogFragment.prepareData(fromTime.getText().toString())); newFragment.show(getSherlockActivity().getSupportFragmentManager(), "timePicker"); } }); toTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = TimePickerDialogFragment.newInstance((EditText) v); newFragment.setArguments(TimePickerDialogFragment.prepareData(toTime.getText().toString())); newFragment.show(getSherlockActivity().getSupportFragmentManager(), "timePicker"); } }); fromDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = DatePickerDialogFragment.newInstance((EditText) v); newFragment.setArguments(DatePickerDialogFragment.prepareData(fromDate.toString())); newFragment.show(getSherlockActivity().getSupportFragmentManager(), "datePicker"); } }); toDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = DatePickerDialogFragment.newInstance((EditText) v); newFragment.setArguments(DatePickerDialogFragment.prepareData(toDate.toString())); newFragment.show(getSherlockActivity().getSupportFragmentManager(), "datePicker"); } }); /* set the toggle buttons */ days.clear(); ToggleButton tmpToggle = (ToggleButton) getView().findViewById(R.id.monday_toggle); days.put(2, tmpToggle); tmpToggle = (ToggleButton) getView().findViewById(R.id.tuesday_toggle); days.put(3, tmpToggle); tmpToggle = (ToggleButton) getView().findViewById(R.id.wednesday_toggle); days.put(4, tmpToggle); tmpToggle = (ToggleButton) getView().findViewById(R.id.thursday_toggle); days.put(5, tmpToggle); tmpToggle = (ToggleButton) getView().findViewById(R.id.friday_toggle); days.put(6, tmpToggle); tmpToggle = (ToggleButton) getView().findViewById(R.id.saturday_toggle); days.put(7, tmpToggle); tmpToggle = (ToggleButton) getView().findViewById(R.id.sunday_toggle); days.put(1, tmpToggle); setToggleDays(params.getData().getParameters().getRecurrence()); }
From source file:org.gnucash.android.ui.transactions.TransactionsListFragment.java
/** * Prepares and displays the dialog for bulk moving transactions to another account *///w w w .ja v a 2 s. c o m protected void showBulkMoveDialog() { FragmentManager manager = getActivity().getSupportFragmentManager(); FragmentTransaction ft = manager.beginTransaction(); Fragment prev = manager.findFragmentByTag("bulk_move_dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment bulkMoveFragment = new BulkMoveDialogFragment(); Bundle args = new Bundle(); args.putLong(ORIGIN_ACCOUNT_ID, mAccountID); long[] selectedIds = new long[mSelectedIds.size()]; int i = 0; for (long l : mSelectedIds.values()) { selectedIds[i++] = l; } args.putLongArray(SELECTED_TRANSACTION_IDS, selectedIds); bulkMoveFragment.setArguments(args); bulkMoveFragment.show(ft, "bulk_move_dialog"); }
From source file:com.fullmeadalchemist.mustwatch.ui.batch.form.BatchFormFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (viewModel.batch != null) { // We're in "edit" mode, so set the title accordingly FORM_MODE = MODES.EDIT;/*from w ww. ja v a 2 s .c om*/ TextView formTitle = getActivity().findViewById(R.id.batchFormTitleTV); if (formTitle != null) { String title = getResources().getString(R.string.edit_batch_title); title = String.format(title, viewModel.batch.id); formTitle.setText(title); } } else { FORM_MODE = MODES.CREATE; } updateUiDateTime(); TextView dateField = getActivity().findViewById(R.id.createDateDate); if (dateField != null) { dateField.setOnClickListener(v -> { Timber.i("Date was clicked!"); DialogFragment newFragment = new DatePickerFragment(); Bundle args = new Bundle(); args.putInt(YEAR, viewModel.batch.createDate.get(Calendar.YEAR)); args.putInt(MONTH, viewModel.batch.createDate.get(Calendar.MONTH)); args.putInt(DAY_OF_MONTH, viewModel.batch.createDate.get(Calendar.DAY_OF_MONTH)); newFragment.setArguments(args); newFragment.setTargetFragment(this, DATE_REQUEST_CODE); newFragment.show(getActivity().getSupportFragmentManager(), "datePicker"); }); } TextView timeField = getActivity().findViewById(R.id.createDateTime); if (timeField != null) { timeField.setOnClickListener(v -> { Timber.i("Time was clicked!"); DialogFragment newFragment = new TimePickerFragment(); Bundle args = new Bundle(); args.putInt(HOUR, viewModel.batch.createDate.get(Calendar.HOUR)); args.putInt(MINUTE, viewModel.batch.createDate.get(Calendar.MINUTE)); newFragment.setArguments(args); newFragment.setTargetFragment(this, TIME_REQUEST_CODE); newFragment.show(getActivity().getSupportFragmentManager(), "timePicker"); }); } Button addSugarButton = getActivity().findViewById(R.id.add_sugar_button); if (addSugarButton != null) { addSugarButton.setOnClickListener(v -> { Timber.i("addSugarButton was clicked!"); DialogFragment newFragment = new AddIngredientDialog(); Bundle args = new Bundle(); args.putString(INGREDIENT_TYPE, SUGAR.toString()); newFragment.setArguments(args); newFragment.setTargetFragment(this, INGREDIENT_REQUEST_CODE); newFragment.show(getActivity().getSupportFragmentManager(), "sugarPicker"); }); } Button addNutrientButton = getActivity().findViewById(R.id.add_nutrient_button); if (addNutrientButton != null) { addNutrientButton.setOnClickListener(v -> { Timber.i("addNutrientButton was clicked!"); DialogFragment newFragment = new AddIngredientDialog(); Bundle args = new Bundle(); args.putString(INGREDIENT_TYPE, NUTRIENT.toString()); newFragment.setArguments(args); newFragment.setTargetFragment(this, INGREDIENT_REQUEST_CODE); newFragment.show(getActivity().getSupportFragmentManager(), "nutrientPicker"); }); } Button addYeastButton = getActivity().findViewById(R.id.add_yeast_button); if (addYeastButton != null) { addYeastButton.setOnClickListener(v -> { Timber.i("addYeastButton was clicked!"); DialogFragment newFragment = new AddIngredientDialog(); Bundle args = new Bundle(); args.putString(INGREDIENT_TYPE, YEAST.toString()); newFragment.setArguments(args); newFragment.setTargetFragment(this, INGREDIENT_REQUEST_CODE); newFragment.show(getActivity().getSupportFragmentManager(), "yeastPicker"); }); } Button addStabilizerButton = getActivity().findViewById(R.id.add_stabilizer_button); if (addStabilizerButton != null) { addStabilizerButton.setOnClickListener(v -> { Timber.i("addStabilizerButton was clicked!"); DialogFragment newFragment = new AddIngredientDialog(); Bundle args = new Bundle(); args.putString(INGREDIENT_TYPE, STABILIZER.toString()); newFragment.setArguments(args); newFragment.setTargetFragment(this, INGREDIENT_REQUEST_CODE); newFragment.show(getActivity().getSupportFragmentManager(), "stabilizerPicker"); }); } LocalBroadcastManager.getInstance(getActivity()).registerReceiver(datePickerMessageReceiver, new IntentFilter(DATE_SET_EVENT)); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(timePickerMessageReceiver, new IntentFilter(TIME_SET_EVENT)); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(ingredientPickerMessageReceiver, new IntentFilter(INGREDIENT_SET_EVENT)); Button submitButton = getActivity().findViewById(R.id.button_submit); if (submitButton != null) { submitButton.setOnClickListener(v -> { Timber.i("Submit button clicked!"); FORM_MODE = (viewModel.batch.id == null) ? MODES.CREATE : MODES.EDIT; viewModel.batch.name = dataBinding.name.getText().toString().trim(); viewModel.batch.targetSgStarting = toDouble( dataBinding.targetSgStarting.getText().toString().trim()); viewModel.batch.targetSgFinal = toDouble(dataBinding.targetSgFinal.getText().toString().trim()); viewModel.batch.targetABV = toFloat(dataBinding.targetABV.getText().toString().trim()); viewModel.batch.startingPh = toFloat(dataBinding.startingPh.getText().toString().trim()); viewModel.batch.startingTemp = toFloat(dataBinding.startingTemp.getText().toString().trim()); viewModel.batch.outputVolume = toVolume(dataBinding.outputVolumeAmount.getText().toString(), abbreviationMap.get(dataBinding.outputVolumeAmountUnit.getSelectedItem().toString())); viewModel.batch.status = BatchStatusEnum.fromString(dataBinding.status.getText().toString().trim()); viewModel.batch.notes = dataBinding.notes.getText().toString().trim(); if (FORM_MODE == MODES.CREATE) { Timber.d("We are in CREATE mode."); Timber.d("Current batch state:\n%s", viewModel.batch.toString()); viewModel.saveNewBatch().observe(this, savedBatchId -> { if (savedBatchId != null) { Timber.i("Successfully saved Batch, which now has ID=%s", savedBatchId); LocalBroadcastManager.getInstance(getActivity()) .unregisterReceiver(datePickerMessageReceiver); LocalBroadcastManager.getInstance(getActivity()) .unregisterReceiver(timePickerMessageReceiver); LocalBroadcastManager.getInstance(getActivity()) .unregisterReceiver(ingredientPickerMessageReceiver); Snackbar snackbar = Snackbar.make(getActivity().findViewById(R.id.container), "Saved batch!", Snackbar.LENGTH_LONG); snackbar.show(); Answers.getInstance().logCustom(new CustomEvent("Batch create success")); navigationController.navigateFromAddBatch(savedBatchId); } else { Answers.getInstance().logCustom(new CustomEvent("Batch create failed")); Snackbar snackbar = Snackbar.make(getActivity().findViewById(R.id.container), "Failed to save batch!", Snackbar.LENGTH_LONG); snackbar.show(); } }); } else { Timber.d("We are in EDIT mode for batch #%s", viewModel.batch.id); Timber.d("Current batch state:\n%s", viewModel.batch.toString()); viewModel.updateBatch(); LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(datePickerMessageReceiver); LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(timePickerMessageReceiver); LocalBroadcastManager.getInstance(getActivity()) .unregisterReceiver(ingredientPickerMessageReceiver); Snackbar snackbar = Snackbar.make(getActivity().findViewById(R.id.container), "Updated batch!", Snackbar.LENGTH_LONG); snackbar.show(); Answers.getInstance().logCustom(new CustomEvent("Batch edit success")); navigationController.navigateFromEditBatch(viewModel.batch.id); } }); } else { Timber.e("Cannot find submit button in view"); } }
From source file:de.eidottermihi.rpicheck.activity.CustomCommandActivity.java
private void parseNonPromptingAndShow(String keyPassphrase, CommandBean command) { final DialogFragment runCommandDialog = new RunCommandDialog(); final Bundle args = new Bundle(); String cmdString = command.getCommand(); Map<String, String> nonPromptingPlaceholders = parseNonPromptingPlaceholders(command.getCommand(), currentDevice);//w w w. j ava2s .c o m for (Map.Entry<String, String> entry : nonPromptingPlaceholders.entrySet()) { cmdString = cmdString.replace(entry.getKey(), entry.getValue()); } command.setCommand(cmdString); args.putSerializable("pi", currentDevice); args.putSerializable("cmd", command); if (keyPassphrase != null) { args.putString("passphrase", keyPassphrase); } runCommandDialog.setArguments(args); runCommandDialog.show(getSupportFragmentManager(), "runCommand"); }
From source file:org.mariotaku.twidere.fragment.MessagesConversationFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.delete_all: { final ParcelableCredentials account = mAccount; if (account == null || mRecipient == null) return true; Bundle args = new Bundle(); args.putParcelable(EXTRA_ACCOUNT, account); args.putParcelable(EXTRA_USER, mRecipient); DialogFragment df = new DeleteConversationConfirmDialogFragment(); df.setArguments(args); df.show(getFragmentManager(), "delete_conversation_confirm"); return true; }/* www .j av a 2s . c o m*/ } return super.onOptionsItemSelected(item); }
From source file:co.uk.socialticker.ticker.TickerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // action with ID action_refresh was selected /*case R.id.settings: openSettings();/* w w w . j av a 2 s . c om*/ break; case R.id.twitter: startActivity(new Intent(this,TwitterActivity.class)); break;*/ case R.id.menu_twitter_update: DialogFragment newFragment = new TwitterUpdateDialogFragment(); Bundle args = new Bundle(); newFragment.setArguments(args); newFragment.show(getSupportFragmentManager(), "sendTweet"); break; case R.id.menu_twitter_logout: logoutFromTwitter(); break; default: break; } return true; }
From source file:de.eidottermihi.rpicheck.activity.MainActivity.java
private void doRebootOrHalt(String type) { LOGGER.info("Doing {} on {}...", type, currentDevice.getName()); ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { // get connection settings from shared preferences final String host = currentDevice.getHost(); final String user = currentDevice.getUser(); final String port = currentDevice.getPort() + ""; final String sudoPass = currentDevice.getSudoPass(); if (currentDevice.getAuthMethod().equals(NewRaspiAuthActivity.SPINNER_AUTH_METHODS[0])) { // ssh password final String pass = currentDevice.getPass(); new SSHShutdownTask(this).execute(host, user, pass, port, sudoPass, type, null, null); } else if (currentDevice.getAuthMethod().equals(NewRaspiAuthActivity.SPINNER_AUTH_METHODS[1])) { // keyfile final String keyfilePath = currentDevice.getKeyfilePath(); if (keyfilePath != null) { final File privateKey = new File(keyfilePath); if (privateKey.exists()) { new SSHShutdownTask(this).execute(host, user, null, port, sudoPass, type, keyfilePath, null);/*from w ww . j a v a2 s . com*/ } else { Toast.makeText(this, "Cannot find keyfile at location: " + keyfilePath, Toast.LENGTH_LONG); } } else { Toast.makeText(this, "No keyfile specified!", Toast.LENGTH_LONG); } } else if (currentDevice.getAuthMethod().equals(NewRaspiAuthActivity.SPINNER_AUTH_METHODS[2])) { // keyfile and passphrase final String keyfilePath = currentDevice.getKeyfilePath(); if (keyfilePath != null) { final File privateKey = new File(keyfilePath); if (privateKey.exists()) { if (!Strings.isNullOrEmpty(currentDevice.getKeyfilePass())) { final String passphrase = currentDevice.getKeyfilePass(); new SSHShutdownTask(this).execute(host, user, null, port, sudoPass, type, keyfilePath, passphrase); } else { final String dialogType = type.equals(Constants.TYPE_REBOOT) ? PassphraseDialog.SSH_SHUTDOWN : PassphraseDialog.SSH_HALT; final DialogFragment passphraseDialog = new PassphraseDialog(); final Bundle args = new Bundle(); args.putString(PassphraseDialog.KEY_TYPE, dialogType); passphraseDialog.setArguments(args); passphraseDialog.setCancelable(false); passphraseDialog.show(getSupportFragmentManager(), "passphrase"); } } else { Toast.makeText(this, "Cannot find keyfile at location: " + keyfilePath, Toast.LENGTH_LONG); } } else { Toast.makeText(this, "No keyfile specified!", Toast.LENGTH_LONG); } } } else { Toast.makeText(this, R.string.no_connection, Toast.LENGTH_SHORT).show(); } }
From source file:com.bonsai.wallet32.SendBitcoinActivity.java
private DialogFragment showSendConfirmDialog(int acctId, String acctStr, String addrStr, long amount, long fee, double rate) { DialogFragment df = new SendConfirmDialogFragment(); Bundle args = new Bundle(); args.putInt("acctId", acctId); args.putString("acctStr", acctStr); args.putString("addr", addrStr); args.putLong("amount", amount); args.putLong("fee", fee); args.putDouble("rate", rate); df.setArguments(args); df.show(getSupportFragmentManager(), "sendconfirm"); return df;/*w w w . j a v a 2 s. c o m*/ }
From source file:com.bonsai.wallet32.SendBitcoinActivity.java
private DialogFragment showFeeAdjustDialog(String msg, int acctId, String acctStr, String addrStr, long amount, long fee, double rate) { DialogFragment df = new FeeAdjustDialogFragment(); Bundle args = new Bundle(); args.putString("msg", msg); args.putInt("acctId", acctId); args.putString("acctStr", acctStr); args.putString("addr", addrStr); args.putLong("amount", amount); args.putLong("fee", fee); args.putDouble("rate", rate); df.setArguments(args); df.show(getSupportFragmentManager(), "sendconfirm"); return df;/* w w w .j av a 2 s. c om*/ }
From source file:de.eidottermihi.rpicheck.activity.MainActivity.java
private void doQuery(boolean initByPullToRefresh) { if (currentDevice == null) { // no device available, show hint for user Toast.makeText(this, R.string.no_device_available, Toast.LENGTH_LONG).show(); // stop refresh animation from pull-to-refresh swipeRefreshLayout.setRefreshing(false); return;// www.ja va2s .c o m } ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { // get connection settings from shared preferences String host = currentDevice.getHost(); String user = currentDevice.getUser(); String port = currentDevice.getPort() + ""; String pass = null; // reading process preference final Boolean hideRoot = sharedPrefs.getBoolean(SettingsActivity.KEY_PREF_QUERY_HIDE_ROOT_PROCESSES, true); String keyPath = null; String keyPass = null; boolean canConnect = false; // check authentification method final String authMethod = currentDevice.getAuthMethod(); if (authMethod.equals(NewRaspiAuthActivity.SPINNER_AUTH_METHODS[0])) { // only ssh password pass = currentDevice.getPass(); if (pass != null) { canConnect = true; } else { Toast.makeText(this, R.string.no_password_specified, Toast.LENGTH_LONG).show(); } } else if (authMethod.equals(NewRaspiAuthActivity.SPINNER_AUTH_METHODS[1])) { // keyfile must be present final String keyfilePath = currentDevice.getKeyfilePath(); if (keyfilePath != null) { final File privateKey = new File(keyfilePath); if (privateKey.exists()) { keyPath = keyfilePath; canConnect = true; } else { Toast.makeText(this, "Cannot find keyfile at location: " + keyfilePath, Toast.LENGTH_LONG) .show(); } } else { Toast.makeText(this, "No keyfile specified!", Toast.LENGTH_LONG).show(); } } else if (authMethod.equals(NewRaspiAuthActivity.SPINNER_AUTH_METHODS[2])) { // keyfile and keypass must be present final String keyfilePath = currentDevice.getKeyfilePath(); if (keyfilePath != null) { final File privateKey = new File(keyfilePath); if (privateKey.exists()) { keyPath = keyfilePath; final String keyfilePass = currentDevice.getKeyfilePass(); if (keyfilePass != null) { canConnect = true; keyPass = keyfilePass; } else { final DialogFragment newFragment = new PassphraseDialog(); final Bundle args = new Bundle(); args.putString(PassphraseDialog.KEY_TYPE, PassphraseDialog.SSH_QUERY); newFragment.setArguments(args); newFragment.setCancelable(false); newFragment.show(getSupportFragmentManager(), "passphrase"); canConnect = false; } } else { Toast.makeText(this, "Cannot find keyfile at location: " + keyfilePath, Toast.LENGTH_LONG) .show(); } } else { Toast.makeText(this, "No keyfile specified!", Toast.LENGTH_LONG).show(); } } if (host == null) { Toast.makeText(this, R.string.no_hostname_specified, Toast.LENGTH_LONG).show(); canConnect = false; } else if (user == null) { Toast.makeText(this, R.string.no_username_specified, Toast.LENGTH_LONG).show(); canConnect = false; } if (canConnect) { // disable pullToRefresh (if refresh initiated by action bar) if (!initByPullToRefresh) { // show hint for pull-to-refresh this.showPullToRefreshHint(); } // execute query new SSHQueryTask(this, getLoadAveragePreference()).execute(host, user, pass, port, hideRoot.toString(), keyPath, keyPass); } } else { Toast.makeText(this, R.string.no_connection, Toast.LENGTH_SHORT).show(); // stop refresh animation from pull-to-refresh swipeRefreshLayout.setRefreshing(false); } }