From e1f37bad8142f00780fc222ef7afb5256697101c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Thu, 12 Oct 2017 12:13:48 +0300 Subject: [PATCH] [android] Refactored passing ugc update time from Java to C++ --- android/jni/com/mapswithme/maps/ugc/UGC.cpp | 6 +++++- android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/android/jni/com/mapswithme/maps/ugc/UGC.cpp b/android/jni/com/mapswithme/maps/ugc/UGC.cpp index 12389e0223..49e209c80f 100644 --- a/android/jni/com/mapswithme/maps/ugc/UGC.cpp +++ b/android/jni/com/mapswithme/maps/ugc/UGC.cpp @@ -99,7 +99,9 @@ public: jstring jtext = static_cast(env->GetObjectField(ugcUpdate, m_ratingTextFieldId)); // TODO: use lang parameter correctly. ugc::Text text(jni::ToNativeString(env, jtext), 1); - return ugc::UGCUpdate(records, text, std::chrono::system_clock::now()); + jlong jtime = env->GetLongField(ugcUpdate, m_updateTimeFieldId); + uint64_t timeSec = static_cast(jtime / 1000); + return ugc::UGCUpdate(records, text, std::chrono::system_clock::from_time_t(timeSec)); } private: @@ -194,6 +196,7 @@ private: env, m_ugcUpdateClass, "([Lcom/mapswithme/maps/ugc/UGC$Rating;Ljava/lang/String;J)V"); m_ratingArrayFieldId = env->GetFieldID(m_ugcUpdateClass, "mRatings", "[Lcom/mapswithme/maps/ugc/UGC$Rating;"); m_ratingTextFieldId = env->GetFieldID(m_ugcUpdateClass, "mText", "Ljava/lang/String;"); + m_updateTimeFieldId = env->GetFieldID(m_ugcUpdateClass, "mTimeMillis", "J"); m_ratingNameFieldId = env->GetFieldID(m_ratingClass, "mName", "Ljava/lang/String;"); m_ratingValueFieldId = env->GetFieldID(m_ratingClass, "mValue", "F"); m_initialized = true; @@ -208,6 +211,7 @@ private: jmethodID m_ugcUpdateCtor; jfieldID m_ratingArrayFieldId; jfieldID m_ratingTextFieldId; + jfieldID m_updateTimeFieldId; jfieldID m_ratingNameFieldId; jfieldID m_ratingValueFieldId; diff --git a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java index 8045d9e0c4..3a59cb61d1 100644 --- a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java +++ b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java @@ -81,7 +81,7 @@ public class UGCEditorFragment extends BaseMwmAuthorizationFragment UGC.Rating[] ratings = new UGC.Rating[modifiedRatings.size()]; modifiedRatings.toArray(ratings); UGCUpdate update = new UGCUpdate(ratings, mReviewEditText.getText().toString(), - 0 /* mTimeMillis. It's set in JNI, UGC.cpp */); + System.currentTimeMillis()); FeatureId featureId = getArguments().getParcelable(ARG_FEATURE_ID); if (featureId == null) throw new AssertionError("Feature ID must be passed to this fragment!");