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

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

Introduction

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

Prototype

public int show(FragmentTransaction transaction, String tag) 

Source Link

Document

Display the dialog, adding the fragment using an existing transaction and then committing the transaction.

Usage

From source file:com.cuddlesoft.nori.fragment.ImageFragment.java

/**
 * Show the {@link com.cuddlesoft.nori.fragment.TagListDialogFragment} for the current image.
 *///from   w w w.  j a va2s  . co  m
protected void showTagListDialog() {
    DialogFragment tagListFragment = TagListDialogFragment.newInstance(image,
            listener.getSearchClientSettings());
    tagListFragment.show(getFragmentManager(), "TagListDialogFragment");
}

From source file:io.github.carlorodriguez.alarmon.PrefsFragment.java

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    switch (preference.getKey()) {
    case AppSettings.APP_THEME_KEY:
        ActivityAlarmClock.activityAlarmClock.finish();

        startActivity(new Intent(getActivity(), ActivityAlarmClock.class));

        getActivity().finish();/*from w w w.ja  v  a 2 s.c  om*/
        break;
    case AppSettings.NOTIFICATION_TEXT:
        final String customNotificationText = getResources()
                .getStringArray(R.array.notification_text_values)[3];

        if (newValue.equals(customNotificationText)) {
            DialogFragment dialog = new ActivityDialogFragment().newInstance(CUSTOM_NOTIFICATION_TEXT);

            dialog.show(getFragmentManager(), "ActivityDialogFragment");
        } else {
            final Intent causeRefresh = new Intent(getActivity(), AlarmClockService.class);

            causeRefresh.putExtra(AlarmClockService.COMMAND_EXTRA,
                    AlarmClockService.COMMAND_NOTIFICATION_REFRESH);

            getActivity().startService(causeRefresh);
        }
        break;
    default:
        break;
    }

    return true;
}

From source file:com.chrulri.droidoflife.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.mi_automatic:
        // toggle automatic mode
        if (iterationTask == null) {
            iterationTask = new IterationTask();
            iterationTask.execute();//from   w  w w .ja v  a 2 s.  c om
        } else {
            iterationTask.cancel(false);
            iterationTask = null;
        }
        refreshTitle();
        return true;
    case R.id.mi_restart:
        // restart game of life
        restartRuntime();
        doRender();
        return true;
    case R.id.mi_settings:
        // open settings activity
        startActivityForResult(new Intent(this, SettingsActivity.class), RESULT_SETTINGS);
        return true;
    case R.id.mi_help:
        // open help dialog
        DialogFragment help = new HelpDialogFragment();
        help.show(getSupportFragmentManager(), null);
        return true;
    case R.id.mi_about:
        // open about dialog
        DialogFragment about = new AboutDialogFragment();
        about.show(getSupportFragmentManager(), null);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.akhbulatov.wordkeeper.ui.activity.MainActivity.java

private void showWordEditorDialog(@StringRes int titleId, @StringRes int positiveTextId,
        @StringRes int negativeTextId) {
    DialogFragment dialog = WordEditorDialog.newInstance(titleId, positiveTextId, negativeTextId);
    dialog.show(getSupportFragmentManager(), null);
    // NOTE! If the method is not called, the app crashes
    getSupportFragmentManager().executePendingTransactions();

    Dialog dialogView = dialog.getDialog();
    Spinner spinnerCategories = dialogView.findViewById(R.id.spinner_categories);

    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
            mWordListFragment.getCategories());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerCategories.setAdapter(adapter);

    // Receives and shows data of the selected word to edit in the dialog
    // Data is the name, translation and category
    if (positiveTextId == R.string.word_editor_action_edit) {
        EditText editName = dialogView.findViewById(R.id.edit_word_name);
        EditText editTranslation = dialogView.findViewById(R.id.edit_word_translation);

        editName.setText(mWordListFragment.getName());
        editTranslation.setText(mWordListFragment.getTranslation());
        spinnerCategories.setSelection(adapter.getPosition(mWordListFragment.getCategory()));
    }//ww w.  j a  v  a2s. c om
}

From source file:com.secretparty.app.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        getSupportFragmentManager().popBackStack();
        return true;
    case R.id.action_settings:
        return true;
    case R.id.action_add:
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        Fragment prev = getSupportFragmentManager().findFragmentByTag("Dialog");
        if (prev != null)
            ft.remove(prev);/*from w w  w .j  a v a2s.  co  m*/
        ft.addToBackStack(null);
        DialogFragment frag = PartyCreationDialog.newInstance();
        frag.show(ft, "dialog");
        return true;

    }
    return super.onOptionsItemSelected(item);
}

From source file:de.skubware.opentraining.activity.manage_workouts.WorkoutDetailFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.workout_detail_menu, menu);

    // configure menu_item_rename_workout
    MenuItem menu_item_rename_workout = (MenuItem) menu.findItem(R.id.menu_item_rename_workout);
    menu_item_rename_workout.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            Fragment prev = getFragmentManager().findFragmentByTag("dialog");
            if (prev != null) {
                ft.remove(prev);/*from   ww w .ja  va2 s  .  c  o  m*/
            }
            ft.addToBackStack(null);

            // Create and show the dialog.
            DialogFragment newFragment = RenameWorkoutDialogFragment.newInstance(mWorkout);
            newFragment.show(ft, "dialog");

            return true;
        }
    });

    // configure menu_item_delete_workout
    MenuItem menu_item_delete_workout = (MenuItem) menu.findItem(R.id.menu_item_delete_workout);
    menu_item_delete_workout.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

            builder.setTitle("Really delete?");
            builder.setMessage("Do you really want to delete this Workout? This cannot be undone.");

            builder.setPositiveButton(getString(R.string.delete_workout), new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int wich) {
                    IDataProvider dataProvider = new DataProvider(getActivity());
                    dataProvider.deleteWorkout(mWorkout);

                    if (getActivity() instanceof WorkoutDetailActivity) {
                        // request WorkoutListActivity to
                        // finish too
                        Intent i = new Intent();
                        getActivity().setResult(WorkoutListActivity.REQUEST_EXIT, i);
                    }

                    // finish WorkoutListActivity
                    getActivity().finish();

                    startActivity(new Intent(getActivity(), WorkoutListActivity.class));

                }
            });
            builder.setNegativeButton(getString(R.string.cancel), new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int wich) {
                    dialog.dismiss();
                }
            });

            builder.create().show();

            return true;
        }
    });

    // configure menu_item_export_workout
    MenuItem menu_item_export_workout = (MenuItem) menu.findItem(R.id.menu_item_export_workout);
    menu_item_export_workout.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {

            Intent showHTMLIntent = new Intent(getActivity(), ShowWorkoutHTMLActivity.class);
            showHTMLIntent.putExtra(ShowWorkoutHTMLActivity.ARG_WORKOUT, mWorkout);
            startActivity(showHTMLIntent);

            return true;
        }
    });

    // configure menu_item_edit_workout
    MenuItem menu_item_edit_workout = (MenuItem) menu.findItem(R.id.menu_item_edit_workout);
    menu_item_edit_workout.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {

            Intent editItent = new Intent(getActivity(), ExerciseTypeListActivity.class);
            editItent.putExtra(ExerciseTypeListActivity.ARG_WORKOUT, mWorkout);
            startActivity(editItent);

            // close the manage workout activities
            if (getActivity() instanceof WorkoutDetailActivity)
                getActivity().finishFromChild(getActivity());
            getActivity().finish();

            return true;
        }
    });

}

From source file:com.digitalarx.android.files.FileOperationsHelper.java

public void sendDownloadedFile(OCFile file) {
    if (file != null) {
        Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
        // set MimeType
        sendIntent.setType(file.getMimetype());
        sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getStoragePath()));
        sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action

        // Show dialog, without the own app
        String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
        DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
        chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);

    } else {// w w  w. ja  v  a2  s.c  o  m
        Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
    }
}

From source file:com.enadein.carlogbook.core.CarLogbookMediator.java

public void showConfirmImport() {
    DialogFragment importDlg = ImportDialog.newInstance();
    importDlg.show(activity.getSupportFragmentManager(), "import");
}

From source file:com.m3sys.proxlock.MainActivity.java

public void setHomeClicked(View w) {
    Button b = (Button) w;

    DialogFragment newFragment = new AddSafeLocationDialogFragment();
    newFragment.show(getSupportFragmentManager(), "Add Location");

}

From source file:com.digitalarx.android.files.FileOperationsHelper.java

public void shareFileWithLink(OCFile file) {

    if (isSharedSupported()) {
        if (file != null) {
            String link = "https://fake.url";
            Intent intent = createShareWithLinkIntent(link);
            String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent, packagesToExclude, file);
            chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);

        } else {/*w w w.  ja va  2 s.c o m*/
            Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
        }

    } else {
        // Show a Message
        Toast t = Toast.makeText(mFileActivity,
                mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
        t.show();
    }
}