[android] Propagated server_id value to elevation info data structure

This commit is contained in:
Александр Зацепин 2020-04-06 19:52:34 +03:00 committed by Vladimir Byko-Ianko
parent 588d69b9cc
commit 97c6ce7d7d
4 changed files with 24 additions and 8 deletions

View file

@ -1034,8 +1034,10 @@ Java_com_mapswithme_maps_Framework_nativePlacePageActivationListener(JNIEnv *env
jni::TScopedLocalRef placePageDataRef(env, nullptr);
if (info.IsTrack())
{
auto const categoryId = info.GetBookmarkCategoryId();
auto const serverId = frm()->GetBookmarkManager().GetCategoryServerId(categoryId);
auto const elevationInfo = frm()->GetBookmarkManager().MakeElevationInfo(info.GetTrackId());
placePageDataRef.reset(usermark_helper::CreateElevationInfo(env, elevationInfo));
placePageDataRef.reset(usermark_helper::CreateElevationInfo(env, serverId, elevationInfo));
}
else
{

View file

@ -211,19 +211,21 @@ jobjectArray ToElevationPointArray(JNIEnv * env, ElevationInfo::Points const & p
});
}
jobject CreateElevationInfo(JNIEnv * env, ElevationInfo const & info)
jobject CreateElevationInfo(JNIEnv * env, std::string const & serverId, ElevationInfo const & info)
{
// public ElevationInfo(long trackId, @NonNull String name, @NonNull Point[] points,
// int ascent, int descent, int minAltitude, int maxAltitude, int difficulty,
// long m_duration)
static jmethodID const ctorId =
jni::GetConstructorID(env, g_elevationInfoClazz, "(JLjava/lang/String;"
jni::GetConstructorID(env, g_elevationInfoClazz, "(JLjava/lang/String;Ljava/lang/String;"
"[Lcom/mapswithme/maps/bookmarks/data/ElevationInfo$Point;"
"IIIIIJ)V");
jni::TScopedLocalRef jServerId(env, jni::ToJavaString(env, serverId));
jni::TScopedLocalRef jName(env, jni::ToJavaString(env, info.GetName()));
jni::TScopedLocalObjectArrayRef jPoints(env, ToElevationPointArray(env, info.GetPoints()));
return env->NewObject(g_elevationInfoClazz, ctorId, static_cast<jlong>(info.GetId()),
jName.get(), jPoints.get(), static_cast<jint>(info.GetAscent()),
jServerId.get(), jName.get(), jPoints.get(),
static_cast<jint>(info.GetAscent()),
static_cast<jint>(info.GetDescent()),
static_cast<jint>(info.GetMinAltitude()),
static_cast<jint>(info.GetMaxAltitude()),

View file

@ -34,7 +34,7 @@ void InjectMetadata(JNIEnv * env, jclass clazz, jobject const mapObject, feature
jobject CreateMapObject(JNIEnv * env, place_page::Info const & info);
jobject CreateElevationInfo(JNIEnv * env, ElevationInfo const & info);
jobject CreateElevationInfo(JNIEnv * env, std::string const & serverId, ElevationInfo const & info);
jobjectArray ToBannersArray(JNIEnv * env, std::vector<ads::Banner> const & banners);

View file

@ -4,6 +4,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mapswithme.maps.widget.placepage.PlacePageData;
import java.util.ArrayList;
@ -14,6 +15,8 @@ import java.util.List;
public class ElevationInfo implements PlacePageData
{
private final long mId;
@Nullable
private final String mServerId;
@NonNull
private final String mName;
@NonNull
@ -25,11 +28,12 @@ public class ElevationInfo implements PlacePageData
private final int mDifficulty;
private final long mDuration;
public ElevationInfo(long trackId, @NonNull String name, @NonNull Point[] points,
int ascent, int descent, int minAltitude, int maxAltitude, int difficulty,
long duration)
public ElevationInfo(long trackId, @Nullable String serverId, @NonNull String name,
@NonNull Point[] points, int ascent, int descent, int minAltitude,
int maxAltitude, int difficulty, long duration)
{
mId = trackId;
mServerId = serverId;
mName = name;
mPoints = Arrays.asList(points);
mAscent = ascent;
@ -43,6 +47,7 @@ public class ElevationInfo implements PlacePageData
protected ElevationInfo(Parcel in)
{
mId = in.readLong();
mServerId = in.readString();
mName = in.readString();
mAscent = in.readInt();
mDescent = in.readInt();
@ -66,6 +71,12 @@ public class ElevationInfo implements PlacePageData
return mId;
}
@Nullable
public String getServerId()
{
return mServerId;
}
@NonNull
public String getName()
{
@ -118,6 +129,7 @@ public class ElevationInfo implements PlacePageData
public void writeToParcel(Parcel dest, int flags)
{
dest.writeLong(mId);
dest.writeString(mServerId);
dest.writeString(mName);
dest.writeInt(mAscent);
dest.writeInt(mDescent);