Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void deleteCategory() {
- CategoryModel currentCategory = categoryModels.get(getAdapterPosition());
- SharedPreferences spCategories = context.getSharedPreferences("spCategories",
- Context.MODE_PRIVATE);
- spCategories.edit().remove(currentCategory.getCategoryId()).apply();
- categoryModels.remove(currentCategory);
- Toast.makeText(context, R.string.preset_deleted,
- Toast.LENGTH_LONG).show();
- notifyDataSetChanged();
- ElementsRV.deleteItem(context);
- }
- public static void deleteItem(Context context){
- SharedPreferences sp = context.getSharedPreferences("spCategories", Context.MODE_PRIVATE);
- for (int i = 0; i < recipesModelList.size(); i++){
- if (!sp.contains(recipesModelList.get(i).getCategoryName())){
- recipesModelList.get(i).setCategoryName("");
- recipesModelList.get(i).setCategoryBtnColor(0);
- recipesModelList.get(i).setCategoryTextColor(0);
- notifyItemChanged(i); // Non-static method 'notifyItemChanged(int)' cannot be referenced from a static context
- }
- }
- }
Add Comment
Please, Sign In to add comment