forked from organicmaps/organicmaps
[android] Added UGC impress logic to Booking poi
This commit is contained in:
parent
52cac60f42
commit
b38c26f3a8
3 changed files with 23 additions and 10 deletions
|
@ -61,7 +61,7 @@ void PrepareClassRefs(JNIEnv * env, jclass sponsoredClass)
|
|||
// Sponsored(String rating, String price, String urlBook, String urlDescription)
|
||||
g_sponsoredClassConstructor = jni::GetConstructorID(
|
||||
env, g_sponsoredClass,
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");
|
||||
"(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");
|
||||
// static void onPriceReceived(final String id, final String price, final String currency)
|
||||
g_priceCallback =
|
||||
jni::GetStaticMethodID(env, g_sponsoredClass, "onPriceReceived",
|
||||
|
@ -117,11 +117,10 @@ JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_widget_placepage_Sponsored_na
|
|||
if (!ppInfo.IsSponsored())
|
||||
return nullptr;
|
||||
|
||||
//TODO: consider using the raw value and impress directly.
|
||||
std::string rating = place_page::rating::GetRatingFormatted(ppInfo.GetRatingRawValue());
|
||||
|
||||
return env->NewObject(g_sponsoredClass, g_sponsoredClassConstructor,
|
||||
jni::ToJavaString(env, rating),
|
||||
static_cast<int>(place_page::rating::GetImpress(ppInfo.GetRatingRawValue())),
|
||||
jni::ToJavaString(env, ppInfo.GetApproximatePricing()),
|
||||
jni::ToJavaString(env, ppInfo.GetSponsoredUrl()),
|
||||
jni::ToJavaString(env, ppInfo.GetSponsoredDescriptionUrl()),
|
||||
|
|
|
@ -71,6 +71,7 @@ import com.mapswithme.maps.location.LocationHelper;
|
|||
import com.mapswithme.maps.review.Review;
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.maps.taxi.TaxiManager;
|
||||
import com.mapswithme.maps.ugc.Impress;
|
||||
import com.mapswithme.maps.ugc.UGCController;
|
||||
import com.mapswithme.maps.viator.Viator;
|
||||
import com.mapswithme.maps.viator.ViatorAdapter;
|
||||
|
@ -733,9 +734,13 @@ public class PlacePageView extends RelativeLayout
|
|||
{
|
||||
UiUtils.show(mHotelReview);
|
||||
mReviewAdapter.setItems(new ArrayList<>(Arrays.asList(info.mReviews)));
|
||||
//noinspection ConstantConditions
|
||||
mHotelRating.setText(mSponsored.getRating());
|
||||
mHotelRatingBase.setText(getResources().getString(R.string.booking_based_on_reviews,
|
||||
info.mReviewsAmount));
|
||||
String text = getResources().getString(R.string.booking_based_on_reviews,
|
||||
info.mReviewsAmount);
|
||||
mHotelRatingBase.setText(text);
|
||||
TextView previewReviewCountView = (TextView) mPreviewRatingInfo.findViewById(R.id.tv__review_count);
|
||||
previewReviewCountView.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1449,19 +1454,18 @@ public class PlacePageView extends RelativeLayout
|
|||
colorizeSubtitle();
|
||||
UiUtils.hide(mAvDirection);
|
||||
UiUtils.setTextAndHideIfEmpty(mTvAddress, mapObject.getAddress());
|
||||
//TODO: rating will be shown not only for sponsored objects now, change it when core is ready.
|
||||
boolean sponsored = isSponsored();
|
||||
UiUtils.showIf(sponsored, mPreviewRatingInfo);
|
||||
if (sponsored)
|
||||
{
|
||||
boolean isPriceEmpty = TextUtils.isEmpty(mSponsoredPrice);
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
boolean isRatingEmpty = TextUtils.isEmpty(mSponsored.getRating());
|
||||
//TODO: remove this code when place_page_info.cpp is ready and use rating parameter.
|
||||
mRatingView.setRating(null, mSponsored.getRating());
|
||||
Impress impress = Impress.values()[mSponsored.getImpress()];
|
||||
mRatingView.setRating(impress, mSponsored.getRating());
|
||||
UiUtils.showIf(!isRatingEmpty, mRatingView);
|
||||
mTvSponsoredPrice.setText(mSponsoredPrice);
|
||||
UiUtils.showIf(!isPriceEmpty, mTvSponsoredPrice);
|
||||
//TODO: set review count to mTvReviewCount when core is ready.
|
||||
UiUtils.showIf(!isRatingEmpty || !isPriceEmpty, mPreviewRatingInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.mapswithme.maps.bookmarks.data.MapObject;
|
|||
import com.mapswithme.maps.bookmarks.data.Metadata;
|
||||
import com.mapswithme.maps.gallery.Image;
|
||||
import com.mapswithme.maps.review.Review;
|
||||
import com.mapswithme.maps.ugc.UGC;
|
||||
import com.mapswithme.util.NetworkPolicy;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -195,6 +196,8 @@ public final class Sponsored
|
|||
|
||||
@NonNull
|
||||
private final String mRating;
|
||||
@UGC.Impress
|
||||
private final int mImpress;
|
||||
@NonNull
|
||||
private final String mPrice;
|
||||
@NonNull
|
||||
|
@ -206,11 +209,12 @@ public final class Sponsored
|
|||
@SponsoredType
|
||||
private final int mType;
|
||||
|
||||
public Sponsored(@NonNull String rating, @NonNull String price, @NonNull String url,
|
||||
public Sponsored(@NonNull String rating, @UGC.Impress int impress, @NonNull String price, @NonNull String url,
|
||||
@NonNull String descriptionUrl, @NonNull String reviewUrl,
|
||||
@SponsoredType int type)
|
||||
{
|
||||
mRating = rating;
|
||||
mImpress = impress;
|
||||
mPrice = price;
|
||||
mUrl = url;
|
||||
mDescriptionUrl = descriptionUrl;
|
||||
|
@ -235,6 +239,12 @@ public final class Sponsored
|
|||
return mRating;
|
||||
}
|
||||
|
||||
@UGC.Impress
|
||||
int getImpress()
|
||||
{
|
||||
return mImpress;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
String getPrice()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue