forked from organicmaps/organicmaps
[android] Review fixes
This commit is contained in:
parent
ea114dc7b0
commit
32a9400a4b
21 changed files with 235 additions and 134 deletions
|
@ -15,6 +15,7 @@ extern JavaVM * GetJVM()
|
|||
|
||||
// Caching is necessary to create class from native threads.
|
||||
jclass g_mapObjectClazz;
|
||||
jclass g_featureIdClazz;
|
||||
jclass g_bookmarkClazz;
|
||||
jclass g_myTrackerClazz;
|
||||
jclass g_httpClientClazz;
|
||||
|
@ -37,6 +38,7 @@ JNI_OnLoad(JavaVM * jvm, void *)
|
|||
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
g_mapObjectClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/MapObject");
|
||||
g_featureIdClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/FeatureId");
|
||||
g_bookmarkClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/Bookmark");
|
||||
g_myTrackerClazz = jni::GetGlobalClassRef(env, "com/my/tracker/MyTracker");
|
||||
g_httpClientClazz = jni::GetGlobalClassRef(env, "com/mapswithme/util/HttpClient");
|
||||
|
@ -56,6 +58,7 @@ JNI_OnUnload(JavaVM *, void *)
|
|||
g_jvm = 0;
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
env->DeleteGlobalRef(g_mapObjectClazz);
|
||||
env->DeleteGlobalRef(g_featureIdClazz);
|
||||
env->DeleteGlobalRef(g_bookmarkClazz);
|
||||
env->DeleteGlobalRef(g_myTrackerClazz);
|
||||
env->DeleteGlobalRef(g_httpClientClazz);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <string>
|
||||
|
||||
extern jclass g_mapObjectClazz;
|
||||
extern jclass g_featureIdClazz;
|
||||
extern jclass g_bookmarkClazz;
|
||||
extern jclass g_myTrackerClazz;
|
||||
extern jclass g_httpClientClazz;
|
||||
|
|
|
@ -43,32 +43,38 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion
|
|||
string const & bookingSearchUrl, jobject const & localAdInfo,
|
||||
jobject const & routingPointInfo)
|
||||
{
|
||||
// public MapObject(@NonNull String mwmName, long mwmVersion, int featureIndex,
|
||||
// @MapObjectType int mapObjectType, String title, @Nullable String secondaryTitle,
|
||||
// public MapObject(@NonNull FeatureId featureId,
|
||||
// @MapObjectType int mapObjectType, String title, @Nullable String
|
||||
// secondaryTitle,
|
||||
// String subtitle, String address, double lat, double lon, String apiId,
|
||||
// @Nullable Banner[] banners, @TaxiType int[] reachableByTaxiTypes,
|
||||
// @Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo,
|
||||
// @Nullable RoutePointInfo routePointInfo)
|
||||
static jmethodID const ctorId =
|
||||
jni::GetConstructorID(env, g_mapObjectClazz,
|
||||
"(Ljava/lang/String;JIILjava/lang/String;Ljava/lang/"
|
||||
"String;Ljava/lang/String;Ljava/lang/String;DDLjava/lang/"
|
||||
"String;[Lcom/mapswithme/maps/ads/Banner;[ILjava/lang/String;"
|
||||
"Lcom/mapswithme/maps/ads/LocalAdInfo;"
|
||||
"Lcom/mapswithme/maps/routing/RoutePointInfo;)V");
|
||||
static jmethodID const ctorId = jni::GetConstructorID(
|
||||
env, g_mapObjectClazz,
|
||||
"(Lcom/mapswithme/maps/bookmarks/data/FeatureId;ILjava/lang/String;Ljava/lang/"
|
||||
"String;Ljava/lang/String;Ljava/lang/String;DDLjava/lang/"
|
||||
"String;[Lcom/mapswithme/maps/ads/Banner;[ILjava/lang/String;"
|
||||
"Lcom/mapswithme/maps/ads/LocalAdInfo;"
|
||||
"Lcom/mapswithme/maps/routing/RoutePointInfo;)V");
|
||||
//public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
|
||||
static jmethodID const featureCtorId =
|
||||
jni::GetConstructorID(env, g_featureIdClazz, "(Ljava/lang/String;JI)V");
|
||||
|
||||
jni::TScopedLocalRef jMwmName(env, jni::ToJavaString(env, mwmName));
|
||||
jni::TScopedLocalRef jFeatureId(
|
||||
env, env->NewObject(g_featureIdClazz, featureCtorId, jMwmName.get(), (jlong)mwmVersion,
|
||||
(jint)featureIndex));
|
||||
jni::TScopedLocalRef jTitle(env, jni::ToJavaString(env, title));
|
||||
jni::TScopedLocalRef jSecondaryTitle(env, jni::ToJavaString(env, secondaryTitle));
|
||||
jni::TScopedLocalRef jSubtitle(env, jni::ToJavaString(env, subtitle));
|
||||
jni::TScopedLocalRef jAddress(env, jni::ToJavaString(env, address));
|
||||
jni::TScopedLocalRef jApiId(env, jni::ToJavaString(env, apiId));
|
||||
jni::TScopedLocalRef jBookingSearchUrl(env, jni::ToJavaString(env, bookingSearchUrl));
|
||||
jobject mapObject = env->NewObject(
|
||||
g_mapObjectClazz, ctorId, jMwmName.get(), (jlong)mwmVersion, (jint)featureIndex,
|
||||
mapObjectType, jTitle.get(), jSecondaryTitle.get(), jSubtitle.get(), jAddress.get(),
|
||||
lat, lon, jApiId.get(), jbanners, jTaxiTypes, jBookingSearchUrl.get(),
|
||||
localAdInfo, routingPointInfo);
|
||||
jobject mapObject =
|
||||
env->NewObject(g_mapObjectClazz, ctorId, jFeatureId.get(), mapObjectType, jTitle.get(),
|
||||
jSecondaryTitle.get(), jSubtitle.get(), jAddress.get(), lat, lon, jApiId.get(),
|
||||
jbanners, jTaxiTypes, jBookingSearchUrl.get(), localAdInfo, routingPointInfo);
|
||||
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, metadata);
|
||||
return mapObject;
|
||||
|
@ -90,7 +96,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
|
||||
if (info.IsBookmark())
|
||||
{
|
||||
// public Bookmark(@NonNull String mwmName, long mwmVersion, int featureIndex,
|
||||
// public Bookmark(@NonNull FeatureId featureId,
|
||||
// @IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId,
|
||||
// String title, @Nullable String secondaryTitle, @Nullable String objectTitle,
|
||||
// @Nullable Banner[] banners, boolean reachableByTaxi,
|
||||
|
@ -98,16 +104,23 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
// @Nullable RoutePointInfo routePointInfo)
|
||||
static jmethodID const ctorId =
|
||||
jni::GetConstructorID(env, g_bookmarkClazz,
|
||||
"(Ljava/lang/String;JIIILjava/lang/String;Ljava/"
|
||||
"lang/String;Ljava/lang/String;Ljava/lang/String;"
|
||||
"(Lcom/mapswithme/maps/bookmarks/data/FeatureId;IILjava/lang/String;"
|
||||
"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;"
|
||||
"[Lcom/mapswithme/maps/ads/Banner;[ILjava/lang/String;"
|
||||
"Lcom/mapswithme/maps/ads/LocalAdInfo;"
|
||||
"Lcom/mapswithme/maps/routing/RoutePointInfo;)V");
|
||||
// public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
|
||||
static jmethodID const featureCtorId =
|
||||
jni::GetConstructorID(env, g_featureIdClazz, "(Ljava/lang/String;JI)V");
|
||||
|
||||
auto const & bac = info.GetBookmarkAndCategory();
|
||||
BookmarkCategory * cat = g_framework->NativeFramework()->GetBmCategory(bac.m_categoryIndex);
|
||||
BookmarkData const & data = info.GetBookmarkData();
|
||||
jni::TScopedLocalRef jMwmName(env, jni::ToJavaString(env, info.GetID().GetMwmName()));
|
||||
jni::TScopedLocalRef jFeatureId(
|
||||
env, env->NewObject(g_featureIdClazz, featureCtorId, jMwmName.get(),
|
||||
(jlong)info.GetID().GetMwmVersion(), (jint)info.GetID().m_index));
|
||||
jni::TScopedLocalRef jName(env, jni::ToJavaString(env, data.GetName()));
|
||||
jni::TScopedLocalRef jTitle(env, jni::ToJavaString(env, info.GetTitle()));
|
||||
jni::TScopedLocalRef jSecondaryTitle(env, jni::ToJavaString(env, info.GetSecondaryTitle()));
|
||||
jni::TScopedLocalRef jSubtitle(env, jni::ToJavaString(env, info.GetSubtitle()));
|
||||
|
@ -115,10 +128,11 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info)
|
|||
|
||||
jni::TScopedLocalRef jBookingSearchUrl(env, jni::ToJavaString(env, info.GetBookingSearchUrl()));
|
||||
jobject mapObject = env->NewObject(
|
||||
g_bookmarkClazz, ctorId, jMwmName.get(), info.GetID().GetMwmVersion(), info.GetID().m_index,
|
||||
static_cast<jint>(bac.m_categoryIndex), static_cast<jint>(bac.m_bookmarkIndex),
|
||||
jTitle.get(), jSecondaryTitle.get(), jSubtitle.get(), jAddress.get(), jbanners.get(),
|
||||
jTaxiTypes.get(), jBookingSearchUrl.get(), localAdInfo.get(), routingPointInfo.get());
|
||||
g_bookmarkClazz, ctorId, jFeatureId.get(), static_cast<jint>(bac.m_categoryIndex),
|
||||
static_cast<jint>(bac.m_bookmarkIndex), jTitle.get(), jSecondaryTitle.get(), jSubtitle.get(),
|
||||
jAddress.get(), jbanners.get(), jTaxiTypes.get(), jBookingSearchUrl.get(),
|
||||
localAdInfo.get(), routingPointInfo.get());
|
||||
|
||||
if (info.IsFeature())
|
||||
InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata());
|
||||
return mapObject;
|
||||
|
|
|
@ -38,10 +38,10 @@ private:
|
|||
if (m_initialized)
|
||||
return;
|
||||
|
||||
m_class = jni::GetGlobalClassRef(env, "com/mapswithme/maps/FeatureId");
|
||||
m_countryName = env->GetFieldID(m_class, "mCountryName", "Ljava/lang/String;");
|
||||
m_version = env->GetFieldID(m_class, "mVersion", "J");
|
||||
m_index = env->GetFieldID(m_class, "mIndex", "I");
|
||||
m_class = jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/FeatureId");
|
||||
m_countryName = env->GetFieldID(m_class, "mMwmName", "Ljava/lang/String;");
|
||||
m_version = env->GetFieldID(m_class, "mMwmVersion", "J");
|
||||
m_index = env->GetFieldID(m_class, "mFeatureIndex", "I");
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
|
|
@ -46,4 +46,4 @@
|
|||
android:background="?windowBackgroundForced"
|
||||
android:text="@string/details"
|
||||
tools:targetApi="jelly_bean"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package com.mapswithme.maps;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public class FeatureId
|
||||
{
|
||||
// Mwm base name.
|
||||
@NonNull
|
||||
public final String mCountryName;
|
||||
|
||||
// Mwm version.
|
||||
public final long mVersion;
|
||||
|
||||
// Feature index.
|
||||
public final int mIndex;
|
||||
|
||||
public FeatureId(@NonNull String countryName, long version, int index)
|
||||
{
|
||||
mCountryName = countryName;
|
||||
mVersion = version;
|
||||
mIndex = index;
|
||||
}
|
||||
};
|
|
@ -41,6 +41,7 @@ import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
|||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.downloader.DownloaderActivity;
|
||||
import com.mapswithme.maps.downloader.DownloaderFragment;
|
||||
|
@ -1511,10 +1512,10 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
RoutingController.get().setRouterType(data.mRouterType);
|
||||
final RoutePoint from = data.mPoints[0];
|
||||
final RoutePoint to = data.mPoints[1];
|
||||
RoutingController.get().prepare(new MapObject("", 0L, 0, MapObject.API_POINT, from.mName,
|
||||
RoutingController.get().prepare(new MapObject(FeatureId.EMPTY, MapObject.API_POINT, from.mName,
|
||||
"", "", "", from.mLat, from.mLon, "", null,
|
||||
null, "", null, null),
|
||||
new MapObject("", 0L, 0, MapObject.API_POINT, to.mName,
|
||||
new MapObject(FeatureId.EMPTY, MapObject.API_POINT, to.mName,
|
||||
"", "", "", to.mLat, to.mLon, "", null,
|
||||
null, "", null, null),
|
||||
true);
|
||||
|
@ -2251,7 +2252,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@NonNull
|
||||
private static MapObject fromLatLon(double lat, double lon)
|
||||
{
|
||||
return new MapObject("", 0L, 0, MapObject.API_POINT, "",
|
||||
return new MapObject(FeatureId.EMPTY, MapObject.API_POINT, "",
|
||||
"", "", "", lat, lon, "", null,
|
||||
null, "", null, null);
|
||||
}
|
||||
|
|
|
@ -86,13 +86,8 @@ public abstract class BaseSponsoredAdapter extends RecyclerView.Adapter<BaseSpon
|
|||
case TYPE_PRODUCT:
|
||||
return createViewHolder(LayoutInflater.from(parent.getContext()), parent);
|
||||
case TYPE_MORE:
|
||||
@LayoutRes final int layout;
|
||||
if (mSponsoredType == Sponsored.TYPE_VIATOR)
|
||||
layout = R.layout.item_viator_more;
|
||||
else
|
||||
layout = R.layout.item_cian_more;
|
||||
return new ViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(layout, parent, false), this);
|
||||
.inflate(getMoreLayout(), parent, false), this);
|
||||
case TYPE_LOADING:
|
||||
return createLoadingViewHolder(LayoutInflater.from(parent.getContext()), parent);
|
||||
}
|
||||
|
@ -128,7 +123,7 @@ public abstract class BaseSponsoredAdapter extends RecyclerView.Adapter<BaseSpon
|
|||
mItems.clear();
|
||||
mItems.add(new Item(TYPE_LOADING, sponsoredType, getLoadingTitle(), url, ERROR_SUBTITLE,
|
||||
true, false));
|
||||
notifyItemChanged(0);
|
||||
notifyItemChanged(0/* position */);
|
||||
}
|
||||
|
||||
public void setLoadingCompleted(@Sponsored.SponsoredType int sponsoredType, @NonNull String url)
|
||||
|
@ -136,7 +131,7 @@ public abstract class BaseSponsoredAdapter extends RecyclerView.Adapter<BaseSpon
|
|||
mItems.clear();
|
||||
mItems.add(new Item(TYPE_LOADING, sponsoredType, getLoadingTitle(), url, getLoadingSubtitle(),
|
||||
false, true));
|
||||
notifyItemChanged(0);
|
||||
notifyItemChanged(0/* position */);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -153,6 +148,9 @@ public abstract class BaseSponsoredAdapter extends RecyclerView.Adapter<BaseSpon
|
|||
@Nullable
|
||||
protected abstract String getLoadingSubtitle();
|
||||
|
||||
@LayoutRes
|
||||
protected abstract int getMoreLayout();
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder
|
||||
implements View.OnClickListener
|
||||
{
|
||||
|
|
|
@ -23,15 +23,14 @@ public class Bookmark extends MapObject
|
|||
private double mMerX;
|
||||
private double mMerY;
|
||||
|
||||
public Bookmark(@NonNull String mwmName, long mwmVersion, int featureIndex,
|
||||
@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId,
|
||||
String title, @Nullable String secondaryTitle, @Nullable String subtitle,
|
||||
@Nullable String address,
|
||||
@Nullable Banner[] banners, @TaxiManager.TaxiType int[] reachableByTaxiTypes,
|
||||
public Bookmark(@NonNull FeatureId featureId, @IntRange(from = 0) int categoryId,
|
||||
@IntRange(from = 0) int bookmarkId, String title, @Nullable String secondaryTitle,
|
||||
@Nullable String subtitle, @Nullable String address, @Nullable Banner[] banners,
|
||||
@TaxiManager.TaxiType int[] reachableByTaxiTypes,
|
||||
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo,
|
||||
@Nullable RoutePointInfo routePointInfo)
|
||||
{
|
||||
super(mwmName, mwmVersion, featureIndex, BOOKMARK, title, secondaryTitle, subtitle, address, 0, 0, "",
|
||||
super(featureId, BOOKMARK, title, secondaryTitle, subtitle, address, 0, 0, "",
|
||||
banners, reachableByTaxiTypes, bookingSearchUrl, localAdInfo, routePointInfo);
|
||||
|
||||
mCategoryId = categoryId;
|
||||
|
|
117
android/src/com/mapswithme/maps/bookmarks/data/FeatureId.java
Normal file
117
android/src/com/mapswithme/maps/bookmarks/data/FeatureId.java
Normal file
|
@ -0,0 +1,117 @@
|
|||
package com.mapswithme.maps.bookmarks.data;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class FeatureId implements Parcelable
|
||||
{
|
||||
public static final Creator<FeatureId> CREATOR = new Creator<FeatureId>()
|
||||
{
|
||||
@Override
|
||||
public FeatureId createFromParcel(Parcel in)
|
||||
{
|
||||
return new FeatureId(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureId[] newArray(int size)
|
||||
{
|
||||
return new FeatureId[size];
|
||||
}
|
||||
};
|
||||
|
||||
@NonNull
|
||||
public static final FeatureId EMPTY = new FeatureId("", 0L, 0);
|
||||
|
||||
@NonNull
|
||||
private final String mMwmName;
|
||||
private final long mMwmVersion;
|
||||
private final int mFeatureIndex;
|
||||
|
||||
@NonNull
|
||||
public static FeatureId fromString(@NonNull String string)
|
||||
{
|
||||
if (TextUtils.isEmpty(string))
|
||||
throw new AssertionError("Feature id string is empty");
|
||||
|
||||
String parts[] = string.split(":");
|
||||
if (parts.length != 3)
|
||||
throw new AssertionError("Wrong feature id string format");
|
||||
|
||||
return new FeatureId(parts[0], Long.parseLong(parts[1]), Integer.parseInt(parts[2]));
|
||||
}
|
||||
|
||||
public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex)
|
||||
{
|
||||
mMwmName = mwmName;
|
||||
mMwmVersion = mwmVersion;
|
||||
mFeatureIndex = featureIndex;
|
||||
}
|
||||
|
||||
private FeatureId(Parcel in)
|
||||
{
|
||||
mMwmName = in.readString();
|
||||
mMwmVersion = in.readLong();
|
||||
mFeatureIndex = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags)
|
||||
{
|
||||
dest.writeString(mMwmName);
|
||||
dest.writeLong(mMwmVersion);
|
||||
dest.writeInt(mFeatureIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getMwmName()
|
||||
{
|
||||
return mMwmName;
|
||||
}
|
||||
|
||||
public long getMwmVersion()
|
||||
{
|
||||
return mMwmVersion;
|
||||
}
|
||||
|
||||
public int getFeatureIndex()
|
||||
{
|
||||
return mFeatureIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
FeatureId featureId = (FeatureId) o;
|
||||
|
||||
if (mMwmVersion != featureId.mMwmVersion) return false;
|
||||
if (mFeatureIndex != featureId.mFeatureIndex) return false;
|
||||
return mMwmName.equals(featureId.mMwmName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = mMwmName.hashCode();
|
||||
result = 31 * result + (int) (mMwmVersion ^ (mMwmVersion >>> 32));
|
||||
result = 31 * result + mFeatureIndex;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return mMwmName + ":" + mMwmVersion + ":" + mFeatureIndex;
|
||||
}
|
||||
}
|
|
@ -33,9 +33,7 @@ public class MapObject implements Parcelable
|
|||
public static final int SEARCH = 4;
|
||||
|
||||
@NonNull
|
||||
private final String mMwmName;
|
||||
private final long mMwmVersion;
|
||||
private final int mFeatureIndex;
|
||||
private final FeatureId mFeatureId;
|
||||
@MapObjectType
|
||||
private final int mMapObjectType;
|
||||
|
||||
|
@ -59,28 +57,26 @@ public class MapObject implements Parcelable
|
|||
@Nullable
|
||||
private RoutePointInfo mRoutePointInfo;
|
||||
|
||||
public MapObject(@NonNull String mwmName, long mwmVersion, int featureIndex,
|
||||
@MapObjectType int mapObjectType, String title, @Nullable String secondaryTitle,
|
||||
String subtitle, String address, double lat, double lon, String apiId,
|
||||
public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType, String title,
|
||||
@Nullable String secondaryTitle, String subtitle, String address,
|
||||
double lat, double lon, String apiId,
|
||||
@Nullable Banner[] banners, @Nullable @TaxiManager.TaxiType int[] types,
|
||||
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo,
|
||||
@Nullable RoutePointInfo routePointInfo)
|
||||
{
|
||||
this(mwmName, mwmVersion, featureIndex, mapObjectType, title, secondaryTitle,
|
||||
this(featureId, mapObjectType, title, secondaryTitle,
|
||||
subtitle, address, lat, lon, new Metadata(), apiId, banners,
|
||||
types, bookingSearchUrl, localAdInfo, routePointInfo);
|
||||
}
|
||||
|
||||
public MapObject(@NonNull String mwmName, long mwmVersion, int featureIndex,
|
||||
@MapObjectType int mapObjectType, String title, @Nullable String secondaryTitle,
|
||||
public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType,
|
||||
String title, @Nullable String secondaryTitle,
|
||||
String subtitle, String address, double lat, double lon, Metadata metadata,
|
||||
String apiId, @Nullable Banner[] banners, @Nullable @TaxiManager.TaxiType int[] taxiTypes,
|
||||
@Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo,
|
||||
@Nullable RoutePointInfo routePointInfo)
|
||||
{
|
||||
mMwmName = mwmName;
|
||||
mMwmVersion = mwmVersion;
|
||||
mFeatureIndex = featureIndex;
|
||||
mFeatureId = featureId;
|
||||
mMapObjectType = mapObjectType;
|
||||
mTitle = title;
|
||||
mSecondaryTitle = secondaryTitle;
|
||||
|
@ -106,9 +102,7 @@ public class MapObject implements Parcelable
|
|||
protected MapObject(@MapObjectType int type, Parcel source)
|
||||
{
|
||||
//noinspection ResourceType
|
||||
this(source.readString(), // MwmName
|
||||
source.readLong(), // MwmVersion
|
||||
source.readInt(), // FeatureId
|
||||
this((FeatureId) source.readParcelable(FeatureId.class.getClassLoader()), // FeatureId
|
||||
type, // MapObjectType
|
||||
source.readString(), // Title
|
||||
source.readString(), // SecondaryTitle
|
||||
|
@ -281,25 +275,9 @@ public class MapObject implements Parcelable
|
|||
}
|
||||
|
||||
@NonNull
|
||||
public String getMwmName()
|
||||
public FeatureId getFeatureId()
|
||||
{
|
||||
return mMwmName;
|
||||
}
|
||||
|
||||
public long getMwmVersion()
|
||||
{
|
||||
return mMwmVersion;
|
||||
}
|
||||
|
||||
public int getFeatureIndex()
|
||||
{
|
||||
return mFeatureIndex;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getFeatureId()
|
||||
{
|
||||
return mMwmName + ":" + mMwmVersion + ":" + mFeatureIndex;
|
||||
return mFeatureId;
|
||||
}
|
||||
|
||||
private static MapObject readFromParcel(Parcel source)
|
||||
|
@ -323,9 +301,7 @@ public class MapObject implements Parcelable
|
|||
// A map object type must be written first, since it's used in readParcel method to distinguish
|
||||
// what type of object should be read from the parcel.
|
||||
dest.writeInt(mMapObjectType);
|
||||
dest.writeString(mMwmName);
|
||||
dest.writeLong(mMwmVersion);
|
||||
dest.writeInt(mFeatureIndex);
|
||||
dest.writeParcelable(mFeatureId, 0);
|
||||
dest.writeString(mTitle);
|
||||
dest.writeString(mSecondaryTitle);
|
||||
dest.writeString(mSubtitle);
|
||||
|
@ -348,19 +324,13 @@ public class MapObject implements Parcelable
|
|||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
MapObject mapObject = (MapObject) o;
|
||||
|
||||
if (mMwmVersion != mapObject.mMwmVersion) return false;
|
||||
if (mFeatureIndex != mapObject.mFeatureIndex) return false;
|
||||
return mMwmName.equals(mapObject.mMwmName);
|
||||
return mFeatureId.equals(mapObject.mFeatureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = mMwmName.hashCode();
|
||||
result = 31 * result + (int) (mMwmVersion ^ (mMwmVersion >>> 32));
|
||||
result = 31 * result + mFeatureIndex;
|
||||
return result;
|
||||
return mFeatureId.hashCode();
|
||||
}
|
||||
|
||||
public static final Creator<MapObject> CREATOR = new Creator<MapObject>()
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.mapswithme.maps.cian;
|
|||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
import com.mapswithme.util.NetworkPolicy;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
@ -13,7 +14,7 @@ public final class Cian
|
|||
@NonNull
|
||||
private static WeakReference<com.mapswithme.maps.cian.Cian.CianListener> sCianListener = new WeakReference<>(null);
|
||||
@NonNull
|
||||
private static final Map<String, RentPlace[]> sProductsCache = new HashMap<>();
|
||||
private static final Map<FeatureId, RentPlace[]> sProductsCache = new HashMap<>();
|
||||
|
||||
public static void setCianListener(@NonNull com.mapswithme.maps.cian.Cian.CianListener listener)
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ public final class Cian
|
|||
|
||||
private static void onRentPlacesReceived(@NonNull RentPlace[] places, @NonNull String id)
|
||||
{
|
||||
sProductsCache.put(id, places);
|
||||
sProductsCache.put(FeatureId.fromString(id), places);
|
||||
com.mapswithme.maps.cian.Cian.CianListener listener = sCianListener.get();
|
||||
if (listener != null)
|
||||
listener.onRentPlacesReceived(places);
|
||||
|
@ -38,16 +39,16 @@ public final class Cian
|
|||
private Cian() {}
|
||||
|
||||
public static void getRentNearby(@NonNull NetworkPolicy policy,double lat, double lon,
|
||||
@NonNull String id)
|
||||
@NonNull FeatureId id)
|
||||
{
|
||||
RentPlace[] products = sProductsCache.get(id);
|
||||
if (products != null && products.length > 0)
|
||||
onRentPlacesReceived(products, id);
|
||||
onRentPlacesReceived(products, id.toString());
|
||||
|
||||
nativeGetRentNearby(policy, lat, lon, id);
|
||||
nativeGetRentNearby(policy, lat, lon, id.toString());
|
||||
}
|
||||
|
||||
public static boolean hasCache(String id)
|
||||
public static boolean hasCache(@NonNull FeatureId id)
|
||||
{
|
||||
return sProductsCache.containsKey(id);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.mapswithme.maps.cian;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -86,6 +87,13 @@ public final class CianAdapter extends BaseSponsoredAdapter
|
|||
return LOADING_SUBTITLE;
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
@Override
|
||||
protected int getMoreLayout()
|
||||
{
|
||||
return R.layout.item_cian_more;
|
||||
}
|
||||
|
||||
private static final class ProductViewHolder extends ViewHolder
|
||||
{
|
||||
@NonNull
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.google.android.gms.common.GoogleApiAvailability;
|
|||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.ads.Banner;
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.util.Config;
|
||||
|
@ -214,7 +215,7 @@ public enum LocationHelper
|
|||
return null;
|
||||
|
||||
if (mMyPosition == null)
|
||||
mMyPosition = new MapObject("", 0L, 0, MapObject.MY_POSITION, "", "", "", "",
|
||||
mMyPosition = new MapObject(FeatureId.EMPTY, MapObject.MY_POSITION, "", "", "", "",
|
||||
mSavedLocation.getLatitude(), mSavedLocation.getLongitude(), "",
|
||||
null, null, "", null, null);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.widget.TextView;
|
|||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.downloader.MapManager;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
|
@ -526,7 +527,7 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
@NonNull
|
||||
private MapObject toMapObject(@NonNull RouteMarkData point)
|
||||
{
|
||||
return new MapObject("", 0L, 0, point.mIsMyPosition ? MapObject.MY_POSITION : MapObject.POI,
|
||||
return new MapObject(FeatureId.EMPTY, point.mIsMyPosition ? MapObject.MY_POSITION : MapObject.POI,
|
||||
point.mTitle, null, point.mSubtitle, null, point.mLat, point.mLon, null,
|
||||
null, null, null, null, null);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.mapswithme.maps.MwmApplication;
|
|||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.downloader.CountrySuggestFragment;
|
||||
import com.mapswithme.maps.downloader.MapManager;
|
||||
|
@ -464,7 +465,7 @@ public class SearchFragment extends BaseMwmFragment
|
|||
if (RoutingController.get().isWaitingPoiPick())
|
||||
{
|
||||
SearchResult.Description description = result.description;
|
||||
final MapObject point = new MapObject("", 0L, 0, MapObject.SEARCH, result.name, "",
|
||||
final MapObject point = new MapObject(FeatureId.EMPTY, MapObject.SEARCH, result.name, "",
|
||||
description != null ? description.featureType : "", "",
|
||||
result.lat, result.lon, "", null, null, "", null, null);
|
||||
RoutingController.get().onPoiSelected(point);
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.support.annotation.IntDef;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapswithme.maps.FeatureId;
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public final class Viator
|
|||
nativeRequestViatorProducts(policy, destId, currency);
|
||||
}
|
||||
|
||||
public static boolean hasCache(String id)
|
||||
public static boolean hasCache(@NonNull String id)
|
||||
{
|
||||
return sProductsCache.containsKey(id);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.mapswithme.maps.viator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -68,6 +69,7 @@ public final class ViatorAdapter extends BaseSponsoredAdapter
|
|||
@Override
|
||||
protected String getLoadingTitle()
|
||||
{
|
||||
//TODO return localized resource
|
||||
return "title";
|
||||
}
|
||||
|
||||
|
@ -75,9 +77,17 @@ public final class ViatorAdapter extends BaseSponsoredAdapter
|
|||
@Override
|
||||
protected String getLoadingSubtitle()
|
||||
{
|
||||
//TODO return localized resource
|
||||
return "subtitle";
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
@Override
|
||||
protected int getMoreLayout()
|
||||
{
|
||||
return R.layout.item_viator_more;
|
||||
}
|
||||
|
||||
private static final class ProductViewHolder extends ViewHolder
|
||||
{
|
||||
@NonNull
|
||||
|
|
|
@ -39,7 +39,6 @@ import android.widget.PopupMenu;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.FeatureId;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
@ -53,6 +52,7 @@ import com.mapswithme.maps.base.BaseSponsoredAdapter;
|
|||
import com.mapswithme.maps.bookmarks.data.Bookmark;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.bookmarks.data.Metadata;
|
||||
import com.mapswithme.maps.cian.Cian;
|
||||
|
@ -289,7 +289,8 @@ public class PlacePageView extends RelativeLayout
|
|||
if (mMapObject == null || mUgc == null)
|
||||
return;
|
||||
|
||||
UGCEditorActivity.start(getActivity(), mMapObject.getTitle(), mMapObject.getFeatureIndex(),
|
||||
UGCEditorActivity.start(getActivity(), mMapObject.getTitle(),
|
||||
mMapObject.getFeatureId().getFeatureIndex(),
|
||||
mUgc, rating);
|
||||
}
|
||||
|
||||
|
@ -865,7 +866,7 @@ public class PlacePageView extends RelativeLayout
|
|||
{
|
||||
if (mSponsoredAdapter == null || !mSponsoredAdapter.containsLoading())
|
||||
{
|
||||
mSponsoredAdapter = new CianAdapter("", true, this);
|
||||
mSponsoredAdapter = new CianAdapter(""/* url */ , true/* hasError */, this);
|
||||
mRvSponsoredProducts.setAdapter(mSponsoredAdapter);
|
||||
}
|
||||
else
|
||||
|
@ -934,7 +935,7 @@ public class PlacePageView extends RelativeLayout
|
|||
{
|
||||
if (mSponsoredAdapter == null || !mSponsoredAdapter.containsLoading())
|
||||
{
|
||||
mSponsoredAdapter = new CianAdapter(url, true, this);
|
||||
mSponsoredAdapter = new CianAdapter(url, true/* hasError */, this);
|
||||
mRvSponsoredProducts.setAdapter(mSponsoredAdapter);
|
||||
}
|
||||
else
|
||||
|
@ -977,13 +978,13 @@ public class PlacePageView extends RelativeLayout
|
|||
}
|
||||
}
|
||||
|
||||
private void showLoadingCianProducts(@NonNull String id, @NonNull String url)
|
||||
private void showLoadingCianProducts(@NonNull FeatureId id, @NonNull String url)
|
||||
{
|
||||
UiUtils.show(mSponsoredGalleryView);
|
||||
mTvSponsoredTitle.setText(R.string.subtitle_rent);
|
||||
if (!Cian.hasCache(id))
|
||||
{
|
||||
mSponsoredAdapter = new CianAdapter(url, false, this);
|
||||
mSponsoredAdapter = new CianAdapter(url, false/* hasError */, this);
|
||||
mRvSponsoredProducts.setAdapter(mSponsoredAdapter);
|
||||
}
|
||||
}
|
||||
|
@ -1287,12 +1288,10 @@ public class PlacePageView extends RelativeLayout
|
|||
if (mMapObject != null)
|
||||
{
|
||||
// TODO: mock implementation for test only
|
||||
if (mMapObject.getFeatureIndex() == 218028)
|
||||
FeatureId fid = mMapObject.getFeatureId();
|
||||
if (fid.getFeatureIndex() == 218028)
|
||||
{
|
||||
UGC.setListener(this);
|
||||
// TODO (@y): replace three fields in the MapObject by FeatureId.
|
||||
FeatureId fid = new FeatureId(
|
||||
mMapObject.getMwmName(), mMapObject.getMwmVersion(), mMapObject.getFeatureIndex());
|
||||
UGC.requestUGC(fid);
|
||||
refreshViews(policy);
|
||||
return;
|
||||
|
|
|
@ -675,9 +675,9 @@ public enum Statistics
|
|||
{
|
||||
trackEvent(PP_OWNERSHIP_BUTTON_CLICK, LocationHelper.INSTANCE.getLastKnownLocation(),
|
||||
params()
|
||||
.add(MWM_NAME, mapObject.getMwmName())
|
||||
.add(MWM_VERSION, mapObject.getMwmVersion())
|
||||
.add(FEATURE_ID, mapObject.getFeatureIndex())
|
||||
.add(MWM_NAME, mapObject.getFeatureId().getMwmName())
|
||||
.add(MWM_VERSION, mapObject.getFeatureId().getMwmVersion())
|
||||
.add(FEATURE_ID, mapObject.getFeatureId().getFeatureIndex())
|
||||
.get());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue