blob: 556878e5c2c6bd66bc40d71ddfa192bc4ba5d94f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package com.mapswithme;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import com.mapswithme.maps.R;
public class HotelUtils
{
@NonNull
public static CharSequence formatStars(int stars, @NonNull Resources resources)
{
if (stars <= 0)
throw new AssertionError("Start count must be > 0");
stars = Math.min(stars, 5);
// Colorize last dimmed stars
final SpannableStringBuilder sb = new SpannableStringBuilder("★ ★ ★ ★ ★");
if (stars < 5)
{
final int start = sb.length() - ((5 - stars) * 2 - 1);
sb.setSpan(new ForegroundColorSpan(resources.getColor(R.color.search_star_dimmed)),
start, sb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
return sb;
}
}
|