diff --git a/app/src/main/java/com/example/citrusclient/views/FavoritesBooksFragment.java b/app/src/main/java/com/example/citrusclient/views/FavoritesBooksFragment.java index 4d27601..160d860 100644 --- a/app/src/main/java/com/example/citrusclient/views/FavoritesBooksFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/FavoritesBooksFragment.java @@ -21,7 +21,10 @@ import com.example.citrusclient.Citrus; import com.example.citrusclient.R; +import com.example.citrusclient.models.Account; import com.example.citrusclient.models.Book; +import com.example.citrusclient.models.BookModel; +import com.example.citrusclient.viewmodels.BooksViewModel; import com.example.citrusclient.viewmodels.FavoritesViewModel; import java.util.ArrayList; @@ -75,7 +78,6 @@ } favoritesViewModel = new ViewModelProvider(this).get(FavoritesViewModel.class); - } @Override @@ -86,17 +88,19 @@ } - private HashMap> bookList; - HashMap books; - HashMap integerBookHashMap; - HashMap> data; + private List bookList; +// HashMap books; +// HashMap integerBookHashMap; +// HashMap> data; FavoritesViewModel favoritesViewModel; + //BooksViewModel booksViewModel; + @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Citrus citrus = (Citrus) (getActivity().getApplication()); - bookList = new HashMap<>(); + bookList = new ArrayList<>(); // いいねした本の一覧を返すのに必要 RecyclerView recyclerView = view.findViewById(R.id.my_favorites_list); //いいねした本の一覧 @@ -116,30 +120,31 @@ } } - +//① class FavoritesBooksAdapter extends RecyclerView.Adapter { - private List books = new ArrayList<>(); + private List books = new ArrayList<>(); //private HashMap integerBookHashMap; //private HashMap> data; - FavoritesBooksAdapter(HashMap> favoritesBooksList) { //初期化 - - for (String account: favoritesBooksList.keySet()){ - for (int number: favoritesBooksList.get(account).keySet()){ - books.add(favoritesBooksList.get(account).get(number)); - } - } - // this.data = data; - // this.integerBookHashMap = new HashMap<>(); + FavoritesBooksAdapter(List favoritesBooksList) { //初期化 + books = favoritesBooksList; +// for (String account: favoritesBooksList.keySet()){ +// for (int number: favoritesBooksList.get(account).keySet()){ +// books.add(favoritesBooksList.get(account).get(number)); +// } +// } + // this.data = data; + // this.integerBookHashMap = new HashMap<>(); } - public void setFavoritesBooks(HashMap> favoritesBooksList) { - for (String account: favoritesBooksList.keySet()){ - for (int number: favoritesBooksList.get(account).keySet()){ - books.add(favoritesBooksList.get(account).get(number)); - } - } + public void setFavoritesBooks(List favoritesBooksList) { + books = favoritesBooksList; +// for (String account: favoritesBooksList.keySet()){ +// for (int number: favoritesBooksList.get(account).keySet()){ +// books.add(favoritesBooksList.get(account).get(number)); +// } +// } notifyDataSetChanged(); } @@ -165,6 +170,11 @@ // for (Integer bookId : bookMap.keySet()) { // Book book = bookMap.get(bookId); // if (count == position){ + +// } +// } +// } +// // 他の人のid名を表示するのに必要 holder.other_id.setText(books.get(position).getAccountId()); // 本の名前を表示 @@ -181,8 +191,9 @@ ((MainActivity) activity).showFragment(new OtherHomeFragment()); }); - - holder.other_icon.setBackgroundTintList(ColorStateList.valueOf(parsedColor)); + //ここにアイコンの色 + int other_iconColor = Color.parseColor(books.get(position).getAccountColor()); + holder.other_icon.setBackgroundTintList(ColorStateList.valueOf(other_iconColor)); } @@ -201,9 +212,10 @@ } } + // これがないとclassにエラー @Override public int getItemCount() { return books.size(); - } // これがないとclassにエラー + } }