diff --git a/app/src/main/java/com/example/citrusclient/views/MyAdapter.java b/app/src/main/java/com/example/citrusclient/views/MyAdapter.java index a829609..965f91c 100644 --- a/app/src/main/java/com/example/citrusclient/views/MyAdapter.java +++ b/app/src/main/java/com/example/citrusclient/views/MyAdapter.java @@ -105,6 +105,10 @@ Animation animation = AnimationUtils.loadAnimation(holder.itemView.getContext(),R.anim.touch); view.startAnimation(animation); holder.LikeTextView.setTag("liked"); + if(!favoritesMap.containsKey(currentBook.getAccountId())) { + favoritesMap.put(currentBook.getAccountId(), new HashSet<>()); + } + favoritesMap.get(currentBook.getAccountId()).add(currentBook.getBookId()); }else if(holder.LikeTextView.getTag().equals("liked")){ System.out.println(citrus.getAccountId()+"が"+currentBook.getAccountId()+"の"+currentBook.getBookId()+"を解除しました"); booksViewModel.unregisterFavoriteCount(currentBook.getAccountId(), currentBook.getBookId()); @@ -112,6 +116,7 @@ favoritesViewModel.deletefavorite(currentBook.getAccountId(), currentBook.getBookId(), citrus.getAccountId(), citrus.getToken()); holder.LikeTextView.setImageResource(R.drawable.baseline_favorite_border_24); holder.LikeTextView.setTag("unliked"); + favoritesMap.get(currentBook.getAccountId()).remove(currentBook.getBookId()); } }); }