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 26dee74..6c00b37 100644 --- a/app/src/main/java/com/example/citrusclient/views/MyAdapter.java +++ b/app/src/main/java/com/example/citrusclient/views/MyAdapter.java @@ -83,6 +83,9 @@ package com.example.citrusclient.views; +import android.app.Activity; +import android.content.Context; +import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -91,16 +94,22 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.example.citrusclient.Citrus; import com.example.citrusclient.R; import com.example.citrusclient.models.Book; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; public class MyAdapter extends RecyclerView.Adapter { private List originalList; // 元のデータリスト private List filteredList; // フィルタリングされたリスト +// private List publicList; +// private List accountIdList; +// private Context context; + public MyAdapter(List originalList) { this.originalList = originalList; this.filteredList = new ArrayList<>(originalList); @@ -117,6 +126,39 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) { Book currentBook = filteredList.get(position); holder.bind(currentBook); + + 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; + } 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); + } + + 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(); +// Activity activity = (Activity) context; +// Citrus citrus = (Citrus) activity.getApplication(); +// citrus.setCurYear(c.get(Calendar.YEAR)); +// citrus.setCurMonth(c.get(Calendar.MONTH) + 1); +// citrus.setCurDay(c.get(Calendar.DATE)); +// citrus.setCurBookId(publicData.getBookId()); +// ((MainActivity) activity).showFragment(new HomeFragment()); +// }); } @Override