Example usage for android.support.v4.app DialogFragment setArguments

List of usage examples for android.support.v4.app DialogFragment setArguments

Introduction

In this page you can find the example usage for android.support.v4.app DialogFragment setArguments.

Prototype

public void setArguments(Bundle args) 

Source Link

Document

Supply the construction arguments for this fragment.

Usage

From source file:org.getlantern.firetweet.util.DirectMessageOnLinkClickHandler.java

@Override
protected void openLink(final String link) {
    if (link == null || manager != null && manager.isActive())
        return;/*from w w  w  .  j  a  v a 2 s  .co m*/
    if (!hasShortenedLinks(link)) {
        super.openLink(link);
        return;
    }
    final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    if (context instanceof FragmentActivity && prefs.getBoolean(KEY_PHISHING_LINK_WARNING, true)) {
        final FragmentManager fm = ((FragmentActivity) context).getSupportFragmentManager();
        final DialogFragment fragment = new PhishingLinkWarningDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_URI, Uri.parse(link));
        fragment.setArguments(args);
        fragment.show(fm, "phishing_link_warning");
    } else {
        super.openLink(link);
    }

}

From source file:org.klnusbaum.udj.PlayerInactivityListenerActivity.java

private void playerWentInactive() {
    DialogFragment newFrag = new PlayerInactiveDialog();
    Bundle args = new Bundle();
    args.putParcelable(Constants.ACCOUNT_EXTRA, account);
    newFrag.setArguments(args);
    newFrag.show(getSupportFragmentManager(), PLAYER_INACTIVE_DIALOG);
}

From source file:de.vanita5.twittnuker.util.OnDirectMessageLinkClickHandler.java

@Override
protected void openLink(final String link) {
    if (link == null || activity == null || manager.isActive())
        return;/*ww w .j  a  v a  2  s.c o  m*/
    if (!hasShortenedLinks(link)) {
        super.openLink(link);
        return;
    }
    final SharedPreferences prefs = activity.getSharedPreferences(SHARED_PREFERENCES_NAME,
            Context.MODE_PRIVATE);
    if (activity instanceof FragmentActivity && prefs.getBoolean(KEY_PHISHING_LINK_WARNING, true)) {
        final FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
        final DialogFragment fragment = new PhishingLinkWarningDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_URI, Uri.parse(link));
        fragment.setArguments(args);
        fragment.show(fm, "phishing_link_warning");
    } else {
        super.openLink(link);
    }

}

From source file:eu.trentorise.smartcampus.eb.fragments.ExperiencesListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final Experience exp = experiencesList.get(info.position);
    switch (item.getItemId()) {
    case R.id.expmenu_remove:
        DialogFragment newFragment = new DeleteExperienceFragment();
        newFragment.setArguments(DeleteExperienceFragment.prepare(exp.getId()));
        newFragment.show(getActivity().getSupportFragmentManager(), "exp_delete");
        return true;
    case R.id.expmenu_assign_collection:
        DialogFragment assignFragment = new AssignCollectionFragment();
        assignFragment.setArguments(AssignCollectionFragment.prepare(exp.getId(), exp.getCollectionIds()));
        assignFragment.show(getActivity().getSupportFragmentManager(), "exp_assign_colls");
        return true;
    default:/*from  w  w w.  ja  va  2 s .c om*/
        Toast.makeText(getActivity(), R.string.not_implemented, Toast.LENGTH_SHORT).show();
        return true;
    }

}

From source file:eu.trentorise.smartcampus.eb.fragments.CollectionsListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final ExpCollection coll = EBHelper.getUserPreference().getCollections().get(info.position);
    switch (item.getItemId()) {
    case R.id.collmenu_remove: {
        new AlertDialog.Builder(getActivity()).setMessage(R.string.msg_delete_coll_confirm).setCancelable(false)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @SuppressWarnings("unchecked")
                    public void onClick(DialogInterface dialog, int id) {
                        EBHelper.getUserPreference().getCollections().remove(coll);
                        if (EBHelper.updateUserPreference(getSherlockActivity(),
                                EBHelper.getUserPreference())) {
                            collections.remove(info.position);
                            ((ArrayAdapter<ExpCollection>) getListAdapter()).notifyDataSetChanged();
                        } else {
                            EBHelper.getUserPreference().getCollections().add(info.position, coll);
                        }//from w  ww .  j ava  2  s .  co m
                    }
                }).setNegativeButton(android.R.string.no, null).show();
        break;
    }
    case R.id.collmenu_edit: {
        DialogFragment editCollFragment = new NewCollectionDialogFragment();
        editCollFragment.setArguments(NewCollectionDialogFragment.prepare(coll));
        editCollFragment.show(getActivity().getSupportFragmentManager(), "exp_coll");
        break;
    }
    }
    return super.onContextItemSelected(item);
}

From source file:net.naonedbus.card.impl.TraficCard.java

private View createView(final LayoutInflater inflater, final ViewGroup root, final InfoTrafic infoTrafic) {
    final View view = inflater.inflate(R.layout.card_item_trafic_ligne, root, false);

    final TextView itemTitle = (TextView) view.findViewById(R.id.itemTitle);
    final TextView itemDate = (TextView) view.findViewById(R.id.itemDate);

    itemTitle.setText(infoTrafic.getIntitule());
    itemDate.setText(infoTrafic.getDateFormated());

    if (isCurrent(infoTrafic)) {
        itemDate.setCompoundDrawablesWithIntrinsicBounds(R.drawable.info_trafic_on, 0, 0, 0);
    } else {/*  ww  w . jav  a 2  s.co  m*/
        itemDate.setCompoundDrawablesWithIntrinsicBounds(R.drawable.info_trafic_off, 0, 0, 0);
    }

    view.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            final Bundle bundle = new Bundle();
            bundle.putParcelable(InfoTraficDetailFragment.PARAM_INFO_TRAFIC, infoTrafic);

            final DialogFragment dialogFragment = new InfoTraficDetailDialogFragment();
            dialogFragment.setArguments(bundle);
            dialogFragment.show(getFragmentManager(), "InfoTraficDetailDialogFragment");
        }
    });

    return view;
}

From source file:net.naonedbus.fragment.impl.InfoTraficFragment.java

@Override
public void onListItemClick(final ListView l, final View v, final int position, final long id) {
    super.onListItemClick(l, v, position, id);
    final InfoTrafic item = (InfoTrafic) getListAdapter().getItem(position);

    final Bundle bundle = new Bundle();
    bundle.putParcelable(InfoTraficDetailFragment.PARAM_INFO_TRAFIC, item);

    final DialogFragment dialogFragment = new InfoTraficDetailDialogFragment();
    dialogFragment.setArguments(bundle);
    dialogFragment.show(getChildFragmentManager(), "InfoTraficDetailDialogFragment");
}

From source file:eu.trentorise.smartcampus.eb.fragments.experience.AssignCollectionFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final List<ExpCollection> collections = EBHelper.getUserPreference().getCollections();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.expmenu_assign_collection);

    if (savedInstanceState != null) {
        selected = savedInstanceState.getBooleanArray("selected");
        selectedIds = new HashSet<String>(savedInstanceState.getStringArrayList("selectedIds"));
        items = savedInstanceState.getStringArray("items");
    } else {/*from   w  w  w  .jav a2 s  . co m*/
        items = new String[collections.size()];
        selected = new boolean[collections.size()];
        for (int i = 0; i < items.length; i++) {
            items[i] = collections.get(i).getName();
            boolean b = false;
            if (getArguments().getStringArrayList(ARG_COLLS) != null) {
                for (String s : getArguments().getStringArrayList(ARG_COLLS)) {
                    if (s.equals(collections.get(i).getId())) {
                        b = true;
                        break;
                    }
                }
            }
            selected[i] = b;
        }
        selectedIds = new HashSet<String>();
        if (getArguments().getStringArrayList(ARG_COLLS) != null)
            selectedIds.addAll(getArguments().getStringArrayList(ARG_COLLS));
    }

    builder.setMultiChoiceItems(items, selected, new OnMultiChoiceClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked)
                selectedIds.add(collections.get(which).getId());
            else
                selectedIds.remove(collections.get(which).getId());
        }
    });

    builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //            exp.setCollectionIds(new ArrayList<String>(selectedIds));
            //            Fragment f = getFragmentManager().findFragmentById(containerId);
            AssignCollectionsCallback c = ((DialogCallbackContainer) getActivity())
                    .getAssignCollectionsCallback();
            c.onCollectionsAssigned(getArguments().getString(ARG_ID), new ArrayList<String>(selectedIds));
            dialog.dismiss();
        }
    });
    builder.setPositiveButton(R.string.dialog_collection_add, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            DialogFragment newCollFragment = new NewCollectionDialogFragment();
            newCollFragment.setArguments(NewCollectionDialogFragment.prepare(null));
            newCollFragment.show(getActivity().getSupportFragmentManager(), "exp_coll");
            //
            //             NewCollectionDialogFragment.saveCollectionDialog(getActivity(), null, new CollectionSavedHandler() {
            //               @Override
            //               public void onCollectionSaved(ExpCollection coll) {
            ////                  exp.setCollectionIds(Collections.singletonList(coll.getId()));
            //                  ((AssignCollectionsCallback)getFragmentManager().findFragmentById(android.R.id.content)).onCollectionsAssigned(getArguments().getString(ARG_ID), Collections.singletonList(coll.getId()));
            //               }
            //            }).show();
            dialog.dismiss();
        }
    });

    return builder.create();
}

From source file:com.xwhiteknuckle.truckerslog.LegalInfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    View v = inflater.inflate(R.layout.fragment_legal_info, container, false);
    Button mButton = (Button) v.findViewById(R.id.legalese_button);
    mButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            DialogFragment newFragment = new LegaleseDialogFragment();
            Bundle b = new Bundle();
            b.putString("msg", GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getActivity()));
            newFragment.setArguments(b);
            newFragment.show(getChildFragmentManager(), "legalese");
        }//from w  ww .ja  v  a2s .  com
    });

    return v;
}

From source file:com.anjalimacwan.activity.NoteEditActivity.java

@Override
public void showDeleteDialog() {
    Bundle bundle = new Bundle();
    bundle.putInt("dialog_title", R.string.dialog_delete_button_title);

    DialogFragment deleteFragment = new DeleteDialogFragment();
    deleteFragment.setArguments(bundle);
    deleteFragment.show(getSupportFragmentManager(), "delete");
}