Skip to content

Commit 42fb114

Browse files
leeyh20iamareebjamal
authored andcommitted
fix: Speaker's color changes when searching (fossasia#2351)
* Add hashmap * Revert "Add hashmap" This reverts commit 3431a46. * Fix color changing problem * Use constant color from resources * Set color to color primary dark
1 parent a10c9af commit 42fb114

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

android/app/src/main/java/org/fossasia/openevent/core/speaker/SpeakerViewHolder.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.graphics.drawable.Drawable;
99
import android.os.Bundle;
1010
import android.support.annotation.Nullable;
11+
import android.support.v4.content.ContextCompat;
1112
import android.support.v7.graphics.Palette;
1213
import android.support.v7.widget.RecyclerView;
1314
import android.text.TextUtils;
@@ -95,8 +96,19 @@ public void bindSpeaker(Speaker speaker) {
9596

9697
final Palette.PaletteAsyncListener paletteAsyncListener = palette -> {
9798
Palette.Swatch swatch = palette.getVibrantSwatch();
98-
if (swatch != null && speakerTextualInfo != null) {
99-
speakerTextualInfo.setBackgroundColor(swatch.getRgb());
99+
if (speakerTextualInfo != null) {
100+
if (swatch != null) {
101+
// bitmap has vibrant swatch profile
102+
speakerTextualInfo.setBackgroundColor(swatch.getRgb());
103+
} else {
104+
Palette.Swatch swatch2 = palette.getDarkMutedSwatch();
105+
if (swatch2 != null) {
106+
// bitmap has dark muted swatch profile
107+
speakerTextualInfo.setBackgroundColor(swatch2.getRgb());
108+
} else {
109+
speakerTextualInfo.setBackgroundColor(ContextCompat.getColor(context, R.color.color_primary_dark));
110+
}
111+
}
100112
}
101113
};
102114

0 commit comments

Comments
 (0)