diff --git a/app/src/main/java/com/example/citrusclient/views/MyBookshelfFragment.java b/app/src/main/java/com/example/citrusclient/views/MyBookshelfFragment.java index b7f9039..291daab 100644 --- a/app/src/main/java/com/example/citrusclient/views/MyBookshelfFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/MyBookshelfFragment.java @@ -170,9 +170,24 @@ public void onBindViewHolder(@NonNull MyBookViewHolder holder, int position) { Book bookData = this.bookList.get(position); holder.bookButton.setText(bookData.getTitle()); - int red = Integer.parseInt(bookData.getColor().substring(1, 3), 16); - int green = Integer.parseInt(bookData.getColor().substring(3, 5), 16); - int blue = Integer.parseInt(bookData.getColor().substring(5, 7), 16); + int red; + int green; + int blue; + if (bookData.getColor() == null){ + red = 255; + green = 255; + blue = 255; + } + else if(bookData.getColor().length() < 7){ + red = 255; + green = 255; + blue = 255; + }else{ + red = Integer.parseInt(bookData.getColor().substring(1, 3), 16); + green = Integer.parseInt(bookData.getColor().substring(3, 5), 16); + blue = Integer.parseInt(bookData.getColor().substring(5, 7), 16); + } + holder.bookButton.setBackgroundColor(Color.rgb(red, green, blue)); holder.bookButton.setTextColor(Color.rgb(255 - red, 255 - green, 255 - blue)); holder.bookButton.setOnClickListener(v -> {