完成
1 parent 43fba57 commit 4d64749c7c6fbc6eaeb6a65c70f3d70be9137885
k-sumita authored on 17 Oct
Showing 2 changed files
View
9
app/src/main/java/com/example/citrusclient/views/FavoritesBooksFragment.java
// HashMap<Integer, Book> bookMap = favoritesBooksList.get(otherAccountId);
// for (Integer bookId : bookMap.keySet()) {
// Book book = bookMap.get(bookId);
// if (count == position){
// 他の人のid名を表示するのに必要
holder.other_id.setText(books.get(position).getAccountId());
// 本の名前を表示
holder.favorites_book.setText(books.get(position).getTitle());
int parsedColor = Color.parseColor(books.get(position).getColor());
holder.favorites_book.setBackgroundTintList(ColorStateList.valueOf(parsedColor));
 
Context context = holder.itemView.getContext();
holder.favorites_book.setOnClickListener(v -> {
Activity activity = (Activity) context;
Citrus citrus = (Citrus) activity.getApplication();
citrus.setCurLookingBookId(books.get(position).getBookId());
((MainActivity) activity).showFragment(new OtherHomeFragment());
});
 
 
holder.other_icon.setBackgroundTintList(ColorStateList.valueOf(parsedColor));
 
}
 
 
static class FavoritesBooksViewHolder extends RecyclerView.ViewHolder {
TextView other_id;
Button favorites_book;
 
Button other_icon;
 
public FavoritesBooksViewHolder(@NonNull View itemView) {
super(itemView);
favorites_book = itemView.findViewById(R.id.favorites_book);
other_id = itemView.findViewById(R.id.other_id);
other_icon = itemView.findViewById(R.id.other_icon);
}
}
 
@Override
View
90
app/src/main/res/layout/a_favorites_book.xml
android:layout_height="wrap_content"
android:layout_margin="12dp"
tools:ignore="ExtraText">
 
<Button
android:id="@+id/favorites_book"
android:layout_width="600dp"
android:layout_height="150dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/other_id"
app:layout_constraintVertical_bias="1.0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
 
<TextView
android:id="@+id/other_id"
android:layout_width="100dp"
android:layout_height="30dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.013"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
 
<Button
android:id="@+id/other_icon"
android:layout_width="35dp"
android:layout_height="45dp"
android:backgroundTint="#FFD1D1D1"
android:shape="oval"
app:cornerRadius="60dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.103" />
 
<TextView
android:id="@+id/other_id"
android:layout_width="100dp"
android:layout_height="30dp"
android:text="TextView" />
 
</LinearLayout>
 
<Button
android:id="@+id/favorites_book"
android:layout_width="600dp"
android:layout_height="150dp"
android:text="Button" />
 
</LinearLayout>
 
</androidx.constraintlayout.widget.ConstraintLayout>