| |
---|
| | holder.LikeTextView.setImageResource(R.drawable.baseline_favorite_24); |
---|
| | 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()); |
---|
| | holder.LikedCountTextView.setText(context.getString(R.string.liked_count_format, currentBook.getFavoritedCount())); |
---|
| | 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()); |
---|
| | } |
---|
| | }); |
---|
| | } |
---|
| | |
---|
| |
---|
| | |