Example usage for android.app Dialog setOwnerActivity

List of usage examples for android.app Dialog setOwnerActivity

Introduction

In this page you can find the example usage for android.app Dialog setOwnerActivity.

Prototype

public final void setOwnerActivity(@NonNull Activity activity) 

Source Link

Document

Sets the Activity that owns this dialog.

Usage

From source file:com.todoroo.astrid.activity.FilterListFragment.java

/** Sets up the coach list adapter */
protected void setUpList() {
    adapter.setListView(getListView());/*  ww w. j av  a 2 s .  c  o  m*/
    setListAdapter(adapter);

    adapter.setLastSelected(mSelectedIndex);

    // Can't do context menus when list is in popup menu for some reason--workaround
    if (((AstridActivity) getActivity()).fragmentLayout == AstridActivity.LAYOUT_SINGLE) {
        getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                // Do stuff
                final Filter filter = adapter.getItem(position);
                final String[] labels = filter.contextMenuLabels;
                final Intent[] intents = filter.contextMenuIntents;
                ArrayAdapter<String> intentAdapter = new ArrayAdapter<String>(getActivity(),
                        android.R.layout.simple_list_item_1);
                intentAdapter.add(getString(R.string.FLA_context_shortcut));
                for (String l : labels) {
                    intentAdapter.add(l);
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(filter.title);
                builder.setAdapter(intentAdapter, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 0) {
                            showCreateShortcutDialog(getActivity(), ShortcutActivity.createIntent(filter),
                                    filter);
                        } else {
                            startActivityForResult(intents[which - 1], REQUEST_CUSTOM_INTENT);
                        }
                    }
                });

                Dialog d = builder.create();
                d.setOwnerActivity(getActivity());
                d.show();
                return true;
            }

        });
    } else {
        registerForContextMenu(getListView());
    }
}

From source file:org.ohmage.reminders.types.location.LocTrigMapsActivity.java

private void showHelpDialog() {
    Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.trigger_loc_maps_tips);
    dialog.setTitle(R.string.trigger_loc_defining_locations);
    dialog.setOwnerActivity(this);
    dialog.show();//from   w  ww . j  ava  2  s  .  co  m

    WebView webView = (WebView) dialog.findViewById(R.id.web_view);
    webView.loadUrl("file:///android_res/raw/trigger_loc_maps_help.html");

    CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.check_do_not_show);
    checkBox.setChecked(shouldSkipToolTip());
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            SharedPreferences pref = LocTrigMapsActivity.this.getSharedPreferences(TOOL_TIP_PREF_NAME,
                    Context.MODE_PRIVATE);

            SharedPreferences.Editor editor = pref.edit();
            editor.putBoolean(KEY_TOOL_TIP_DO_NT_SHOW, isChecked);
            editor.commit();
        }
    });

    Button button = (Button) dialog.findViewById(R.id.button_close);
    button.setTag(dialog);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Object tag = v.getTag();
            if (tag != null && tag instanceof Dialog) {
                ((Dialog) tag).dismiss();
            }
        }
    });
}

From source file:android.app.Activity.java

/**
 * @deprecated Old no-arguments version of
 * {@link #onPrepareDialog(int, Dialog, Bundle)}.
 */// w  w w  .jav  a 2  s  .co m
@Deprecated
protected void onPrepareDialog(int id, Dialog dialog) {
    dialog.setOwnerActivity(this);
}