forked from organicmaps/organicmaps
[android] hotel textual impression for PP
This commit is contained in:
parent
bf6f8e5698
commit
7a7f190e30
2 changed files with 37 additions and 8 deletions
|
@ -3,16 +3,23 @@ package com.mapswithme.maps.ugc;
|
|||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
public enum Impress
|
||||
{
|
||||
NONE(R.drawable.ic_24px_rating_normal, R.color.rating_none),
|
||||
HORRIBLE(R.drawable.ic_24px_rating_horrible, R.color.rating_horrible),
|
||||
BAD(R.drawable.ic_24px_rating_bad, R.color.rating_bad),
|
||||
NORMAL(R.drawable.ic_24px_rating_normal, R.color.rating_normal),
|
||||
GOOD(R.drawable.ic_24px_rating_good, R.color.rating_good),
|
||||
EXCELLENT(R.drawable.ic_24px_rating_excellent, R.color.rating_excellent),
|
||||
HORRIBLE(R.drawable.ic_24px_rating_horrible, R.color.rating_horrible, R.color.rating_horrible,
|
||||
R.string.placepage_rate_horrible),
|
||||
BAD(R.drawable.ic_24px_rating_bad, R.color.rating_bad, R.color.rating_bad,
|
||||
R.string.placepage_rate_bad),
|
||||
NORMAL(R.drawable.ic_24px_rating_normal, R.color.rating_normal, R.color.rating_normal,
|
||||
R.string.placepage_rate_normal),
|
||||
GOOD(R.drawable.ic_24px_rating_good, R.color.rating_good, R.color.rating_good,
|
||||
R.string.placepage_rate_good),
|
||||
EXCELLENT(R.drawable.ic_24px_rating_excellent, R.color.rating_excellent, R.color.rating_excellent,
|
||||
R.string.placepage_rate_excellent),
|
||||
COMING_SOON(R.drawable.ic_24px_rating_coming_soon, R.color.rating_coming_soon),
|
||||
POPULAR(R.drawable.ic_thumb_up, R.color.rating_coming_soon),
|
||||
DISCOUNT(R.drawable.ic_thumb_up, android.R.color.white, R.color.rating_coming_soon);
|
||||
|
@ -23,6 +30,8 @@ public enum Impress
|
|||
private final int mTextColor;
|
||||
@ColorRes
|
||||
private final int mBgColor;
|
||||
@StringRes
|
||||
private final int mTextId;
|
||||
|
||||
Impress(@DrawableRes int smile, @ColorRes int color)
|
||||
{
|
||||
|
@ -31,9 +40,14 @@ public enum Impress
|
|||
|
||||
Impress(@DrawableRes int smile, @ColorRes int color, @ColorRes int bgColor)
|
||||
{
|
||||
this(smile, color, bgColor, UiUtils.NO_ID);
|
||||
}
|
||||
|
||||
Impress(@DrawableRes int smile, @ColorRes int color, @ColorRes int bgColor, @StringRes int textId) {
|
||||
mDrawableId = smile;
|
||||
mTextColor = color;
|
||||
mBgColor = bgColor;
|
||||
mTextId = textId;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
|
@ -53,4 +67,13 @@ public enum Impress
|
|||
{
|
||||
return mBgColor;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public int getTextId()
|
||||
{
|
||||
if (mTextId == UiUtils.NO_ID)
|
||||
throw new UnsupportedOperationException(String.format("Impress %s does't support textual" +
|
||||
"presentation", name()));
|
||||
return mTextId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -921,9 +921,15 @@ public class PlacePageView extends NestedScrollViewClickFixed
|
|||
{
|
||||
UiUtils.show(mHotelReview);
|
||||
mReviewAdapter.setItems(new ArrayList<>(Arrays.asList(info.mReviews)));
|
||||
//noinspection ConstantConditions
|
||||
mHotelRating.setText(getContext().getString(R.string.place_page_booking_rating,
|
||||
mSponsored.getRating()));
|
||||
Objects.requireNonNull(mSponsored);
|
||||
Impress impress = Impress.values()[mSponsored.getImpress()];
|
||||
Context context = getContext();
|
||||
String ratingText = context.getString(R.string.place_page_booking_rating,
|
||||
mSponsored.getRating())
|
||||
.concat(" (")
|
||||
.concat(context.getString(impress.getTextId()))
|
||||
.concat(")");
|
||||
mHotelRating.setText(ratingText);
|
||||
int reviewsCount = (int) info.mReviewsAmount;
|
||||
String text = getResources().getQuantityString(
|
||||
R.plurals.placepage_summary_rating_description, reviewsCount, reviewsCount);
|
||||
|
|
Loading…
Add table
Reference in a new issue