Search in sources :

Example 1 with BlacklistAdapter

use of me.zeeroooo.materialfb.Misc.BlacklistAdapter in project MaterialFBook by ZeeRooo.

the class NotificationsSettingsFragment method onPreferenceClick.

@Override
public boolean onPreferenceClick(Preference preference) {
    String key = preference.getKey();
    switch(key) {
        case "BlackList":
            AlertDialog.Builder BlacklistDialog = new AlertDialog.Builder(getActivity());
            LayoutInflater inflater = LayoutInflater.from(getActivity());
            View view = inflater.inflate(R.layout.blacklist, null);
            final EditText blword = view.findViewById(R.id.blword_new);
            BlacklistDialog.setView(view);
            BlacklistDialog.setTitle(R.string.blacklist_title);
            adapter = new BlacklistAdapter(getActivity(), blacklist, DBHelper);
            ListView BlackListView = view.findViewById(R.id.BlackListView);
            BlackListView.setAdapter(adapter);
            BlacklistDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    String word = blword.getText().toString();
                    if (!word.equals("")) {
                        blh = new BlackListH(word);
                        DBHelper.addData(null, null, blh.getWord());
                        blacklist.add(blh);
                        adapter.notifyDataSetChanged();
                    }
                }
            });
            BlacklistDialog.setCancelable(false);
            BlacklistDialog.show();
            return true;
    }
    return false;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) ListView(android.widget.ListView) ListView(android.widget.ListView) BlackListH(me.zeeroooo.materialfb.Misc.BlackListH) BlacklistAdapter(me.zeeroooo.materialfb.Misc.BlacklistAdapter) LayoutInflater(android.view.LayoutInflater)

Aggregations

DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 EditText (android.widget.EditText)1 ListView (android.widget.ListView)1 BlackListH (me.zeeroooo.materialfb.Misc.BlackListH)1 BlacklistAdapter (me.zeeroooo.materialfb.Misc.BlacklistAdapter)1