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:mx.openpay.android.example.AddCardActivity.java

@Override
public void onCommunicationError(final ServiceUnavailableException error) {
    error.printStackTrace();/*from w ww  .j a  v a  2s.co m*/
    this.progressFragment.dismiss();
    DialogFragment fragment = MessageDialogFragment.newInstance(R.string.error,
            this.getString(R.string.communication_error));
    fragment.show(this.getFragmentManager(), "Error");
}

From source file:info.curtbinder.farmgame.GameActivity.java

private void promptToRenameGame() {
    DialogFragment dlg = new RenameDialogFragment();
    dlg.show(getFragmentManager(), "RenameDialogFragment");
}

From source file:com.spacejake.jake.ultimatepurduediner.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTitle = getTitle();/* w  ww.ja v  a 2 s .  c  om*/
    mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager()
            .findFragmentById(R.id.navigation_drawer);

    // Set up the drawer.
    mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));

    cal = Calendar.getInstance();
    dateString = format.format(cal.getTime());

    spinner = (Spinner) findViewById(R.id.spinner);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            updateMeal();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    listView = (ListView) findViewById(R.id.listview);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            String foodName = adapterView.getItemAtPosition(i).toString();
            String meal = spinner.getSelectedItem().toString();

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            Fragment previous = getFragmentManager().findFragmentByTag("floatingFood");

            if (previous != null) {
                ft.remove(previous);
            }

            ft.addToBackStack(null);

            DialogFragment frag = FloatingFood.newInstance(foodName, mTitle.toString(), meal, cal);
            frag.show(ft, "floatingFood");
        }
    });

}

From source file:de.uulm.graphicalpasswords.opentapi.TAPICreatePasswordActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tapi_create_password);

    // Show the Up button in the action bar.
    setupActionBar();/*w w  w  .  j  a v a2 s . c  o  m*/

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    length = Integer.parseInt(sharedPref.getString("tapi_length", "6"));
    input = new String[length];

    // Save Pictures in randomized order
    SharedPreferences.Editor editor = sharedPref.edit();
    Random random = new Random(System.currentTimeMillis());
    boolean[] usedImages = new boolean[TAPIActivity.IMAGES.length];
    Arrays.fill(usedImages, false);
    for (int i = 0; i < TAPIActivity.IMAGES.length; i++) {
        boolean pictureSet = false;
        int index = random.nextInt(TAPIActivity.IMAGES.length);
        do {
            if (!usedImages[index]) {
                editor.putInt("image" + i, TAPIActivity.IMAGES[index]);
                pictureSet = true;
                usedImages[index] = true;
            } else if (index == TAPIActivity.IMAGES.length - 1) {
                index = 0;
            } else {
                index++;
            }
        } while (!pictureSet);
    }
    editor.commit();

    for (int i = 0; i < images.length; i++) {
        images[i] = sharedPref.getInt("image" + i, 0);
    }

    EditText editText = (EditText) findViewById(R.id.tapi_edittext);
    text = editText.getText();
    back = (Button) findViewById(R.id.tapi_back);
    save = (Button) findViewById(R.id.tapi_save);

    TableLayout table = (TableLayout) findViewById(R.id.tapi_imagetable);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    TableRow row = null;
    for (int i = 0; i < imageViews.length; i++) {
        if (i % 4 == 0) {
            row = new TableRow(this);
        }
        imageViews[i] = new PassImageView(this);
        imageViews[i].setLayoutParams(layoutParams);
        imageViews[i].setAdjustViewBounds(true);
        imageViews[i].setScaleType(ScaleType.CENTER_INSIDE);
        imageViews[i].setPadding(5, 5, 5, 5);
        imageViews[i].setImageResource(images[i]);
        row.addView(imageViews[i]);
        if (i % 4 == 3) {
            table.addView(row);
        }
        imageViews[i].setOnTouchListener(new TAPIOnTouchListener(this, imageViews[i]));
    }

    Bundle bundle = new Bundle();
    bundle.putInt("length", length);
    DialogFragment intro = new IntroDialogFragment();
    intro.setArguments(bundle);
    intro.show(getFragmentManager(), "intro");
}

From source file:com.coinblesk.client.wallet.WalletAddressList.java

private void showSendDialog(Coin amount) {
    DialogFragment sendDialog = SendDialogFragment.newInstance(amount);
    sendDialog.show(getFragmentManager(), "collect_refund_send_dialog");
    // Note: the callback is WalletActivity#sendCoins
}

From source file:at.alladin.rmbt.android.util.CheckNewsTask.java

@Override
protected void onPostExecute(final JSONArray newsList) {

    if (newsList != null && newsList.length() > 0 && !serverConn.hasError())
        for (int i = 0; i < newsList.length(); i++)
            if (!isCancelled() && !Thread.interrupted())
                try {

                    final JSONObject newsItem = newsList.getJSONObject(i);

                    final DialogFragment newFragment = RMBTAlertDialogFragment.newInstance(
                            newsItem.optString("title", activity.getString(R.string.news_title)),
                            newsItem.optString("text", activity.getString(R.string.news_no_message)), null);

                    newFragment.show(activity.getFragmentManager(), "dialog");

                    if (newsItem.has("uid")) {
                        if (lastNewsUid < newsItem.getLong("uid"))
                            lastNewsUid = newsItem.getLong("uid");
                    }//from   w w w.j  a  va2s .  c  om
                } catch (final JSONException e) {
                    e.printStackTrace();
                }

    ConfigHelper.setLastNewsUid(activity.getApplicationContext(), lastNewsUid);
}

From source file:paarmann.physikprofil.MainActivity.java

@Override
public void onResume() {
    super.onResume();
    isPaused = false;//  ww  w.ja va2s .  c o  m

    while (dialogsToShow.size() > 0) {
        DialogFragment dialog = dialogsToShow.get(0);
        dialog.show(getFragmentManager(), "dialogsToShow");
        dialogsToShow.remove(0);
    }
}

From source file:com.vaquerosisd.projectmanager.NewProject.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_project);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    //Initialize database operation object
    db = new ProjectOperations(this);
    db.open();/*from  w  w w  . ja  v  a 2s .com*/

    //Initialize file operations instance
    fO = new FileOperations(this);

    //UI handlers references
    final EditText projectNameEditText = (EditText) findViewById(R.id.newProject_ProjectName);
    final EditText startDateEditText = (EditText) findViewById(R.id.newProject_StartDate);
    final EditText dueDateEditText = (EditText) findViewById(R.id.newProject_DueDate);
    statusSpinner = (Spinner) findViewById(R.id.newProject_StatusSpinner);
    final Button addProjectButton = (Button) findViewById(R.id.addProject);

    //Set spinner
    String statusItemsString = "New\nIn progress\nPrinting\nOn hold\nCancelled\nReviewing\nDelegated\nCompleted\n";
    fO.createStringFile(statusFileName, statusItemsString);
    setStatusSpinner();
    int statusPosition = statusSpinnerAdapter.getPosition("New");
    statusSpinner.setSelection(statusPosition, true);

    //Check if custom option is selected to open a dialog to provide a custom status      
    statusSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if ("Custom...".equals((String) statusSpinnerAdapter.getItem(position))) {
                DialogFragment customStatusDialog = new CustomStatus();
                customStatusDialog.show(getFragmentManager(), "Custom Status Dialog");
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });

    //StartDate click listener
    startDateEditText.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            showDatePickerDialog(arg0, STARTDATE_DIALOG_TAG, startDateEditText, startDateStrings);
        }
    });

    //DueDate click listener
    dueDateEditText.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            showDatePickerDialog(arg0, DUEDATE_DIALOG_TAG, dueDateEditText, dueDateStrings);
        }
    });

    //Add project to database
    addProjectButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            //Get EditText info
            String projectNameString = projectNameEditText.getText().toString();
            String projectStatusString = statusSpinner.getSelectedItem().toString();
            String projectStartDateString = startDateEditText.getText().toString();
            String projectDueDateString = dueDateEditText.getText().toString();

            //Add project to database if all input elements are filled
            boolean dueDateBeforeStartDate = true;

            Calendar startDateCalendar = Calendar.getInstance();
            startDateCalendar.set(startDateStrings[0], startDateStrings[1], startDateStrings[2]);
            Calendar dueDateCalendar = Calendar.getInstance();
            dueDateCalendar.set(dueDateStrings[0], dueDateStrings[1], dueDateStrings[2]);
            if (startDateCalendar.before(dueDateCalendar) || startDateCalendar.equals(dueDateCalendar))
                dueDateBeforeStartDate = false;

            if (dueDateBeforeStartDate) {
                Toast.makeText(getApplicationContext(), R.string.dueDateError, Toast.LENGTH_LONG).show();
                return;
            } else if (!projectNameString.equals("") && !projectStartDateString.equals("")
                    && !projectDueDateString.equals("")) {
                File contentDir = new File("/storage/sdcard0/ProjectManager/" + projectNameString);
                contentDir.mkdirs();
                db.addProject(projectNameString, projectStatusString, startDateStrings, dueDateStrings,
                        contentDir.getAbsolutePath());
                Toast.makeText(getApplicationContext(), R.string.projectAdded, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), R.string.incomplete, Toast.LENGTH_LONG).show();
                return;
            }

            //Inform of successful adding
            Intent intent = new Intent();
            setResult(RESULT_OK, intent);
            finish();
        }
    });
}

From source file:paarmann.physikprofil.MainActivity.java

public void onBtnPickDateClick(View view) {
    DialogFragment dialog = new DatePickerFragment().setListener(this);
    dialog.show(getFragmentManager(), "datePicker");
}

From source file:com.sparshik.monalisa.FaceTrackerActivity.java

public void showEmojiDialog(View view) {
    DialogFragment dialogFragment = new EmojiDialogFragment();
    dialogFragment.show(FaceTrackerActivity.this.getFragmentManager(), "EmojiDialogFragment");
}