Search in sources :

Example 1 with BlackListH

use of me.zeeroooo.materialfb.Misc.BlackListH 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)

Example 2 with BlackListH

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

the class NotificationsSettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.notifications_settings);
    preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    DBHelper = new DatabaseHelper(getActivity());
    blacklist = new ArrayList<>();
    final Cursor data = DBHelper.getListContents();
    while (data.moveToNext()) {
        if (data.getString(3) != null) {
            blh = new BlackListH(data.getString(3));
            blacklist.add(blh);
        }
    }
    Preference BlackList = findPreference("BlackList");
    BlackList.setOnPreferenceClickListener(this);
    listener = new SharedPreferences.OnSharedPreferenceChangeListener() {

        public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
            switch(key) {
                case "notif_interval":
                    reschedule(prefs);
                    break;
                case "notif_exact":
                    reschedule(prefs);
                    break;
                default:
                    break;
            }
        }
    };
    preferences.registerOnSharedPreferenceChangeListener(listener);
}
Also used : BlackListH(me.zeeroooo.materialfb.Misc.BlackListH) DatabaseHelper(me.zeeroooo.materialfb.Misc.DatabaseHelper) Preference(android.preference.Preference) RingtonePreference(android.preference.RingtonePreference) SharedPreferences(android.content.SharedPreferences) Cursor(android.database.Cursor)

Aggregations

BlackListH (me.zeeroooo.materialfb.Misc.BlackListH)2 DialogInterface (android.content.DialogInterface)1 SharedPreferences (android.content.SharedPreferences)1 Cursor (android.database.Cursor)1 Preference (android.preference.Preference)1 RingtonePreference (android.preference.RingtonePreference)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 BlacklistAdapter (me.zeeroooo.materialfb.Misc.BlacklistAdapter)1 DatabaseHelper (me.zeeroooo.materialfb.Misc.DatabaseHelper)1