Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HotelUtils.java « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1f04228161e8fff68320167ddfc30c5ff267d211 (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 androidx.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;
  }
}