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;
}
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);
}
Aggregations