Browse Source

Null check palette object. Should fix https://github.com/austinhuang0131/barinsta/issues/567

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
ae79a35d01
  1. 4
      app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java

4
app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java

@ -81,9 +81,10 @@ public class TopicClusterViewHolder extends RecyclerView.ViewHolder {
}
if (bitmap != null) {
Palette.from(bitmap).generate(p -> {
final Palette.Swatch swatch = p.getDominantSwatch();
final Resources resources = itemView.getResources();
int titleTextColor = resources.getColor(R.color.white);
if (p != null) {
final Palette.Swatch swatch = p.getDominantSwatch();
if (swatch != null) {
backgroundColor.set(swatch.getRgb());
GradientDrawable gd = new GradientDrawable(
@ -92,6 +93,7 @@ public class TopicClusterViewHolder extends RecyclerView.ViewHolder {
titleTextColor = swatch.getTitleTextColor();
binding.background.setBackground(gd);
}
}
titleColor.set(titleTextColor);
binding.title.setTextColor(titleTextColor);
});

Loading…
Cancel
Save