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.csipsimple.ui.help.Help.java

@Override
public void onItemClick(AdapterView<?> av, View v, int position, long id) {
    Log.i(THIS_FILE, "Item clicked : " + id + " " + position);
    HelpArrayAdapter haa = (HelpArrayAdapter) av.getAdapter();
    HelpEntry he = haa.getItem(position);

    DialogFragment newFragment;
    switch (he.choiceTag) {
    case FAQ:/*  w w w.  j ava 2  s .  com*/
        newFragment = Faq.newInstance();
        newFragment.show(getSupportFragmentManager(), "faq");
        break;
    case LEGALS:
        newFragment = Legal.newInstance();
        newFragment.show(getSupportFragmentManager(), "issues");
        break;
    case OPEN_ISSUES:
        Intent it = new Intent(Intent.ACTION_VIEW);
        it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        it.setData(Uri.parse("http://code.google.com/p/csipsimple/issues"));
        startActivity(it);
        break;
    case NIGHTLY:
        // We have to check for an update
        final NightlyUpdater nu = new NightlyUpdater(getActivity());
        Thread t = new Thread() {
            public void run() {
                UpdaterPopupLauncher ru = nu.getUpdaterPopup(true);
                if (ru != null) {
                    getActivity().runOnUiThread(ru);
                }
            };
        };
        t.start();
        break;
    case SEND_LOGS:
        prefsWrapper.setPreferenceStringValue(SipConfigManager.LOG_LEVEL, "1");
        try {
            startActivityForResult(
                    CollectLogs.getLogReportIntent("<<<PLEASE ADD THE BUG DESCRIPTION HERE>>>", getActivity()),
                    REQUEST_SEND_LOGS);
        } catch (Exception e) {
            Log.e(THIS_FILE, "Impossible to send logs...", e);
        }
        Log.setLogLevel(1);
        break;
    case START_LOGS:
        prefsWrapper.setPreferenceStringValue(SipConfigManager.LOG_LEVEL, "4");
        Log.setLogLevel(4);
        Intent intent = new Intent(SipManager.ACTION_SIP_REQUEST_RESTART);
        getActivity().sendBroadcast(intent);
        dismiss();
        break;
    default:
        break;
    }
}

From source file:com.vuze.android.remote.AndroidUtils.java

public static boolean showDialog(DialogFragment dlg, FragmentManager fm, String tag) {
    try {/*from w  ww. ja va  2 s.  c o  m*/
        dlg.show(fm, tag);
        return true;
    } catch (IllegalStateException e) {
        // Activity is no longer active (ie. most likely paused)
        return false;
    }
}

From source file:com.ohso.omgubuntu.ArticleActivity.java

@Override
public void articleError() {
    DialogFragment fragment = AlertDialogFragment.newInstance(activeArticle);
    fragment.show(getSupportFragmentManager(), "article_error");
}

From source file:de.skubware.opentraining.activity.start_training.FExDetailFragment.java

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

    // configure menu_item_add_entry
    MenuItem menu_item_add_entry = (MenuItem) menu.findItem(R.id.menu_item_add_entry);
    menu_item_add_entry.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            showDialog();//from w  ww .j  av  a 2s.  co m
            return true;
        }
    });

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

            String license = "";

            if (mExercise.getImageLicenseMap().values().iterator().hasNext()) {
                license = mExercise.getImageLicenseMap().values().iterator().next();
            } else {
                license = getString(R.string.no_license_available);
            }

            builder.setMessage(license);
            builder.create().show();

            return true;
        }
    });

    // configure menu_item_license_info
    MenuItem menu_item_history = (MenuItem) menu.findItem(R.id.menu_item_history);
    menu_item_history.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            Fragment prev = getFragmentManager().findFragmentByTag("dialog");
            if (prev != null) {
                ft.remove(prev);
            }
            ft.addToBackStack(null);

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

            return true;
        }
    });

}

From source file:fr.jcf.pret.activities.PretEmpruntActivity.java

/**
 * Mthode qui permet d'afficher la boite dialogue de date
 * //ww  w.  ja  v a2  s  .  com
 * @param v
 */
public void showDatePickerDialog(View v) {
    // Instanciation de la boite de dialogue  laquelle on passe le champ  alimenter
    DialogFragment newFragment = new DatePickerFragment(dateEditText);

    // Affichage de la boite de dialogue
    newFragment.show(getSupportFragmentManager(), "datePicker");
}

From source file:com.abcvoipsip.ui.help.Help.java

@Override
public void onItemClick(AdapterView<?> av, View v, int position, long id) {
    Log.i(THIS_FILE, "Item clicked : " + id + " " + position);
    HelpArrayAdapter haa = (HelpArrayAdapter) av.getAdapter();
    HelpEntry he = haa.getItem(position);

    DialogFragment newFragment;
    switch (he.choiceTag) {
    case FAQ:/*from w  w w .  j  a v a 2  s .  com*/
        newFragment = Faq.newInstance();
        newFragment.show(getSupportFragmentManager(), "faq");
        break;
    case LEGALS:
        newFragment = Legal.newInstance();
        newFragment.show(getSupportFragmentManager(), "issues");
        break;
    case OPEN_ISSUES:
        Intent it = new Intent(Intent.ACTION_VIEW);
        it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        it.setData(Uri.parse("http://code.google.com/p/csipsimple/issues"));
        startActivity(it);
        break;
    case NIGHTLY:
        // We have to check for an update

        // ABC-VoIP Modification: disabled all nightly updates
        /*
        final NightlyUpdater nu = new NightlyUpdater(getActivity());
        Thread t = new Thread() {
           public void run() {
              UpdaterPopupLauncher ru = nu.getUpdaterPopup(true);
              if (ru != null) {
          getActivity().runOnUiThread(ru);
              }
           };
        };
        t.start();
        */
        break;
    case SEND_LOGS:
        prefsWrapper.setPreferenceStringValue(SipConfigManager.LOG_LEVEL, "1");
        try {
            startActivityForResult(
                    CollectLogs.getLogReportIntent("<<<PLEASE ADD THE BUG DESCRIPTION HERE>>>", getActivity()),
                    REQUEST_SEND_LOGS);
        } catch (Exception e) {
            Log.e(THIS_FILE, "Impossible to send logs...", e);
        }
        Log.setLogLevel(1);
        break;
    case START_LOGS:
        prefsWrapper.setPreferenceStringValue(SipConfigManager.LOG_LEVEL, "4");
        Log.setLogLevel(4);
        Intent intent = new Intent(SipManager.ACTION_SIP_REQUEST_RESTART);
        getActivity().sendBroadcast(intent);
        dismiss();
        break;
    default:
        break;
    }
}

From source file:de.damdi.fitness.activity.start_training.FExDetailFragment.java

/**
 * Shows DialogFragmentAddEntry with the given {@link FSet}.
 * //from  w  w  w  .j  a  v a  2s . c  o  m
 * @param set
 *            The FSet to edit. If it is null a new FSet will be added to
 *            the TrainingEntry.
 *            
 * @see DialogFragmentAddEntry#newInstance(FitnessExercise, FSet)           
 */
private void showDialog(FSet set, int setPosition) {

    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    DialogFragment newFragment = DialogFragmentAddEntry.newInstance(mExercise, set, setPosition,
            mTrainingEntry);
    newFragment.show(ft, "dialog");
}

From source file:edu.cmu.cylab.starslinger.view.IntroductionFragment.java

protected void showHelp(String title, String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_TITLE, title);
    args.putString(extra.RESID_MSG, msg);
    DialogFragment newFragment = IntroAlertDialogFragment.newInstance(BaseActivity.DIALOG_HELP, args);
    newFragment.show(getFragmentManager(), "dialog");
}

From source file:com.example.joeroger.homework2.activity.WeatherActivity.java

private boolean isGooglePlayServicesReady() {
    // If already showing dialog, then skip further checks.
    if (resolvingError)
        return false;

    // See if play services is available
    int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    if (result == ConnectionResult.SUCCESS) {
        return true;
    } else {/*from  w  ww .ja  va 2  s. c om*/
        DialogFragment fragment = PlayServicesDialogFragment.newInstance(result);
        fragment.show(getSupportFragmentManager(), GPS_DIALOG_TAG);
        resolvingError = true;
        return false;
    }
}

From source file:com.bonsai.btcreceive.BaseWalletActivity.java

protected DialogFragment showErrorDialog(String msg) {
    DialogFragment df = new MyDialogFragment();
    Bundle args = new Bundle();
    args.putString("msg", msg);
    args.putBoolean("hasOK", true);
    df.setArguments(args);//from   w  w  w.jav  a  2 s .co m
    df.show(getSupportFragmentManager(), "error");
    return df;
}