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 965f91c..425c268 100644 --- a/app/src/main/java/com/example/citrusclient/views/MyAdapter.java +++ b/app/src/main/java/com/example/citrusclient/views/MyAdapter.java @@ -109,6 +109,7 @@ favoritesMap.put(currentBook.getAccountId(), new HashSet<>()); } favoritesMap.get(currentBook.getAccountId()).add(currentBook.getBookId()); + currentBook.setFavoritedCount(currentBook.getFavoritedCount()+1); }else if(holder.LikeTextView.getTag().equals("liked")){ System.out.println(citrus.getAccountId()+"が"+currentBook.getAccountId()+"の"+currentBook.getBookId()+"を解除しました"); booksViewModel.unregisterFavoriteCount(currentBook.getAccountId(), currentBook.getBookId()); @@ -117,7 +118,9 @@ holder.LikeTextView.setImageResource(R.drawable.baseline_favorite_border_24); holder.LikeTextView.setTag("unliked"); favoritesMap.get(currentBook.getAccountId()).remove(currentBook.getBookId()); + currentBook.setFavoritedCount(currentBook.getFavoritedCount()-1); } + holder.LikedCountTextView.setText(context.getString(R.string.liked_count_format, currentBook.getFavoritedCount())); }); }