forked from organicmaps/organicmaps
Merge pull request #3805 from mgsergio/price-category
[android] Add hotel rating and price category.
This commit is contained in:
commit
5086726a08
4 changed files with 72 additions and 32 deletions
|
@ -78,9 +78,12 @@ jobject ToJavaResult(Result & result, bool hasPosition, double lat, double lon)
|
|||
jni::TScopedLocalRef address(env, jni::ToJavaString(env, result.GetAddress()));
|
||||
jni::TScopedLocalRef dist(env, jni::ToJavaString(env, distance));
|
||||
jni::TScopedLocalRef cuisine(env, jni::ToJavaString(env, result.GetCuisine()));
|
||||
jni::TScopedLocalRef rating(env, jni::ToJavaString(env, result.GetHotelRating()));
|
||||
jni::TScopedLocalRef pricing(env, jni::ToJavaString(env, result.GetHotelApproximatePricing()));
|
||||
jni::TScopedLocalRef desc(env, env->NewObject(g_descriptionClass, g_descriptionConstructor,
|
||||
featureType.get(), address.get(),
|
||||
dist.get(), cuisine.get(),
|
||||
rating.get(), pricing.get(),
|
||||
result.GetStarsCount(),
|
||||
static_cast<jint>(result.IsOpenNow())));
|
||||
|
||||
|
@ -171,7 +174,7 @@ extern "C"
|
|||
g_resultConstructor = jni::GetConstructorID(env, g_resultClass, "(Ljava/lang/String;Lcom/mapswithme/maps/search/SearchResult$Description;DD[I)V");
|
||||
g_suggestConstructor = jni::GetConstructorID(env, g_resultClass, "(Ljava/lang/String;Ljava/lang/String;DD[I)V");
|
||||
g_descriptionClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/search/SearchResult$Description");
|
||||
g_descriptionConstructor = jni::GetConstructorID(env, g_descriptionClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)V");
|
||||
g_descriptionConstructor = jni::GetConstructorID(env, g_descriptionClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)V");
|
||||
|
||||
g_mapResultsMethod = jni::GetMethodID(env, g_javaListener, "onMapSearchResults", "([Lcom/mapswithme/maps/search/NativeMapSearchListener$Result;JZ)V");
|
||||
g_mapResultClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/search/NativeMapSearchListener$Result");
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:gravity="bottom"
|
||||
android:paddingLeft="@dimen/margin_half"
|
||||
android:paddingRight="@dimen/margin_half"
|
||||
android:paddingTop="@dimen/margin_eighth"
|
||||
|
@ -21,19 +22,6 @@
|
|||
android:textAppearance="@style/MwmTextAppearance.Body4.Light"
|
||||
android:text="@string/closed"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/closed"
|
||||
android:gravity="bottom"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
android:textColor="?colorAccent"
|
||||
tools:text="500 km \u2022 \u2605\u2606\u2606\u2606\u2606"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -54,13 +42,25 @@
|
|||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/title"
|
||||
android:layout_toLeftOf="@id/distance"
|
||||
android:layout_toStartOf="@id/distance"
|
||||
android:layout_toLeftOf="@+id/price_category"
|
||||
android:layout_toStartOf="@id/price_category"
|
||||
android:layout_marginRight="@dimen/margin_half"
|
||||
android:layout_marginTop="@dimen/margin_quarter"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
android:singleLine="true"
|
||||
android:maxLines="2"
|
||||
tools:text="Hotel \u2022 \u2605\u2605\u2605\u2605\u2605"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/price_category"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignBaseline="@id/description"
|
||||
android:layout_marginTop="@dimen/margin_quarter"
|
||||
android:singleLine="true"
|
||||
tools:text="$$$"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/region"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -68,11 +68,24 @@
|
|||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/description"
|
||||
android:layout_toLeftOf="@id/distance"
|
||||
android:layout_toLeftOf="@+id/distance"
|
||||
android:layout_toStartOf="@id/distance"
|
||||
android:layout_marginTop="@dimen/margin_quarter"
|
||||
android:layout_marginRight="@dimen/margin_half"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
android:singleLine="true"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
tools:text="Russia, Moscow & Central, Moscow"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignBaseline="@id/region"
|
||||
android:layout_below="@id/closed"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
android:textColor="?colorAccent"
|
||||
tools:text="500 km"/>
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -146,6 +146,7 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.BaseViewHolder>
|
|||
final TextView mDescription;
|
||||
final TextView mRegion;
|
||||
final TextView mDistance;
|
||||
final TextView mPriceCategory;
|
||||
|
||||
@Override
|
||||
int getTintAttr()
|
||||
|
@ -160,25 +161,41 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.BaseViewHolder>
|
|||
final SpannableStringBuilder tail = new SpannableStringBuilder();
|
||||
|
||||
final int stars = Math.min(result.description.stars, 5);
|
||||
if (stars > 0)
|
||||
if (stars > 0 || !result.description.rating.isEmpty())
|
||||
{
|
||||
// Colorize last dimmed stars
|
||||
final SpannableStringBuilder sb = new SpannableStringBuilder("★ ★ ★ ★ ★");
|
||||
if (stars < 5)
|
||||
if (stars > 0)
|
||||
{
|
||||
final int start = sb.length() - ((5 - stars) * 2 - 1);
|
||||
sb.setSpan(new ForegroundColorSpan(itemView.getResources().getColor(R.color.search_star_dimmed)),
|
||||
start, sb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
// 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(itemView.getResources().getColor(R.color.search_star_dimmed)),
|
||||
start, sb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
tail.append(" • ");
|
||||
tail.append(sb);
|
||||
}
|
||||
|
||||
tail.append(sb);
|
||||
if (!result.description.rating.isEmpty())
|
||||
{
|
||||
final SpannableStringBuilder sb = new SpannableStringBuilder(
|
||||
itemView.getResources().getString(R.string.place_page_booking_rating, result.description.rating));
|
||||
sb.setSpan(new ForegroundColorSpan(itemView.getResources().getColor(R.color.base_green)),
|
||||
0, sb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
||||
tail
|
||||
.append(" • ")
|
||||
.append(sb);
|
||||
}
|
||||
}
|
||||
else if (!TextUtils.isEmpty(result.description.cuisine))
|
||||
tail.append(result.description.cuisine);
|
||||
{
|
||||
tail.append(" • " + result.description.cuisine);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(tail))
|
||||
res.append(" • ")
|
||||
.append(tail);
|
||||
res.append(tail);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -192,6 +209,7 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.BaseViewHolder>
|
|||
mDescription = (TextView) view.findViewById(R.id.description);
|
||||
mRegion = (TextView) view.findViewById(R.id.region);
|
||||
mDistance = (TextView) view.findViewById(R.id.distance);
|
||||
mPriceCategory = (TextView) view.findViewById(R.id.price_category);
|
||||
|
||||
mClosedMarker.setBackgroundDrawable(mClosedMarkerBackground);
|
||||
}
|
||||
|
@ -212,6 +230,7 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.BaseViewHolder>
|
|||
UiUtils.setTextAndHideIfEmpty(mDescription, formatDescription(result));
|
||||
UiUtils.setTextAndHideIfEmpty(mRegion, result.description.region);
|
||||
UiUtils.setTextAndHideIfEmpty(mDistance, result.description.distance);
|
||||
UiUtils.setTextAndHideIfEmpty(mPriceCategory, result.description.pricing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,15 +20,20 @@ public class SearchResult
|
|||
public final String region;
|
||||
public final String distance;
|
||||
public final String cuisine;
|
||||
public final String rating;
|
||||
public final String pricing;
|
||||
public final int stars;
|
||||
public final int openNow;
|
||||
|
||||
public Description(String featureType, String region, String distance, String cuisine, int stars, int openNow)
|
||||
public Description(String featureType, String region, String distance,
|
||||
String cuisine, String rating, String pricing, int stars, int openNow)
|
||||
{
|
||||
this.featureType = featureType;
|
||||
this.region = region;
|
||||
this.distance = distance;
|
||||
this.cuisine = cuisine;
|
||||
this.rating = rating;
|
||||
this.pricing = pricing;
|
||||
this.stars = stars;
|
||||
this.openNow = openNow;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue