Example usage for android.app DialogFragment show

List of usage examples for android.app DialogFragment show

Introduction

In this page you can find the example usage for android.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:it.angrydroids.epub3reader.EpubReaderMain.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.FirstEPUB:
        bookSelector = BookEnum.first;/*from   www .j  av a2 s  .c  o m*/
        Intent goToChooser1 = new Intent(this, FileChooser.class);
        goToChooser1.putExtra(getString(R.string.second), getString(R.string.time));
        startActivityForResult(goToChooser1, 0);
        return true;

    case R.id.SecondEPUB:
        bookSelector = BookEnum.second;
        Intent goToChooser2 = new Intent(this, FileChooser.class);
        goToChooser2.putExtra(getString(R.string.second), getString(R.string.time));
        startActivityForResult(goToChooser2, 0);
        // invalidateOptionsMenu();
        return true;

    case R.id.Front:
        if (navigator.isExactlyOneBookOpen() == true || navigator.isParallelTextOn() == true)
            chooseLanguage(BookEnum.first);
        return true;

    case R.id.FirstFront:
        chooseLanguage(BookEnum.first);
        return true;

    case R.id.SecondFront:
        if (navigator.isExactlyOneBookOpen() == false)
            chooseLanguage(BookEnum.second);
        else
            errorMessage(getString(R.string.error_onlyOneBookOpen));
        return true;

    case R.id.PconS:
        try {
            boolean yes = navigator.synchronizeView1WithView2();
            if (!yes) {
                errorMessage(getString(R.string.error_onlyOneBookOpen));
            }
        } catch (Exception e) {
            errorMessage(getString(R.string.error_cannotSynchronize));
        }
        return true;

    case R.id.SconP:
        try {
            boolean ok = navigator.synchronizeView2WithView1();
            if (!ok) {
                errorMessage(getString(R.string.error_onlyOneBookOpen));
            }
        } catch (Exception e) {
            errorMessage(getString(R.string.error_cannotSynchronize));
        }
        return true;

    case R.id.Synchronize:

        boolean sync = navigator.flipSynchronizedReadingActive();
        if (!sync) {
            errorMessage(getString(R.string.error_onlyOneBookOpen));
        }
        return true;

    case R.id.Metadata:
        if (navigator.isExactlyOneBookOpen() == true || navigator.isParallelTextOn() == true) {
            navigator.displayMetadata(BookEnum.first);
            updateView1(ViewStateEnum.notes);
        } else {
        }
        return true;

    case R.id.meta1:
        if (navigator.displayMetadata(BookEnum.first))
            updateView1(ViewStateEnum.notes);
        else
            errorMessage(getString(R.string.error_metadataNotFound));
        return true;

    case R.id.meta2:
        if (navigator.displayMetadata(BookEnum.second))
            updateView2(ViewStateEnum.notes);
        else
            errorMessage(getString(R.string.error_metadataNotFound));
        return true;

    case R.id.tableOfContents:
        if (navigator.isExactlyOneBookOpen() == true || navigator.isParallelTextOn() == true) {
            navigator.displayTOC(BookEnum.first);
            updateView1(ViewStateEnum.notes);
        } else {
        }
        return true;

    case R.id.toc1:
        if (navigator.displayTOC(BookEnum.first))
            updateView1(ViewStateEnum.notes);
        else
            errorMessage(getString(R.string.error_tocNotFound));
        return true;
    case R.id.toc2:
        if (navigator.displayTOC(BookEnum.second))
            updateView1(ViewStateEnum.notes);
        else
            errorMessage(getString(R.string.error_tocNotFound));
        return true;
    case R.id.changeSize:
        try {
            DialogFragment newFragment = new SetPanelSize();
            newFragment.show(getFragmentManager(), "");
        } catch (Exception e) {
            errorMessage(getString(R.string.error_cannotChangeSizes));
        }
        return true;
    case R.id.Style: // work in progress...
        try {
            DialogFragment newFragment = new ChangeCSSMenu();
            newFragment.show(getFragmentManager(), "");
        } catch (Exception e) {
            errorMessage(getString(R.string.error_CannotChangeStyle));
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.coinblesk.client.KeyboardFragment.java

private void onEnter() {
    if (coinConvert().isPositive()) {
        DialogFragment fragment = getDialogFragment();
        if (fragment != null) {
            fragment.show(this.getFragmentManager(), "keyboard_dialog_fragment");
        }// w ww .ja va2s .c  o  m
    }
}

From source file:com.ffmpeger.card.MainNativeActivity.java

private void openDialogFragment(DialogFragment dialogStandardFragment) {
    if (dialogStandardFragment != null) {
        FragmentManager fm = getFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("carddemo_dialog");
        if (prev != null) {
            ft.remove(prev);// w  w  w.  j  av  a  2s.  c  om
        }
        //ft.addToBackStack(null);

        dialogStandardFragment.show(ft, "carddemo_dialog");
    }
}

From source file:key.secretkey.crypto.PgpHandler.java

public void handleClick(View view) {
    switch (view.getId()) {
    case R.id.crypto_show_button:
        decryptAndVerify(new Intent());
        break;//from   w  w w  . j  a  va 2s .co  m
    case R.id.crypto_delete_button:
        //                deletePassword();
        break;
    case R.id.crypto_get_key_ids:
        getKeyIds(new Intent());
        break;
    case R.id.generate_password:
        DialogFragment df = new passwordGenerationFragment();
        df.show(getFragmentManager(), "generator");
    default:
        Log.wtf(Constants.TAG, "This should not happen.... PgpHandler.java#handleClick(View) default reached.");
        // should not happen

    }
}

From source file:com.coinblesk.client.KeyboardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_keyboard, container, false);

    final int screenLayout = getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    switch (screenLayout) {
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
    case Configuration.SCREENLAYOUT_SIZE_XLARGE:
        initLarge(view);/*from w ww  .j  a  va  2 s.c o m*/
        break;
    default:
        initStandard(view);
        break;
    }

    TextView t1 = (TextView) view.findViewById(R.id.amount_large_text_view);
    TextView t2 = (TextView) view.findViewById(R.id.amount_large_text_currency);
    TextView t3 = (TextView) view.findViewById(R.id.amount_small_text_view);
    TextView t4 = (TextView) view.findViewById(R.id.amount_small_text_currency);

    View.OnLongClickListener listener = new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            DialogFragment fragment = CurrencyDialogFragment.newInstance();
            if (fragment != null) {
                fragment.show(KeyboardFragment.this.getFragmentManager(), TAG);
            }
            return true;
        }
    };

    t1.setOnLongClickListener(listener);
    t2.setOnLongClickListener(listener);
    t3.setOnLongClickListener(listener);
    t4.setOnLongClickListener(listener);

    UIUtils.refreshConnectionIconStatus(getActivity(), view);

    return view;
}

From source file:org.symptomcheck.capstone.ui.CheckInFlowActivityOld.java

void showDialog() {
    DialogFragment newFragment = AlertCheckSubmissionFragment.newInstance(
            R.string.alert_dialog_title_checkin_submission,
            CheckIn.getDetailedInfo(mCheckInFromUserChoices, false));
    newFragment.show(getFragmentManager(), "dialog");
}

From source file:com.benlinskey.greekreference.MainActivity.java

/**
 * Deletes all items from the syntax bookmarks list.
 *//*from   w  ww  . jav a 2s. c  o  m*/
private void clearSyntaxBookmarks() {
    DialogFragment dialog = new ClearSyntaxBookmarksDialogFragment();
    dialog.show(getFragmentManager(), "clearBookmarks");
}

From source file:com.benlinskey.greekreference.MainActivity.java

/**
 * Deletes all words from the lexicon favorites list.
 *///from ww  w  .  j  a  va  2 s.  c o  m
private void clearLexiconFavorites() {
    DialogFragment dialog = new ClearLexiconFavoritesDialogFragment();
    dialog.show(getFragmentManager(), "clearFavorites");
}

From source file:com.iClone.AlarmChallenge.ActivityAlarmSettings.java

private void showDialogFragment(int id) {
    DialogFragment dialog = new ActivityDialogFragment().newInstance(id);
    dialog.show(getFragmentManager(), "ActivityDialogFragment");
}

From source file:com.google.android.apps.santatracker.doodles.tilt.SwimmingFragment.java

@Override
protected void firstPassLoadOnUiThread() {
    final FrameLayout.LayoutParams wrapperLP = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);// ww w. jav  a 2s.  c o  m

    final SwimmingFragment that = this;
    scoreView = getScoreView();
    pauseView = getPauseView();

    int diveViewBottomMargin = (int) context.getResources().getDimension(R.dimen.dive_margin_bottom);
    int diveViewStartMargin = (int) context.getResources().getDimension(R.dimen.dive_margin_left);
    int diveViewSize = (int) context.getResources().getDimension(R.dimen.dive_image_size);

    FrameLayout.LayoutParams diveViewLP = new LayoutParams(diveViewSize, diveViewSize);
    diveViewLP.setMargins(diveViewStartMargin, 0, 0, diveViewBottomMargin);
    diveViewLP.gravity = Gravity.BOTTOM | Gravity.LEFT;

    if (VERSION.SDK_INT >= 17) {
        diveViewLP.setMarginStart(diveViewStartMargin);
    }
    diveView = new DiveView(context);

    countdownView = new TextView(context);
    countdownView.setGravity(Gravity.CENTER);
    countdownView.setTextColor(context.getResources().getColor(R.color.ui_text_yellow));
    countdownView.setTypeface(Typeface.DEFAULT_BOLD);
    countdownView.setText("0");
    countdownView.setVisibility(View.INVISIBLE);
    Locale locale = context.getResources().getConfiguration().locale;
    countdownView.setText(NumberFormat.getInstance(locale).format(3));
    Point screenDimens = AndroidUtils.getScreenSize();
    UIUtil.fitToBounds(countdownView, screenDimens.x / 10, screenDimens.y / 10);

    LinearLayout gameView = new LinearLayout(context);
    gameView.setOrientation(LinearLayout.VERTICAL);

    // Add game view.
    swimmingView = new SwimmingView(context);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, 7);
    gameView.addView(swimmingView, lp);

    if (editorMode) {
        LinearLayout buttonWrapper = new LinearLayout(context);
        buttonWrapper.setOrientation(LinearLayout.HORIZONTAL);
        lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1);
        gameView.addView(buttonWrapper, lp);

        resetButton = getButton(R.string.reset_level, new OnClickListener() {
            @Override
            public void onClick(View v) {
                SwimmingModel level = levelManager.loadDefaultLevel();
                initializeLevel(level, false);

                getActivity().getSharedPreferences(context.getString(R.string.swimming), Context.MODE_PRIVATE)
                        .edit().putString(CURRENT_LEVEL_KEY, null).commit();
            }
        });
        deleteButton = getButton(R.string.delete_levels, new OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogFragment dialogFragment = new DeleteLevelDialogFragment();
                dialogFragment.show(getActivity().getFragmentManager(), "delete");
            }
        });
        loadButton = getButton(R.string.load_level, new OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogFragment dialogFragment = new LoadLevelDialogFragment(that);
                dialogFragment.show(getActivity().getFragmentManager(), "load");
            }
        });
        saveButton = getButton(R.string.save_level, new OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogFragment dialogFragment = new SaveLevelDialogFragment(that);
                dialogFragment.show(getActivity().getFragmentManager(), "save");
            }
        });
        collisionModeButton = new ToggleButton(context);
        collisionModeButton.setText(R.string.scenery_mode);
        collisionModeButton.setTextOff(context.getString(R.string.scenery_mode));
        collisionModeButton.setTextOn(context.getString(R.string.collision_mode));
        collisionModeButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                model.collisionMode = isChecked;
            }
        });

        lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.MATCH_PARENT, 1);
        buttonWrapper.addView(deleteButton, lp);
        buttonWrapper.addView(resetButton, lp);
        buttonWrapper.addView(loadButton, lp);
        buttonWrapper.addView(saveButton, lp);
        buttonWrapper.addView(collisionModeButton, lp);
    }

    sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    if (accelerometerSensor == null) {
        // TODO: The game won't be playable without this, so what should we do?
        Log.d(TAG, "Accelerometer sensor is null");
    }
    displayRotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
            .getRotation();

    wrapper.addView(gameView, 0, wrapperLP);
    wrapper.addView(countdownView, 1);
    wrapper.addView(diveView, 2, diveViewLP);
    wrapper.addView(scoreView, 3);
    wrapper.addView(pauseView, 4);
}