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.google.plus.samples.photohunt.ThemeViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_upload:
        startCameraIntent();//from   w ww  . j a v  a2s.  co  m
        return true;

    case R.id.menu_item_gallery:
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select Photo"), REQUEST_CODE_IMAGE_SELECT);
        return true;

    case android.R.id.home:
    case R.id.menu_item_theme_select:
        DialogFragment themeDialog = new ThemeSelectDialog();
        themeDialog.show(getSupportFragmentManager(), SELECT_THEME_TAG);
        return true;

    case R.id.menu_item_profile:
        Intent profileIntent = new Intent();
        profileIntent.setClass(this, ProfileActivity.class);
        startActivity(profileIntent);
        return true;

    case R.id.menu_item_refresh:
        mThemeListLoader.forceLoad();
        mPhotoListAdapter.setDirty(THEME_PHOTOS_ID, true);
        mPhotoListAdapter.setDirty(FRIEND_PHOTOS_ID, true);
        mPhotoListAdapter.setDirty(MY_PHOTOS_ID, true);
        update();
        return true;

    case R.id.menu_item_about:
        Intent aboutIntent = new Intent();
        aboutIntent.setClass(this, AboutActivity.class);
        startActivity(aboutIntent);
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.loloof64.android.chess_position_manager.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int menuItemId = menuItem.getItemId();
    DialogFragment newFragment;
    switch (menuItemId) {
    case R.id.action_new_directory:
        newFragment = new NewDirectoryDialogFragment();
        newFragment.show(getSupportFragmentManager(), "newDirectory");
        return true;
    case R.id.action_new_position:
        newFragment = new NewPositionDialogFragment();
        newFragment.show(getSupportFragmentManager(), "newPosition");
        return true;
    case R.id.action_toggle_selection_mode:
        setSelectionMode(!selectionMode);
        return true;
    case R.id.action_remove:
        if (selectionMode) {
            final ListFileElement[] selectedElements = listAdapter.getSelectedElements();
            boolean thereIsSelection = selectedElements != null && selectedElements.length > 0;

            if (thereIsSelection) {
                new AsyncTask<Void, Void, Void>() {
                    @Override//w ww  .j  a v  a2s  .  co  m
                    protected Void doInBackground(Void... params) {
                        ArrayList<String> folders = new ArrayList<>();
                        ArrayList<String> positions = new ArrayList<>();

                        for (ListFileElement currentFileElement : selectedElements) {
                            if (currentFileElement.isDirectory()) {
                                folders.add(currentFileElement.getFileName());
                            } else {
                                positions.add(currentFileElement.getFileName());
                            }
                        }

                        final String[] foldersArray = new String[folders.size()];
                        final String[] positionsArray = new String[positions.size()];
                        folders.toArray(foldersArray);
                        positions.toArray(positionsArray);

                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                DialogFragment newFragment = new ConfirmRemoveElementsDialogFragment();
                                Bundle arguments = new Bundle();
                                arguments.putStringArray(ConfirmRemoveElementsDialogFragment.FOLDERS_TAG,
                                        foldersArray);
                                arguments.putStringArray(ConfirmRemoveElementsDialogFragment.POSITIONS_TAG,
                                        positionsArray);
                                newFragment.setArguments(arguments);
                                newFragment.show(getSupportFragmentManager(), "confirmRemoveElements");
                            }
                        });

                        return null;
                    }
                }.execute();
            }
            // if (thereIsSelection)
            else {
                Toast.makeText(this, R.string.error_select_removing_elements_first, Toast.LENGTH_LONG).show();
            }
        }
        // if (selectionMode)
        else {
            Toast.makeText(this, R.string.error_enter_selection_mode_first, Toast.LENGTH_LONG).show();
        }
        return true;
    /////////////////// temporary
    case R.id.action_test:
        DialogFragment dialog = new ExistingFileDialogFragment();
        Bundle arguments = new Bundle();
        arguments.putString(ExistingFileDialogFragment.FILE_NAME_TAG, "MyTest.epd");
        dialog.setArguments(arguments);
        dialog.show(getSupportFragmentManager(), "testDialog");
        return true;
    ////////////////////
    default:
        return super.onOptionsItemSelected(menuItem);
    }
}

From source file:com.mattprecious.notisync.activity.MainActivity.java

private void showSamsungTtsDialog() {
    DialogFragment samsungFragment = new SamsungTtsDialogFragment();
    samsungFragment.show(getSupportFragmentManager(), null);
}

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

public void showDatePickerDialog(View v) {
    DialogFragment newFragment = new DatePickerFragment();
    newFragment.show(getSupportFragmentManager(), Const.TAG_FRAGMENT_PICKER_DATE);
}

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

public void showTimePickerDialog(View v) {
    DialogFragment newFragment = new TimePickerFragment();
    newFragment.show(getSupportFragmentManager(), Const.TAG_FRAGMENT_PICKER_TIME);
}

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

public void showNumberPickerDialog(View v) {
    DialogFragment newFragment = new NumberPickerFragment();
    newFragment.show(getSupportFragmentManager(), Const.TAG_FRAGMENT_PICKER_NUMBER);
}

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

public void showNumberSeekBarDialog(View v) {
    DialogFragment newFragment = new NumberSeekBarFragment();
    newFragment.show(getSupportFragmentManager(), Const.TAG_FRAGMENT_SEEKBAR_NUMBER);
}

From source file:com.notepadlite.MainActivity.java

@Override
public void showDeleteDialog() {
    DialogFragment deleteFragment = new DeleteDialogFragment();
    deleteFragment.show(getSupportFragmentManager(), "delete");
}

From source file:com.bonsai.wallet32.MainActivity.java

private void showSyncProgressDialog() {
    String details;/*ww  w . j a  v  a2s . co  m*/

    switch (mWalletService.getSyncState()) {
    case CREATED:
        details = mRes.getString(R.string.sync_details_created);
        break;
    case RESTORE:
        details = mRes.getString(R.string.sync_details_restore);
        break;
    case STARTUP:
        details = mRes.getString(R.string.sync_details_startup);
        break;
    case RESCAN:
        details = mRes.getString(R.string.sync_details_rescan);
        break;
    case RERESCAN:
        details = mRes.getString(R.string.sync_details_rerescan);
        break;
    default:
        details = "???"; // Shouldn't happen
        break;
    }

    DialogFragment df = new SyncProgressDialogFragment();
    Bundle args = new Bundle();
    args.putString("details", details);
    df.setArguments(args);
    df.setCancelable(false);
    df.show(getSupportFragmentManager(), "sync_progress_dialog");
    mSyncProgressDialog = df;
}

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

@Override
public void onConnectionFailed(ConnectionResult status) {
    resetAccountState();/*from w  w  w .  jav  a  2  s .  co 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);
    }
}