[android] Modified PlacePage Ui, modified MapObject and SearchResult POJO

This commit is contained in:
Dmitry Donskoy 2018-08-07 09:48:46 +03:00 committed by Aleksey Belousov
parent 79ba163445
commit 7c07e383d5
13 changed files with 245 additions and 115 deletions

View file

@ -271,6 +271,8 @@ jmethodID g_resultConstructor;
jmethodID g_suggestConstructor;
jclass g_descriptionClass;
jmethodID g_descriptionConstructor;
jclass g_popularityClass;
jmethodID g_popularityConstructor;
// Implements 'NativeMapSearchListener' java interface.
jmethodID g_mapResultsMethod;
@ -356,10 +358,13 @@ jobject ToJavaResult(Result & result, search::ProductInfo const & productInfo, b
static_cast<jboolean>(popularityHasHigherPriority)));
jni::TScopedLocalRef name(env, jni::ToJavaString(env, result.GetString()));
jni::TScopedLocalRef popularity(env, env->NewObject(g_popularityClass,
g_popularityConstructor,
static_cast<jint>(result.GetRankingInfo().m_popularity)));
jobject ret =
env->NewObject(g_resultClass, g_resultConstructor, name.get(), desc.get(), ll.lat, ll.lon,
ranges.get(), result.IsHotel(), productInfo.m_isLocalAdsCustomer,
static_cast<jint>(result.GetRankingInfo().m_popularity));
popularity.get());
ASSERT(ret, ());
return ret;
@ -633,7 +638,7 @@ extern "C"
g_resultClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/search/SearchResult");
g_resultConstructor = jni::GetConstructorID(
env, g_resultClass,
"(Ljava/lang/String;Lcom/mapswithme/maps/search/SearchResult$Description;DD[IZZI)V");
"(Ljava/lang/String;Lcom/mapswithme/maps/search/SearchResult$Description;DD[IZZLcom/mapswithme/maps/search/Popularity;)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,
@ -641,6 +646,9 @@ extern "C"
"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;"
"Ljava/lang/String;Ljava/lang/String;FIIZ)V");
g_popularityClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/search/Popularity");
g_popularityConstructor = jni::GetConstructorID(env, g_popularityClass, "(I)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");

View file

@ -43,6 +43,16 @@ jobject CreateRating(JNIEnv * env, std::string const & name)
return env->NewObject(g_ratingClazz, ratingCtorId, nameRef.get(), place_page::kIncorrectRating);
}
jobject CreatePopularity(JNIEnv * env, place_page::Info const & info)
{
static jclass const popularityClass =
jni::GetGlobalClassRef(env, "com/mapswithme/maps/search/Popularity");
static jmethodID const popularity =
jni::GetConstructorID(env, popularityClass, "(I)V");
auto const popularityValue = info.GetPopularity();
return env->NewObject(popularityClass, popularity, static_cast<jint>(popularityValue));
}
jobject CreateHotelType(JNIEnv * env, place_page::Info const & info)
{
if (!info.GetHotelType())
@ -67,7 +77,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion
string const & bookingSearchUrl, jobject const & localAdInfo,
jobject const & routingPointInfo, bool isExtendedView, bool shouldShowUGC,
bool canBeRated, bool canBeReviewed, jobjectArray jratings,
jobject const & hotelType, int priceRate)
jobject const & hotelType, int priceRate, jobject const & popularity)
{
// public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType, String title,
// @Nullable String secondaryTitle, String subtitle, String address,
@ -85,7 +95,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion
"String;[Lcom/mapswithme/maps/ads/Banner;[ILjava/lang/String;"
"Lcom/mapswithme/maps/ads/LocalAdInfo;"
"Lcom/mapswithme/maps/routing/RoutePointInfo;ZZZZ[Lcom/mapswithme/maps/ugc/UGC$Rating;"
"Lcom/mapswithme/maps/search/HotelsFilter$HotelType;I)V");
"Lcom/mapswithme/maps/search/HotelsFilter$HotelType;ILcom/mapswithme/maps/search/Popularity;)V");
//public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
static jmethodID const featureCtorId =
@ -107,7 +117,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion
jbanners, jTaxiTypes, jBookingSearchUrl.get(), localAdInfo, routingPointInfo,
static_cast<jboolean>(isExtendedView), static_cast<jboolean>(shouldShowUGC),
static_cast<jboolean>(canBeRated), static_cast<jboolean>(canBeReviewed),
jratings, hotelType, priceRate);
jratings, hotelType, priceRate, popularity);
InjectMetadata(env, g_mapObjectClazz, mapObject, metadata);
return mapObject;
@ -130,6 +140,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
routingPointInfo.reset(CreateRoutePointInfo(env, info));
jni::TScopedLocalRef hotelType(env, CreateHotelType(env, info));
jni::TScopedLocalRef popularity(env, CreatePopularity(env, info));
int priceRate = info.GetRawApproximatePricing().get_value_or(kPriceRateUndefined);
@ -143,7 +154,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
// boolean isExtendedView, boolean shouldShowUGC, boolean canBeRated,
// boolean canBeReviewed, @Nullable UGC.Rating[] ratings,
// @Nullable HotelsFilter.HotelType hotelType,
// @PriceFilterView.PriceDef int priceRate)
// @PriceFilterView.PriceDef int priceRate,
// @NotNull com.mapswithme.maps.search.Popularity entity)
static jmethodID const ctorId =
jni::GetConstructorID(env, g_bookmarkClazz,
"(Lcom/mapswithme/maps/bookmarks/data/FeatureId;JJLjava/lang/String;"
@ -152,7 +164,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
"Lcom/mapswithme/maps/ads/LocalAdInfo;"
"Lcom/mapswithme/maps/routing/RoutePointInfo;"
"ZZZZ[Lcom/mapswithme/maps/ugc/UGC$Rating;"
"Lcom/mapswithme/maps/search/HotelsFilter$HotelType;I)V");
"Lcom/mapswithme/maps/search/HotelsFilter$HotelType;"
"ILcom/mapswithme/maps/search/Popularity;)V");
// public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
static jmethodID const featureCtorId =
jni::GetConstructorID(env, g_featureIdClazz, "(Ljava/lang/String;JI)V");
@ -174,7 +187,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
static_cast<jlong>(bookmarkId), jTitle.get(), jSecondaryTitle.get(), jSubtitle.get(),
jAddress.get(), jbanners.get(), jTaxiTypes.get(), jBookingSearchUrl.get(),
localAdInfo.get(), routingPointInfo.get(), info.IsPreviewExtended(), info.ShouldShowUGC(),
info.CanBeRated(), info.CanBeReviewed(), jratings.get(), hotelType.get(), priceRate);
info.CanBeRated(), info.CanBeReviewed(), jratings.get(), hotelType.get(), priceRate,
popularity.get());
if (info.IsFeature())
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
@ -192,7 +206,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
info.GetAddress(), {}, "", jbanners.get(), jTaxiTypes.get(),
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(),
info.IsPreviewExtended(), info.ShouldShowUGC(), info.CanBeRated(),
info.CanBeReviewed(), jratings.get(), hotelType.get(), priceRate);
info.CanBeReviewed(), jratings.get(), hotelType.get(), priceRate,
popularity.get());
}
if (info.HasApiUrl())
@ -203,7 +218,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
info.GetAddress(), info.GetMetadata(), info.GetApiUrl(), jbanners.get(), jTaxiTypes.get(),
info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(), info.IsPreviewExtended(),
info.ShouldShowUGC(), info.CanBeRated(), info.CanBeReviewed(), jratings.get(),
hotelType.get(), priceRate);
hotelType.get(), priceRate, popularity.get());
}
return CreateMapObject(
@ -212,7 +227,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
info.GetAddress(), info.IsFeature() ? info.GetMetadata() : Metadata(), "", jbanners.get(),
jTaxiTypes.get(), info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(),
info.IsPreviewExtended(), info.ShouldShowUGC(), info.CanBeRated(), info.CanBeReviewed(),
jratings.get(), hotelType.get(), priceRate);
jratings.get(), hotelType.get(), priceRate, popularity.get());
}
jobjectArray ToBannersArray(JNIEnv * env, vector<ads::Banner> const & banners)

View file

@ -30,7 +30,7 @@
<com.mapswithme.maps.widget.RatingView
android:id="@+id/popular"
android:layout_width="wrap_content"
android:layout_height="@dimen/rating_view_height_small"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_eighth"
android:layout_marginBottom="@dimen/margin_half"
android:layout_marginStart="@dimen/margin_half"
@ -41,7 +41,6 @@
android:paddingEnd="@dimen/margin_quarter_plus"
android:paddingTop="@dimen/margin_quarter"
android:paddingBottom="@dimen/margin_quarter"
android:gravity="center"
android:layout_gravity="center_horizontal|start"
android:textSize="@dimen/text_size_body_4"
@ -130,7 +129,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignBaseline="@id/region"
android:layout_below="@id/closed"
android:layout_below="@id/metadata_container"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:textColor="?colorAccent"
tools:text="500 km"/>

View file

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center_vertical"
android:paddingTop="@dimen/margin_base">
@ -18,39 +19,59 @@
android:visibility="gone"
tools:visibility="visible"/>
<TextView
android:id="@+id/tv__title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
<LinearLayout
android:id="@+id/title_container"
android:layout_toEndOf="@id/downloader_status_frame"
android:layout_toRightOf="@id/downloader_status_frame"
android:layout_marginTop="@dimen/margin_quarter"
android:layout_marginEnd="@dimen/margin_base"
android:layout_marginRight="@dimen/margin_base"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginLeft="@dimen/margin_base"
android:layout_toEndOf="@id/downloader_status_frame"
android:layout_toRightOf="@id/downloader_status_frame"
android:layout_toLeftOf="@+id/direction_frame"
android:layout_toStartOf="@+id/direction_frame"
android:ellipsize="end"
android:fontFamily="@string/robotoMedium"
android:maxLines="@integer/pp_title_lines"
android:textAppearance="@style/MwmTextAppearance.Title"
tools:background="#C0800000"
tools:ignore="UnusedAttribute"
tools:text="Title"/>
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv__title"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@string/robotoMedium"
android:maxLines="@integer/pp_title_lines"
android:textAppearance="@style/MwmTextAppearance.Title"
tools:background="#C0800000"
tools:ignore="UnusedAttribute"
tools:text="Title"/>
<com.mapswithme.maps.widget.RatingView
android:id="@+id/popular_rating_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/margin_quarter_plus"
android:paddingStart="@dimen/margin_quarter_plus"
android:paddingRight="@dimen/margin_quarter_plus"
android:paddingEnd="@dimen/margin_quarter_plus"
android:paddingTop="@dimen/margin_quarter"
android:paddingBottom="@dimen/margin_quarter"
android:layout_gravity="center"
android:textSize="@dimen/text_size_body_4"
android:text="@string/popular_place"
android:visibility="gone"
app:rating="popular"/>
</LinearLayout>
<TextView
android:id="@+id/tv__secondary_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv__title"
android:layout_below="@id/title_container"
android:layout_alignWithParentIfMissing="true"
android:layout_marginTop="@dimen/margin_quarter"
android:layout_marginEnd="@dimen/margin_base"
android:layout_marginRight="@dimen/margin_base"
android:layout_alignLeft="@id/tv__title"
android:layout_alignStart="@id/tv__title"
android:layout_alignLeft="@id/title_container"
android:layout_alignStart="@id/title_container"
android:layout_toLeftOf="@id/direction_frame"
android:layout_toStartOf="@id/direction_frame"
android:ellipsize="end"
@ -81,11 +102,13 @@
tools:text="Subtitle, very very very very very very very long"/>
<LinearLayout
android:id="@id/direction_frame"
android:id="@+id/direction_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_quarter"
android:layout_marginEnd="@dimen/margin_base"
android:layout_marginRight="@dimen/margin_base"
android:layout_below="@id/title_container"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true"

View file

@ -11,6 +11,7 @@ import com.mapswithme.maps.ads.Banner;
import com.mapswithme.maps.ads.LocalAdInfo;
import com.mapswithme.maps.routing.RoutePointInfo;
import com.mapswithme.maps.search.HotelsFilter;
import com.mapswithme.maps.search.Popularity;
import com.mapswithme.maps.search.PriceFilterView;
import com.mapswithme.maps.ugc.UGC;
import com.mapswithme.util.Constants;
@ -32,11 +33,12 @@ public class Bookmark extends MapObject
@Nullable LocalAdInfo localAdInfo, @Nullable RoutePointInfo routePointInfo,
boolean isExtendedView, boolean shouldShowUGC, boolean canBeRated,
boolean canBeReviewed, @Nullable UGC.Rating[] ratings,
@Nullable HotelsFilter.HotelType hotelType, @PriceFilterView.PriceDef int priceRate)
@Nullable HotelsFilter.HotelType hotelType, @PriceFilterView.PriceDef int priceRate,
@NonNull Popularity popularity)
{
super(featureId, BOOKMARK, title, secondaryTitle, subtitle, address, 0, 0, "",
banners, reachableByTaxiTypes, bookingSearchUrl, localAdInfo, routePointInfo,
isExtendedView, shouldShowUGC, canBeRated, canBeReviewed, ratings, hotelType, priceRate);
isExtendedView, shouldShowUGC, canBeRated, canBeReviewed, ratings, hotelType, priceRate, popularity);
mCategoryId = categoryId;
mBookmarkId = bookmarkId;

View file

@ -11,6 +11,8 @@ import com.mapswithme.maps.ads.Banner;
import com.mapswithme.maps.ads.LocalAdInfo;
import com.mapswithme.maps.routing.RoutePointInfo;
import com.mapswithme.maps.search.HotelsFilter;
import com.mapswithme.maps.search.Popularity;
import com.mapswithme.maps.search.PopularityProvider;
import com.mapswithme.maps.search.PriceFilterView;
import com.mapswithme.maps.taxi.TaxiType;
import com.mapswithme.maps.ugc.UGC;
@ -23,7 +25,7 @@ import java.util.List;
// TODO(yunikkk): Refactor. Displayed information is different from edited information, and it's better to
// separate them. Simple getters from jni place_page::Info and osm::EditableFeature should be enough.
public class MapObject implements Parcelable
public class MapObject implements Parcelable, PopularityProvider
{
@Retention(RetentionPolicy.SOURCE)
@IntDef({ POI, API_POINT, BOOKMARK, MY_POSITION, SEARCH })
@ -65,6 +67,8 @@ public class MapObject implements Parcelable
private final boolean mShouldShowUGC;
private final boolean mCanBeRated;
private final boolean mCanBeReviewed;
@NonNull
private final Popularity mPopularity;
@Nullable
private ArrayList<UGC.Rating> mRatings;
@Nullable
@ -79,12 +83,13 @@ public class MapObject implements Parcelable
@Nullable LocalAdInfo localAdInfo, @Nullable RoutePointInfo routePointInfo,
boolean isExtendedView, boolean shouldShowUGC, boolean canBeRated,
boolean canBeReviewed, @Nullable UGC.Rating[] ratings,
@Nullable HotelsFilter.HotelType hotelType, @PriceFilterView.PriceDef int priceRate)
@Nullable HotelsFilter.HotelType hotelType, @PriceFilterView.PriceDef int priceRate,
@NonNull Popularity popularity)
{
this(featureId, mapObjectType, title, secondaryTitle,
subtitle, address, lat, lon, new Metadata(), apiId, banners,
types, bookingSearchUrl, localAdInfo, routePointInfo, isExtendedView, shouldShowUGC,
canBeRated, canBeReviewed, ratings, hotelType, priceRate);
canBeRated, canBeReviewed, ratings, hotelType, priceRate, popularity);
}
public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType,
@ -95,7 +100,7 @@ public class MapObject implements Parcelable
@Nullable RoutePointInfo routePointInfo, boolean isExtendedView,
boolean shouldShowUGC, boolean canBeRated, boolean canBeReviewed,
@Nullable UGC.Rating[] ratings, @Nullable HotelsFilter.HotelType hotelType,
@PriceFilterView.PriceDef int priceRate)
@PriceFilterView.PriceDef int priceRate, @NonNull Popularity popularity)
{
mFeatureId = featureId;
mMapObjectType = mapObjectType;
@ -114,6 +119,7 @@ public class MapObject implements Parcelable
mShouldShowUGC = shouldShowUGC;
mCanBeRated = canBeRated;
mCanBeReviewed = canBeReviewed;
mPopularity = popularity;
if (banners != null)
mBanners = new ArrayList<>(Arrays.asList(banners));
if (taxiTypes != null)
@ -131,7 +137,7 @@ public class MapObject implements Parcelable
protected MapObject(@MapObjectType int type, Parcel source)
{
//noinspection ResourceType
this((FeatureId) source.readParcelable(FeatureId.class.getClassLoader()), // FeatureId
this(source.readParcelable(FeatureId.class.getClassLoader()), // FeatureId
type, // MapObjectType
source.readString(), // Title
source.readString(), // SecondaryTitle
@ -139,20 +145,21 @@ public class MapObject implements Parcelable
source.readString(), // Address
source.readDouble(), // Lat
source.readDouble(), // Lon
(Metadata) source.readParcelable(Metadata.class.getClassLoader()),
source.readParcelable(Metadata.class.getClassLoader()),
source.readString(), // ApiId;
null, // mBanners
null, // mReachableByTaxiTypes
source.readString(), // BookingSearchUrl
(LocalAdInfo) source.readParcelable(LocalAdInfo.class.getClassLoader()), // LocalAdInfo
(RoutePointInfo) source.readParcelable(RoutePointInfo.class.getClassLoader()), // RoutePointInfo
source.readParcelable(LocalAdInfo.class.getClassLoader()), // LocalAdInfo
source.readParcelable(RoutePointInfo.class.getClassLoader()), // RoutePointInfo
source.readInt() == 1, // mExtendedView
source.readInt() == 1, // mShouldShowUGC
source.readInt() == 1, // mCanBeRated;
source.readInt() == 1, // mCanBeReviewed
null, // mRatings
source.readParcelable(HotelsFilter.HotelType.class.getClassLoader()), // mHotelType
source.readInt()); // mPriceRate
source.readInt(), // mPriceRate
source.readParcelable(Popularity.class.getClassLoader()));
mBanners = readBanners(source);
mReachableByTaxiTypes = readTaxiTypes(source);
@ -167,7 +174,8 @@ public class MapObject implements Parcelable
"", subtitle, "", lat, lon, "", null,
null, "", null, null, false /* isExtendedView */,
false /* shouldShowUGC */, false /* canBeRated */, false /* canBeReviewed */,
null /* ratings */, null /* mHotelType */, PriceFilterView.UNDEFINED);
null /* ratings */, null /* mHotelType */,
PriceFilterView.UNDEFINED, Popularity.defaultInstance());
}
@Nullable
@ -262,6 +270,13 @@ public class MapObject implements Parcelable
return mAddress;
}
@NonNull
@Override
public Popularity getPopularity()
{
return mPopularity;
}
@NonNull
public String getMetadata(Metadata.MetadataType type)
{
@ -437,6 +452,7 @@ public class MapObject implements Parcelable
dest.writeTypedList(mBanners);
dest.writeList(mReachableByTaxiTypes);
dest.writeTypedList(mRatings);
dest.writeParcelable(mPopularity,0);
}
@Override

View file

@ -1,18 +0,0 @@
package com.mapswithme.maps.discovery;
import android.support.annotation.NonNull;
public enum Popularity
{
NOT_POPULAR,
POPULAR;
@NonNull
public static Popularity makeInstance(int index)
{
if (index < 0)
throw new AssertionError("Incorrect negative index = " + index);
return index > 0 ? POPULAR : NOT_POPULAR;
}
}

View file

@ -20,7 +20,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.mapswithme.HotelUtils;
import com.mapswithme.maps.R;
import com.mapswithme.maps.discovery.Popularity;
import com.mapswithme.maps.search.Popularity;
import com.mapswithme.maps.ugc.Impress;
import com.mapswithme.maps.ugc.UGC;
import com.mapswithme.maps.widget.RatingView;
@ -250,7 +250,7 @@ public class Holders
UiUtils.setTextAndHideIfEmpty(mTitle, item.getTitle());
UiUtils.setTextAndHideIfEmpty(mSubtitle, item.getSubtitle());
UiUtils.setTextAndHideIfEmpty(mDistance, item.getDistance());
UiUtils.showIf(item.getPopularity() == Popularity.POPULAR, mPopularTagRating);
UiUtils.showIf(item.getPopularity().getType() == Popularity.Type.POPULAR, mPopularTagRating);
float rating = item.getRating();
Impress impress = Impress.values()[UGC.nativeToImpress(rating)];

View file

@ -5,12 +5,11 @@ import android.support.annotation.Nullable;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.discovery.Popularity;
import com.mapswithme.maps.search.Popularity;
import com.mapswithme.maps.search.SearchResult;
import static com.mapswithme.maps.gallery.Constants.TYPE_MORE;
import static com.mapswithme.maps.gallery.Constants.TYPE_PRODUCT;
import static com.mapswithme.util.Constants.Rating.RATING_INCORRECT_VALUE;
public class Items

View file

@ -0,0 +1,70 @@
package com.mapswithme.maps.search;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
public class Popularity implements Parcelable
{
@NonNull
private final Type mType;
public Popularity(int popularity)
{
mType = Type.makeInstance(popularity);
}
@NonNull
public Type getType()
{
return mType;
}
@NonNull
public static Popularity defaultInstance() {
return new Popularity(Type.NOT_POPULAR.ordinal());
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.mType.ordinal());
}
protected Popularity(Parcel in) {
int tmpMPopularity = in.readInt();
this.mType = Type.values()[tmpMPopularity];
}
public static final Creator<Popularity> CREATOR = new Creator<Popularity>() {
@Override
public Popularity createFromParcel(Parcel source) {
return new Popularity(source);
}
@Override
public Popularity[] newArray(int size) {
return new Popularity[size];
}
};
public enum Type
{
NOT_POPULAR,
POPULAR;
@NonNull
public static Type makeInstance(int index)
{
if (index < 0)
throw new AssertionError("Incorrect negative index = " + index);
return index > 0 ? POPULAR : NOT_POPULAR;
}
}
}

View file

@ -0,0 +1,9 @@
package com.mapswithme.maps.search;
import android.support.annotation.NonNull;
public interface PopularityProvider
{
@NonNull
Popularity getPopularity();
}

View file

@ -3,7 +3,6 @@ package com.mapswithme.maps.search;
import android.support.annotation.NonNull;
import com.mapswithme.maps.bookmarks.data.FeatureId;
import com.mapswithme.maps.discovery.Popularity;
import static com.mapswithme.maps.search.SearchResultTypes.TYPE_LOCAL_ADS_CUSTOMER;
import static com.mapswithme.maps.search.SearchResultTypes.TYPE_RESULT;
@ -13,7 +12,7 @@ import static com.mapswithme.maps.search.SearchResultTypes.TYPE_SUGGEST;
* Class instances are created from native code.
*/
@SuppressWarnings("unused")
public class SearchResult implements SearchData
public class SearchResult implements SearchData, PopularityProvider
{
// Values should match osm::YesNoUnknown enum.
public static final int OPEN_NOW_UNKNOWN = 0;
@ -77,23 +76,22 @@ public class SearchResult implements SearchData
this.isHotel = false;
this.description = null;
this.type = TYPE_SUGGEST;
this.highlightRanges = highlightRanges;
mPopularity = Popularity.NOT_POPULAR;
mPopularity = Popularity.defaultInstance();
}
public SearchResult(String name, Description description, double lat, double lon, int[] highlightRanges,
boolean isHotel, boolean isLocalAdsCustomer, int popularity)
boolean isHotel, boolean isLocalAdsCustomer, @NonNull Popularity popularity)
{
this.type = isLocalAdsCustomer ? TYPE_LOCAL_ADS_CUSTOMER : TYPE_RESULT;
this.name = name;
this.isHotel = isHotel;
mPopularity = popularity;
this.suggestion = null;
this.lat = lat;
this.lon = lon;
this.description = description;
this.highlightRanges = highlightRanges;
mPopularity = Popularity.makeInstance(popularity);
}
@Override
@ -103,6 +101,7 @@ public class SearchResult implements SearchData
}
@NonNull
@Override
public Popularity getPopularity()
{
return mPopularity;

View file

@ -71,6 +71,7 @@ import com.mapswithme.maps.review.Review;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.maps.search.FilterUtils;
import com.mapswithme.maps.search.HotelsFilter;
import com.mapswithme.maps.search.Popularity;
import com.mapswithme.maps.taxi.TaxiType;
import com.mapswithme.maps.ugc.Impress;
import com.mapswithme.maps.ugc.UGCController;
@ -205,6 +206,10 @@ public class PlacePageView extends RelativeLayout
private RecyclerView mRvSponsoredProducts;
private TextView mTvSponsoredTitle;
private ImageView mIvSponsoredLogo;
@SuppressWarnings("NullableProblems")
@NonNull
private View mPopularityView;
@Nullable
UGCController mUgcController;
@ -385,55 +390,56 @@ public class PlacePageView extends RelativeLayout
{
LayoutInflater.from(getContext()).inflate(R.layout.place_page, this);
mPreview = (ViewGroup) findViewById(R.id.pp__preview);
mTvTitle = (TextView) mPreview.findViewById(R.id.tv__title);
mTvSecondaryTitle = (TextView) mPreview.findViewById(R.id.tv__secondary_title);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mTvSubtitle = (TextView) mPreview.findViewById(R.id.tv__subtitle);
mPreview = findViewById(R.id.pp__preview);
mTvTitle = mPreview.findViewById(R.id.tv__title);
mPopularityView = findViewById(R.id.popular_rating_view);
mTvSecondaryTitle = mPreview.findViewById(R.id.tv__secondary_title);
mToolbar = findViewById(R.id.toolbar);
mTvSubtitle = mPreview.findViewById(R.id.tv__subtitle);
View directionFrame = mPreview.findViewById(R.id.direction_frame);
mTvDistance = (TextView) mPreview.findViewById(R.id.tv__straight_distance);
mAvDirection = (ArrowView) mPreview.findViewById(R.id.av__direction);
mTvDistance = mPreview.findViewById(R.id.tv__straight_distance);
mAvDirection = mPreview.findViewById(R.id.av__direction);
directionFrame.setOnClickListener(this);
mTvAddress = (TextView) mPreview.findViewById(R.id.tv__address);
mTvAddress = mPreview.findViewById(R.id.tv__address);
mPreview.findViewById(R.id.search_hotels_btn).setOnClickListener(this);
mPreviewRatingInfo = mPreview.findViewById(R.id.preview_rating_info);
mRatingView = (RatingView) mPreviewRatingInfo.findViewById(R.id.rating_view);
mTvSponsoredPrice = (TextView) mPreviewRatingInfo.findViewById(R.id.tv__hotel_price);
mRatingView = mPreviewRatingInfo.findViewById(R.id.rating_view);
mTvSponsoredPrice = mPreviewRatingInfo.findViewById(R.id.tv__hotel_price);
mDetails = (NestedScrollView) findViewById(R.id.pp__details);
RelativeLayout address = (RelativeLayout) mDetails.findViewById(R.id.ll__place_name);
mDetails = findViewById(R.id.pp__details);
RelativeLayout address = mDetails.findViewById(R.id.ll__place_name);
mPhone = mDetails.findViewById(R.id.ll__place_phone);
mPhone.setOnClickListener(this);
mTvPhone = (TextView) mDetails.findViewById(R.id.tv__place_phone);
mTvPhone = mDetails.findViewById(R.id.tv__place_phone);
mWebsite = mDetails.findViewById(R.id.ll__place_website);
mWebsite.setOnClickListener(this);
mTvWebsite = (TextView) mDetails.findViewById(R.id.tv__place_website);
LinearLayout latlon = (LinearLayout) mDetails.findViewById(R.id.ll__place_latlon);
mTvWebsite = mDetails.findViewById(R.id.tv__place_website);
LinearLayout latlon = mDetails.findViewById(R.id.ll__place_latlon);
latlon.setOnClickListener(this);
mTvLatlon = (TextView) mDetails.findViewById(R.id.tv__place_latlon);
mTvLatlon = mDetails.findViewById(R.id.tv__place_latlon);
mOpeningHours = mDetails.findViewById(R.id.ll__place_schedule);
mFullOpeningHours = (TextView) mDetails.findViewById(R.id.opening_hours);
mTodayOpeningHours = (TextView) mDetails.findViewById(R.id.today_opening_hours);
mFullOpeningHours = mDetails.findViewById(R.id.opening_hours);
mTodayOpeningHours = mDetails.findViewById(R.id.today_opening_hours);
mWifi = mDetails.findViewById(R.id.ll__place_wifi);
mEmail = mDetails.findViewById(R.id.ll__place_email);
mEmail.setOnClickListener(this);
mTvEmail = (TextView) mEmail.findViewById(R.id.tv__place_email);
mTvEmail = mEmail.findViewById(R.id.tv__place_email);
mOperator = mDetails.findViewById(R.id.ll__place_operator);
mOperator.setOnClickListener(this);
mTvOperator = (TextView) mOperator.findViewById(R.id.tv__place_operator);
mTvOperator = mOperator.findViewById(R.id.tv__place_operator);
mCuisine = mDetails.findViewById(R.id.ll__place_cuisine);
mTvCuisine = (TextView) mCuisine.findViewById(R.id.tv__place_cuisine);
mTvCuisine = mCuisine.findViewById(R.id.tv__place_cuisine);
mWiki = mDetails.findViewById(R.id.ll__place_wiki);
mWiki.setOnClickListener(this);
mEntrance = mDetails.findViewById(R.id.ll__place_entrance);
mTvEntrance = (TextView) mEntrance.findViewById(R.id.tv__place_entrance);
mTvEntrance = mEntrance.findViewById(R.id.tv__place_entrance);
mTaxiShadow = mDetails.findViewById(R.id.place_page_taxi_shadow);
mTaxiDivider = mDetails.findViewById(R.id.place_page_taxi_divider);
mTaxi = mDetails.findViewById(R.id.ll__place_page_taxi);
TextView orderTaxi = (TextView) mTaxi.findViewById(R.id.tv__place_page_order_taxi);
TextView orderTaxi = mTaxi.findViewById(R.id.tv__place_page_order_taxi);
orderTaxi.setOnClickListener(this);
mEditPlace = mDetails.findViewById(R.id.ll__place_editor);
mEditPlace.setOnClickListener(this);
@ -443,7 +449,7 @@ public class PlacePageView extends RelativeLayout
mAddPlace.setOnClickListener(this);
mLocalAd = mDetails.findViewById(R.id.ll__local_ad);
mLocalAd.setOnClickListener(this);
mTvLocalAd = (TextView) mLocalAd.findViewById(R.id.tv__local_ad);
mTvLocalAd = mLocalAd.findViewById(R.id.tv__local_ad);
mEditTopSpace = mDetails.findViewById(R.id.edit_top_space);
latlon.setOnLongClickListener(this);
address.setOnLongClickListener(this);
@ -455,12 +461,12 @@ public class PlacePageView extends RelativeLayout
mWiki.setOnLongClickListener(this);
mBookmarkFrame = mDetails.findViewById(R.id.bookmark_frame);
mWvBookmarkNote = (WebView) mBookmarkFrame.findViewById(R.id.wv__bookmark_notes);
mWvBookmarkNote = mBookmarkFrame.findViewById(R.id.wv__bookmark_notes);
mWvBookmarkNote.getSettings().setJavaScriptEnabled(false);
mTvBookmarkNote = (TextView) mBookmarkFrame.findViewById(R.id.tv__bookmark_notes);
mTvBookmarkNote = mBookmarkFrame.findViewById(R.id.tv__bookmark_notes);
initEditMapObjectBtn();
ViewGroup ppButtons = (ViewGroup) findViewById(R.id.pp__buttons).findViewById(R.id.container);
ViewGroup ppButtons = findViewById(R.id.pp__buttons).findViewById(R.id.container);
mHeightCompensationView = findViewById(R.id.pp__height_compensation);
@ -673,7 +679,7 @@ public class PlacePageView extends RelativeLayout
mDownloaderIcon = new DownloaderStatusIcon(mPreview.findViewById(R.id.downloader_status_frame));
mDownloaderInfo = (TextView) mPreview.findViewById(R.id.tv__downloader_details);
mDownloaderInfo = mPreview.findViewById(R.id.tv__downloader_details);
mShadowController = new ScrollViewShadowController((ObservableScrollView) mDetails)
.addBottomShadow()
@ -721,14 +727,14 @@ public class PlacePageView extends RelativeLayout
private void initHotelRatingView()
{
mHotelReview = findViewById(R.id.ll__place_hotel_rating);
RecyclerView rvHotelReview = (RecyclerView) findViewById(R.id.rv__place_hotel_review);
RecyclerView rvHotelReview = findViewById(R.id.rv__place_hotel_review);
rvHotelReview.setLayoutManager(new LinearLayoutManager(getContext()));
rvHotelReview.getLayoutManager().setAutoMeasureEnabled(true);
rvHotelReview.setNestedScrollingEnabled(false);
rvHotelReview.setHasFixedSize(false);
rvHotelReview.setAdapter(mReviewAdapter);
mHotelRating = (TextView) findViewById(R.id.tv__place_hotel_rating);
mHotelRatingBase = (TextView) findViewById(R.id.tv__place_hotel_rating_base);
mHotelRating = findViewById(R.id.tv__place_hotel_rating);
mHotelRatingBase = findViewById(R.id.tv__place_hotel_rating_base);
View hotelMoreReviews = findViewById(R.id.tv__place_hotel_reviews_more);
hotelMoreReviews.setOnClickListener(this);
}
@ -736,14 +742,14 @@ public class PlacePageView extends RelativeLayout
private void initHotelNearbyView()
{
mHotelNearby = findViewById(R.id.ll__place_hotel_nearby);
GridView gvHotelNearby = (GridView) findViewById(R.id.gv__place_hotel_nearby);
GridView gvHotelNearby = findViewById(R.id.gv__place_hotel_nearby);
gvHotelNearby.setAdapter(mNearbyAdapter);
}
private void initHotelGalleryView()
{
mHotelGallery = findViewById(R.id.ll__place_hotel_gallery);
mRvHotelGallery = (RecyclerView) findViewById(
mRvHotelGallery = findViewById(
R.id.rv__place_hotel_gallery);
mRvHotelGallery.setLayoutManager(new LinearLayoutManager(getContext(),
LinearLayoutManager.HORIZONTAL, false));
@ -756,7 +762,7 @@ public class PlacePageView extends RelativeLayout
private void initHotelFacilitiesView()
{
mHotelFacilities = findViewById(R.id.ll__place_hotel_facilities);
RecyclerView rvHotelFacilities = (RecyclerView) findViewById(R.id.rv__place_hotel_facilities);
RecyclerView rvHotelFacilities = findViewById(R.id.rv__place_hotel_facilities);
rvHotelFacilities.setLayoutManager(new GridLayoutManager(getContext(), 2));
rvHotelFacilities.getLayoutManager().setAutoMeasureEnabled(true);
rvHotelFacilities.setNestedScrollingEnabled(false);
@ -769,7 +775,7 @@ public class PlacePageView extends RelativeLayout
private void initHotelDescriptionView()
{
mHotelDescription = findViewById(R.id.ll__place_hotel_description);
mTvHotelDescription = (LineCountTextView) findViewById(R.id.tv__place_hotel_details);
mTvHotelDescription = findViewById(R.id.tv__place_hotel_details);
mHotelMoreDescription = findViewById(R.id.tv__place_hotel_more);
View hotelMoreDescriptionOnWeb = findViewById(R.id.tv__place_hotel_more_on_web);
mTvHotelDescription.setListener(this);
@ -824,7 +830,7 @@ public class PlacePageView extends RelativeLayout
String text = getResources().getQuantityString(
R.plurals.placepage_summary_rating_description, reviewsCount, reviewsCount);
mHotelRatingBase.setText(text);
TextView previewReviewCountView = (TextView) mPreviewRatingInfo.findViewById(R.id.tv__review_count);
TextView previewReviewCountView = mPreviewRatingInfo.findViewById(R.id.tv__review_count);
previewReviewCountView.setText(text);
}
}
@ -883,10 +889,10 @@ public class PlacePageView extends RelativeLayout
{
mTvHotelDescription.setText("");
mHotelMoreDescription.setVisibility(GONE);
mFacilitiesAdapter.setItems(Collections.<Sponsored.FacilityType>emptyList());
mFacilitiesAdapter.setItems(Collections.emptyList());
mHotelMoreFacilities.setVisibility(GONE);
mGalleryAdapter.setItems(new ArrayList<Image>());
mNearbyAdapter.setItems(Collections.<Sponsored.NearbyObject>emptyList());
mNearbyAdapter.setItems(Collections.emptyList());
mReviewAdapter.setItems(new ArrayList<Review>());
mHotelRating.setText("");
mHotelRatingBase.setText("");
@ -909,9 +915,9 @@ public class PlacePageView extends RelativeLayout
private void initSponsoredGalleryView()
{
mSponsoredGalleryView = findViewById(R.id.ll__place_sponsored_gallery);
mTvSponsoredTitle = (TextView) mSponsoredGalleryView.findViewById(R.id.tv__sponsored_title);
mIvSponsoredLogo = (ImageView) mSponsoredGalleryView.findViewById(R.id.btn__sponsored_logo);
mRvSponsoredProducts = (RecyclerView) mSponsoredGalleryView.findViewById(R.id.rv__sponsored_products);
mTvSponsoredTitle = mSponsoredGalleryView.findViewById(R.id.tv__sponsored_title);
mIvSponsoredLogo = mSponsoredGalleryView.findViewById(R.id.btn__sponsored_logo);
mRvSponsoredProducts = mSponsoredGalleryView.findViewById(R.id.rv__sponsored_products);
mRvSponsoredProducts.setLayoutManager(new LinearLayoutManager(getContext(),
LinearLayoutManager.HORIZONTAL,
false));
@ -1420,6 +1426,8 @@ public class PlacePageView extends RelativeLayout
{
UiUtils.setTextAndHideIfEmpty(mTvTitle, mapObject.getTitle());
UiUtils.setTextAndHideIfEmpty(mTvSecondaryTitle, mapObject.getSecondaryTitle());
boolean isPopular = mapObject.getPopularity().getType() == Popularity.Type.POPULAR;
UiUtils.showIf(isPopular, mPopularityView);
if (mToolbar != null)
mToolbar.setTitle(mapObject.getTitle());
UiUtils.setTextAndHideIfEmpty(mTvSubtitle, mapObject.getSubtitle());