Guest User

Untitled

a guest
Oct 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. private void deleteCategory() {
  2. CategoryModel currentCategory = categoryModels.get(getAdapterPosition());
  3. SharedPreferences spCategories = context.getSharedPreferences("spCategories",
  4. Context.MODE_PRIVATE);
  5. spCategories.edit().remove(currentCategory.getCategoryId()).apply();
  6. categoryModels.remove(currentCategory);
  7. Toast.makeText(context, R.string.preset_deleted,
  8. Toast.LENGTH_LONG).show();
  9. notifyDataSetChanged();
  10. ElementsRV.deleteItem(context);
  11. }
  12.  
  13. public static void deleteItem(Context context){
  14. SharedPreferences sp = context.getSharedPreferences("spCategories", Context.MODE_PRIVATE);
  15. for (int i = 0; i < recipesModelList.size(); i++){
  16. if (!sp.contains(recipesModelList.get(i).getCategoryName())){
  17. recipesModelList.get(i).setCategoryName("");
  18. recipesModelList.get(i).setCategoryBtnColor(0);
  19. recipesModelList.get(i).setCategoryTextColor(0);
  20. notifyItemChanged(i); // Non-static method 'notifyItemChanged(int)' cannot be referenced from a static context
  21. }
  22. }
  23. }
Add Comment
Please, Sign In to add comment