Example usage for android.support.v4.app DialogFragment setArguments

List of usage examples for android.support.v4.app DialogFragment setArguments

Introduction

In this page you can find the example usage for android.support.v4.app DialogFragment setArguments.

Prototype

public void setArguments(Bundle args) 

Source Link

Document

Supply the construction arguments for this fragment.

Usage

From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.MyHealthHubGlassMainActivity.java

private void openSelectSensorType(Bundle extras, String sensorType, String[] names) {
    DialogFragment deviceDialog = new SelectDeviceDialogFragment();
    extras.putInt("position", 0);
    extras.putBoolean("device", false);
    extras.putString("sensorType", sensorType);
    extras.putStringArray("names", names);
    deviceDialog.setArguments(extras);
    getFragmentManager().beginTransaction();
    deviceDialog.show(getSupportFragmentManager().beginTransaction(), "deviceDialog");
}

From source file:org.mariotaku.twidere.activity.UserListSelectorActivity.java

@Override
public void onClick(final View v) {
    switch (v.getId()) {
    case R.id.screen_name_confirm: {
        final String screen_name = ParseUtils.parseString(mEditScreenName.getText());
        if (isEmpty(screen_name))
            return;
        searchUser(screen_name);/*from w  w  w  .  jav a2  s  .c  o m*/
        break;
    }
    case R.id.create_list: {
        final DialogFragment f = new CreateUserListDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_ACCOUNT_KEY, getAccountKey());
        f.setArguments(args);
        f.show(getSupportFragmentManager(), null);
        break;
    }
    }
}

From source file:com.google.android.gms.samples.plus.SignInActivity.java

@Override
public void onConnectionFailed(ConnectionResult status) {
    resetAccountState();/*from w w  w  .  j a  v a 2 s . c o m*/
    if (mConnectionProgressDialog.isShowing()) {
        // The user clicked the button already and we are showing a spinner
        // progress dialog. We dismiss the progress dialog and start to
        // resolve connection errors.
        mConnectionProgressDialog.dismiss();

        if (status.hasResolution()) {
            try {
                status.startResolutionForResult(this, REQUEST_CODE_RESOLVE_FAILURE);
            } catch (SendIntentException e) {
                mPlusClient.connect();
            }
        }
    }

    // Save the intent so that we can start an activity when the user clicks
    // the button.
    mStatus = status;

    FragmentManager fragmentManager = getSupportFragmentManager();
    if (!status.hasResolution() && GooglePlayServicesUtil.isUserRecoverableError(status.getErrorCode())
            && fragmentManager.findFragmentByTag(TAG_ERROR_DIALOG_FRAGMENT) == null) {
        DialogFragment fragment = new GooglePlayServicesErrorDialogFragment();
        Bundle args = new Bundle();
        args.putInt(GooglePlayServicesErrorDialogFragment.ARG_ERROR_CODE, status.getErrorCode());
        args.putInt(GooglePlayServicesErrorDialogFragment.ARG_REQUEST_CODE, REQUEST_CODE_RESOLVE_MISSING_GP);
        fragment.setArguments(args);
        fragment.show(fragmentManager, TAG_ERROR_DIALOG_FRAGMENT);
    }
}

From source file:com.github.yuukis.businessmap.app.ContactsTaskFragment.java

private void showProgress() {
    String title = getString(R.string.title_geocoding);
    String message = getString(R.string.message_geocoding);
    int max = mGeocodingResultCache.size();

    Bundle args = new Bundle();
    args.putString(ProgressDialogFragment.TITLE, title);
    args.putString(ProgressDialogFragment.MESSAGE, message);
    args.putBoolean(ProgressDialogFragment.CANCELABLE, true);
    args.putInt(ProgressDialogFragment.MAX, max);
    final DialogFragment dialog = ProgressDialogFragment.newInstance();
    dialog.setArguments(args);
    if (getActivity() != null) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override//from  ww  w . j  a  va  2s  .  c  o  m
            public void run() {
                dialog.show(getActivity().getSupportFragmentManager(), ProgressDialogFragment.TAG);
            }
        });
    }
}

From source file:net.naonedbus.fragment.impl.ItineraireFragment.java

@Override
public void onListItemClick(final ListView l, final View v, final int position, final long id) {
    super.onListItemClick(l, v, position, id);

    final Bundle bundle = new Bundle();
    bundle.putString(ItineraryDetailFragment.PARAM_ITINERARY_FROM, mFromAddressTextView.getText().toString());
    bundle.putString(ItineraryDetailFragment.PARAM_ITINERARY_TO, mToAddressTextView.getText().toString());
    bundle.putParcelable(ItineraryDetailFragment.PARAM_ITINERARY_WRAPPER, mItineraryWrappers.get(position));

    final DialogFragment dialogFragment = new ItineraryDetailDialogFragment();
    dialogFragment.setArguments(bundle);
    dialogFragment.show(getChildFragmentManager(), "ItineraryDetails");
}

From source file:com.fullmeadalchemist.mustwatch.ui.log.form.LogFormFragment.java

private void initClickListeners() {
    TextView dateField = getActivity().findViewById(R.id.createDateDate);
    if (dateField != null) {
        dateField.setOnClickListener(v -> {
            Log.i(TAG, "Date was clicked!");
            DialogFragment newFragment = new DatePickerFragment();
            Bundle args = new Bundle();
            args.putInt(YEAR, viewModel.logEntry.entryDate.get(Calendar.YEAR));
            args.putInt(MONTH, viewModel.logEntry.entryDate.get(Calendar.MONTH));
            args.putInt(DAY_OF_MONTH, viewModel.logEntry.entryDate.get(Calendar.DAY_OF_MONTH));
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, DATE_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "datePicker");
        });/*w w  w .  j  a  v a2  s  .  c  om*/
    }

    TextView timeField = getActivity().findViewById(R.id.createDateTime);
    if (timeField != null) {
        timeField.setOnClickListener(v -> {
            Log.i(TAG, "Time was clicked!");
            DialogFragment newFragment = new TimePickerFragment();
            Bundle args = new Bundle();
            args.putInt(HOUR, viewModel.logEntry.entryDate.get(Calendar.HOUR));
            args.putInt(MINUTE, viewModel.logEntry.entryDate.get(Calendar.MINUTE));
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, TIME_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "timePicker");
        });
    }

    Button submitButton = getActivity().findViewById(R.id.button_submit);
    if (submitButton != null) {
        submitButton.setOnClickListener(v -> {
            Log.i(TAG, "Submit button clicked!");

            TextView phTv = getActivity().findViewById(R.id.ph);
            if (phTv != null) {
                viewModel.logEntry.acidity = toFloat(phTv.getText().toString().trim());
            }

            TextView sgTv = getActivity().findViewById(R.id.sg);
            if (sgTv != null) {
                viewModel.logEntry.sg = toFloat(sgTv.getText().toString().trim());
            }

            TextView noteTv = getActivity().findViewById(R.id.notes);
            if (noteTv != null) {
                viewModel.logEntry.note = noteTv.getText().toString().trim();
            }

            viewModel.saveNewLogEntry();
            navigationController.navigateToBatchDetail(this.batchId);
        });
    }
}

From source file:de.vanita5.twittnuker.activity.support.DataImportActivity.java

public void showImportTypeDialog(final String path, final Integer flags) {
    final DialogFragment df = new DataExportImportTypeSelectorDialogFragment();
    final Bundle args = new Bundle();
    args.putString(EXTRA_PATH, path);/* w  w  w . j av a 2  s  . co  m*/
    args.putString(EXTRA_TITLE, getString(R.string.export_settings_type_dialog_title));
    if (flags != null) {
        args.putInt(EXTRA_FLAGS, flags);
    } else {
        args.putInt(EXTRA_FLAGS, 0);
    }
    df.setArguments(args);
    df.show(getSupportFragmentManager(), "select_import_type");
}

From source file:de.eidottermihi.rpicheck.activity.CustomCommandActivity.java

private void runCommand(long commandId) {
    ConnectivityManager connMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isConnected()) {
        if (currentDevice.getAuthMethod().equals(NewRaspiAuthActivity.SPINNER_AUTH_METHODS[2])
                && Strings.isNullOrEmpty(currentDevice.getKeyfilePass())) {
            // must ask for key passphrase first
            LOGGER.debug("Asking for key passphrase.");
            // dirty hack, saving commandId as "dialog type"
            final String dialogType = commandId + "";
            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 {//from   w w  w.  j  a v a  2 s  .c o  m
            LOGGER.debug("Opening command dialog.");
            openCommandDialog(commandId, currentDevice.getKeyfilePass());
        }
    } else {
        Toast.makeText(this, R.string.no_connection, Toast.LENGTH_SHORT).show();
    }
}

From source file:org.klnusbaum.udj.PlayerListFragment.java

private void handlePlayerJoinFail() {
    PlayerJoinError joinError = PlayerJoinError.valueOf(am.getUserData(account, Constants.PLAYER_JOIN_ERROR));
    am.setUserData(account, Constants.PLAYER_STATE_DATA, String.valueOf(Constants.NOT_IN_PLAYER));
    DialogFragment newFrag = new PlayerJoinFailDialog();
    Bundle args = new Bundle();
    args.putInt(Constants.PLAYER_JOIN_ERROR_EXTRA, joinError.ordinal());
    newFrag.setArguments(args);
    newFrag.show(getActivity().getSupportFragmentManager(), PLAYER_JOIN_FAIL_TAG);
}

From source file:org.mariotaku.twidere.fragment.UserListFragment.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    final AsyncTwitterWrapper twitter = mTwitterWrapper;
    final ParcelableUserList userList = mUserList;
    if (twitter == null || userList == null)
        return false;
    switch (item.getItemId()) {
    case R.id.add: {
        if (!userList.user_key.equals(userList.account_key))
            return false;
        final Intent intent = new Intent(INTENT_ACTION_SELECT_USER);
        intent.setClass(getActivity(), UserListSelectorActivity.class);
        intent.putExtra(EXTRA_ACCOUNT_KEY, userList.account_key);
        startActivityForResult(intent, REQUEST_SELECT_USER);
        break;//from   w  w  w  .j av  a2  s.  co m
    }
    case R.id.delete: {
        if (!userList.user_key.equals(userList.account_key))
            return false;
        DestroyUserListDialogFragment.show(getFragmentManager(), userList);
        break;
    }
    case R.id.edit: {
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_ACCOUNT_KEY, userList.account_key);
        args.putString(EXTRA_LIST_NAME, userList.name);
        args.putString(EXTRA_DESCRIPTION, userList.description);
        args.putBoolean(EXTRA_IS_PUBLIC, userList.is_public);
        args.putString(EXTRA_LIST_ID, userList.id);
        final DialogFragment f = new EditUserListDialogFragment();
        f.setArguments(args);
        f.show(getFragmentManager(), "edit_user_list_details");
        return true;
    }
    case R.id.follow: {
        if (userList.is_following) {
            DestroyUserListSubscriptionDialogFragment.show(getFragmentManager(), userList);
        } else {
            twitter.createUserListSubscriptionAsync(userList.account_key, userList.id);
        }
        return true;
    }
    case R.id.open_with_account: {
        final Intent intent = new Intent(INTENT_ACTION_SELECT_ACCOUNT);
        intent.setClass(getActivity(), AccountSelectorActivity.class);
        intent.putExtra(EXTRA_SINGLE_SELECTION, true);
        startActivityForResult(intent, REQUEST_SELECT_ACCOUNT);
        break;
    }
    default: {
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}