Search in sources :

Example 1 with SpaceTokenizer

use of fr.neamar.kiss.utils.SpaceTokenizer in project KISS by Neamar.

the class AppResult method launchEditTagsDialog.

private void launchEditTagsDialog(final Context context, final AppPojo app) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(context.getResources().getString(R.string.tags_add_title));
    // Create the tag dialog
    final View v = LayoutInflater.from(context).inflate(R.layout.tags_dialog, null);
    final MultiAutoCompleteTextView tagInput = (MultiAutoCompleteTextView) v.findViewById(R.id.tag_input);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_dropdown_item_1line, KissApplication.getDataHandler(context).getTagsHandler().getAllTagsAsArray());
    tagInput.setTokenizer(new SpaceTokenizer());
    tagInput.setText(appPojo.tags);
    tagInput.setAdapter(adapter);
    builder.setView(v);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            KissApplication.getDataHandler(context).getTagsHandler().setTags(app.id, tagInput.getText().toString());
            // Refresh tags for given app
            app.setTags(tagInput.getText().toString());
            // Show toast message
            String msg = context.getResources().getString(R.string.tags_confirmation_added);
            Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    builder.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) MultiAutoCompleteTextView(android.widget.MultiAutoCompleteTextView) View(android.view.View) TextView(android.widget.TextView) SpaceTokenizer(fr.neamar.kiss.utils.SpaceTokenizer) MultiAutoCompleteTextView(android.widget.MultiAutoCompleteTextView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 View (android.view.View)1 ArrayAdapter (android.widget.ArrayAdapter)1 ImageView (android.widget.ImageView)1 MultiAutoCompleteTextView (android.widget.MultiAutoCompleteTextView)1 TextView (android.widget.TextView)1 SpaceTokenizer (fr.neamar.kiss.utils.SpaceTokenizer)1