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 6c00b37..1086bcf 100644 --- a/app/src/main/java/com/example/citrusclient/views/MyAdapter.java +++ b/app/src/main/java/com/example/citrusclient/views/MyAdapter.java @@ -125,29 +125,18 @@ @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { Book currentBook = filteredList.get(position); - holder.bind(currentBook); + holder.bind(currentBook); // bindメソッドで設定 - holder.authorTextView.setText(filteredList.get(position).getAccountId()); - holder.authorTextView.setHeight(30); - holder.authorTextView.setWidth(100); - - Book publicData = this.filteredList.get(position); - holder.titleTextView.setText(publicData.getTitle()); - + // 背景色の設定 int red, green, blue; - if (publicData.getColor() == null || publicData.getColor().length() < 7) { - red = 255; - green = 255; - blue = 255; + if (currentBook.getColor() == null || currentBook.getColor().length() < 7) { + red = 255; green = 255; blue = 255; } else { - red = Integer.parseInt(publicData.getColor().substring(1, 3), 16); - green = Integer.parseInt(publicData.getColor().substring(3, 5), 16); - blue = Integer.parseInt(publicData.getColor().substring(5, 7), 16); - System.out.println("redColor is "+red); + red = Integer.parseInt(currentBook.getColor().substring(1, 3), 16); + green = Integer.parseInt(currentBook.getColor().substring(3, 5), 16); + blue = Integer.parseInt(currentBook.getColor().substring(5, 7), 16); } - holder.titleTextView.setBackgroundColor(Color.rgb(red, green, blue)); - holder.titleTextView.setTextColor(Color.rgb(255 - red, 255 - green, 255 - blue)); // holder.titleTextView.setOnClickListener(v -> { // Calendar c = Calendar.getInstance(); @@ -170,7 +159,9 @@ public void setBooks(List books) { originalList.clear(); originalList.addAll(books); - filter(""); // 空のクエリで全てのアイテムを表示 + filteredList.clear(); // フィルタリングされたリストもクリア + filteredList.addAll(originalList); // 元のリストの内容を追加 + notifyDataSetChanged(); // アダプターを更新 } // フィルタリングメソッド