Search in sources :

Example 1 with AbstractFilterFragment

use of org.qii.weiciyuan.ui.preference.filter.AbstractFilterFragment in project weiciyuan by qii.

the class AddFilterDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final EditText et = new EditText(getActivity());
    builder.setView(et).setTitle(getString(R.string.input_filter_word)).setPositiveButton(getString(R.string.add), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String word = et.getText().toString().trim();
            if (!TextUtils.isEmpty(word)) {
                AbstractFilterFragment filterFragment = (AbstractFilterFragment) getTargetFragment();
                filterFragment.addFilter(word);
            }
        }
    }).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    AlertDialog dialog = builder.create();
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) AbstractFilterFragment(org.qii.weiciyuan.ui.preference.filter.AbstractFilterFragment) DialogInterface(android.content.DialogInterface)

Example 2 with AbstractFilterFragment

use of org.qii.weiciyuan.ui.preference.filter.AbstractFilterFragment in project weiciyuan by qii.

the class ModifyFilterDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final String word = getArguments().getString("word");
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final EditText et = new EditText(getActivity());
    et.setText(word);
    et.setSelection(et.getText().toString().length());
    builder.setView(et).setTitle(getString(R.string.modify_filter_word)).setPositiveButton(getString(R.string.modify), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String newValue = et.getText().toString().trim();
            if (!TextUtils.isEmpty(word)) {
                AbstractFilterFragment filterFragment = (AbstractFilterFragment) getTargetFragment();
                filterFragment.modifyFilter(word, newValue);
            }
        }
    }).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    AlertDialog dialog = builder.create();
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) AbstractFilterFragment(org.qii.weiciyuan.ui.preference.filter.AbstractFilterFragment) DialogInterface(android.content.DialogInterface)

Aggregations

AlertDialog (android.app.AlertDialog)2 DialogInterface (android.content.DialogInterface)2 EditText (android.widget.EditText)2 AbstractFilterFragment (org.qii.weiciyuan.ui.preference.filter.AbstractFilterFragment)2