diff --git a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp index 6cadf6580f..18f961ce16 100644 --- a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp +++ b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp @@ -43,12 +43,13 @@ struct FileToDownload uint64_t m_fileSize; }; -//static string g_apkPath; -//static string g_sdcardPath; +namespace +{ static vector g_filesToDownload; static int g_totalDownloadedBytes; static int g_totalBytesToDownload; static shared_ptr g_currentRequest; +} // namespace extern "C" { @@ -171,8 +172,8 @@ extern "C" FileToDownload & curFile = g_filesToDownload.back(); JNIEnv * env = jni::GetEnv(); - static jmethodID methodID = jni::GetMethodID(env, *listener.get(), "onProgress", "(I)V"); - env->CallVoidMethod(*listener.get(), methodID, static_cast(g_totalDownloadedBytes + req.Progress().first)); + static jmethodID methodID = jni::GetMethodID(env, *listener, "onProgress", "(I)V"); + env->CallVoidMethod(*listener, methodID, static_cast(g_totalDownloadedBytes + req.Progress().first)); } static void DownloadURLListFinished(HttpRequest const & req, TCallback const & onFinish, TCallback const & onProgress) diff --git a/android/jni/com/mapswithme/maps/MapManager.cpp b/android/jni/com/mapswithme/maps/MapManager.cpp index 231b3563a1..c66375f2d7 100644 --- a/android/jni/com/mapswithme/maps/MapManager.cpp +++ b/android/jni/com/mapswithme/maps/MapManager.cpp @@ -9,7 +9,7 @@ #include "std/bind.hpp" #include "std/shared_ptr.hpp" -namespace data +namespace { using namespace storage; @@ -21,9 +21,9 @@ enum ItemCategory : uint32_t ALL, }; -jclass g_listClass; jmethodID g_listAddMethod; jclass g_countryItemClass; +jobject g_countryChangedListener; Storage & GetStorage() { @@ -32,23 +32,18 @@ Storage & GetStorage() void PrepareClassRefs(JNIEnv * env) { - if (g_listClass) + if (g_listAddMethod) return; - g_listClass = jni::GetGlobalClassRef(env, "java/util/List"); - g_listAddMethod = env->GetMethodID(g_listClass, "add", "(Ljava/lang/Object;)Z"); + jclass listClass = env->FindClass("java/util/List"); + g_listAddMethod = env->GetMethodID(listClass, "add", "(Ljava/lang/Object;)Z"); g_countryItemClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/downloader/CountryItem"); } -} // namespace data +} // namespace extern "C" { - -using namespace storage; -using namespace data; - - // static boolean nativeMoveFile(String oldFile, String newFile); JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_MapStorage_nativeMoveFile(JNIEnv * env, jclass clazz, jstring oldFile, jstring newFile) @@ -308,8 +303,6 @@ Java_com_mapswithme_maps_downloader_MapManager_nativeUnsubscribe(JNIEnv * env, j GetStorage().Unsubscribe(slot); } -static jobject g_countryChangedListener; - // static void nativeSubscribeOnCountryChanged(CurrentCountryChangedListener listener); JNIEXPORT void JNICALL Java_com_mapswithme_maps_downloader_MapManager_nativeSubscribeOnCountryChanged(JNIEnv * env, jclass clazz, jobject listener) diff --git a/android/jni/com/mapswithme/platform/Platform.hpp b/android/jni/com/mapswithme/platform/Platform.hpp index 136acc5716..c1d086493a 100644 --- a/android/jni/com/mapswithme/platform/Platform.hpp +++ b/android/jni/com/mapswithme/platform/Platform.hpp @@ -9,7 +9,6 @@ namespace android class Platform : public ::Platform { public: - Platform() {} void Initialize(JNIEnv * env, jobject functorProcessObject, jstring apkPath, jstring storagePath, diff --git a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java index a96a66edbf..8053293144 100644 --- a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java +++ b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java @@ -85,7 +85,7 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity @SuppressWarnings("unused") private interface Listener { - void onProgress(int progress); + void onProgress(int percent); void onFinish(int errorCode); } @@ -152,10 +152,10 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity private final Listener mResourcesDownloadListener = new Listener() { @Override - public void onProgress(final int progress) + public void onProgress(final int percent) { if (!isFinishing()) - mProgress.setProgress(progress); + mProgress.setProgress(percent); } @Override