diff --git a/android/jni/com/mapswithme/maps/MapManager.cpp b/android/jni/com/mapswithme/maps/MapManager.cpp index 3c243ba624..4ccdbbaa2c 100644 --- a/android/jni/com/mapswithme/maps/MapManager.cpp +++ b/android/jni/com/mapswithme/maps/MapManager.cpp @@ -104,7 +104,8 @@ static void MigrationStatusChangedCallback(TCountryId const & countryId, bool ke case NodeStatus::Undefined: case NodeStatus::Error: - OnMigrationError(attrs.m_error); + if (attrs.m_mwmCounter == 1) + OnMigrationError(attrs.m_error); break; } } @@ -356,8 +357,8 @@ static void StatusChangedCallback(shared_ptr const & listenerRef, TCoun NodeAttrs attrs; GetStorage().GetNodeAttrs(countryId, attrs); - jmethodID const methodID = jni::GetMethodID(env, *listenerRef, "onStatusChanged", "(Ljava/lang/String;I)V"); - env->CallVoidMethod(*listenerRef, methodID, jni::ToJavaString(env, countryId), attrs.m_status); + jmethodID const methodID = jni::GetMethodID(env, *listenerRef, "onStatusChanged", "(Ljava/lang/String;IZ)V"); + env->CallVoidMethod(*listenerRef, methodID, jni::ToJavaString(env, countryId), attrs.m_status, (attrs.m_mwmCounter == 1); } static void ProgressChangedCallback(shared_ptr const & listenerRef, TCountryId const & countryId, TLocalAndRemoteSize const & sizes) diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp index b2336c0b04..65afe2e1a4 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.cpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp @@ -69,7 +69,7 @@ jobject ToJavaResult(Result result, bool hasPosition, double lat, double lon) auto const address = g_framework->NativeFramework()->GetSearchResultAddress(result); - jni::TScopedLocalRef featureType (env, jni::ToJavaString(env, result.GetFeatureType())); + jni::TScopedLocalRef featureType(env, jni::ToJavaString(env, result.GetFeatureType())); jni::TScopedLocalRef region(env, jni::ToJavaString(env, address.FormatAddress(search::AddressInfo::SEARCH_RESULT))); jni::TScopedLocalRef dist(env, jni::ToJavaString(env, distance)); jni::TScopedLocalRef cuisine(env, jni::ToJavaString(env, result.GetCuisine())); diff --git a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java index 8053293144..cade4e6261 100644 --- a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java +++ b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java @@ -178,9 +178,9 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity private final MapManager.StorageCallback mCountryDownloadListener = new MapManager.StorageCallback() { @Override - public void onStatusChanged(String countryId, int newStatus) + public void onStatusChanged(String countryId, int newStatus, boolean isLeafNode) { - if (newStatus == CountryItem.STATUS_DONE) + if (newStatus == CountryItem.STATUS_DONE && isLeafNode) { mAreResourcesDownloaded = true; showMap(); diff --git a/android/src/com/mapswithme/maps/MwmApplication.java b/android/src/com/mapswithme/maps/MwmApplication.java index 34064f25be..ec1dfb759f 100644 --- a/android/src/com/mapswithme/maps/MwmApplication.java +++ b/android/src/com/mapswithme/maps/MwmApplication.java @@ -25,6 +25,7 @@ import com.mapswithme.util.ThemeSwitcher; import com.mapswithme.util.UiUtils; import com.mapswithme.util.Yota; import com.mapswithme.util.statistics.AlohaHelper; +import com.mapswithme.util.statistics.Statistics; import com.parse.Parse; import com.parse.ParseException; import com.parse.ParseInstallation; @@ -51,11 +52,15 @@ public class MwmApplication extends Application private final MapManager.StorageCallback mStorageCallbacks = new MapManager.StorageCallback() { @Override - public void onStatusChanged(String countryId, int newStatus) + public void onStatusChanged(String countryId, int newStatus, boolean isLeafNode) { Notifier.cancelDownloadSuggest(); - if (newStatus == CountryItem.STATUS_FAILED) - Notifier.notifyDownloadFailed(countryId); + if (newStatus == CountryItem.STATUS_FAILED && isLeafNode) + { + CountryItem country = CountryItem.fill(countryId); + Notifier.notifyDownloadFailed(country); + MapManager.sendErrorStat(Statistics.EventName.DOWNLOADER_ERROR, country.errorCode); + } } @Override diff --git a/android/src/com/mapswithme/maps/background/Notifier.java b/android/src/com/mapswithme/maps/background/Notifier.java index 5b7d1f75ab..25370bb2ba 100644 --- a/android/src/com/mapswithme/maps/background/Notifier.java +++ b/android/src/com/mapswithme/maps/background/Notifier.java @@ -34,14 +34,12 @@ public final class Notifier placeNotification(title, countryName, pi, ID_UPDATE_AVAILABLE); } - public static void notifyDownloadFailed(String countryId) + public static void notifyDownloadFailed(CountryItem country) { - CountryItem item = CountryItem.fill(countryId); - String title = APP.getString(R.string.app_name); - String content = APP.getString(R.string.download_country_failed, item.name); + String content = APP.getString(R.string.download_country_failed, country.name); - PendingIntent pi = PendingIntent.getActivity(APP, 0, MwmActivity.createShowMapIntent(APP, countryId, false) + PendingIntent pi = PendingIntent.getActivity(APP, 0, MwmActivity.createShowMapIntent(APP, country.id, false) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java b/android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java index 7c7e94efb9..f0cd008418 100644 --- a/android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java +++ b/android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java @@ -18,6 +18,7 @@ import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.widget.WheelProgressView; import com.mapswithme.util.StringUtils; import com.mapswithme.util.UiUtils; +import com.mapswithme.util.statistics.Statistics; public class CountrySuggestFragment extends BaseMwmFragment implements View.OnClickListener { @@ -50,9 +51,9 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl mListenerSlot = MapManager.nativeSubscribe(new MapManager.StorageCallback() { @Override - public void onStatusChanged(String countryId, int newStatus) + public void onStatusChanged(String countryId, int newStatus, boolean isLeafNode) { - if (!isAdded()) + if (!isLeafNode || !isAdded()) return; refreshViews(); @@ -191,6 +192,9 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl case R.id.wpv__download_progress: MapManager.nativeCancel(mDownloadingCountry.id); + + Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_CANCEL, + Statistics.params().add(Statistics.EventParam.FROM, "search")); break; } } diff --git a/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java b/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java index 03a010716e..1a49c437bf 100644 --- a/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java +++ b/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java @@ -31,6 +31,7 @@ import com.mapswithme.util.BottomSheetHelper; import com.mapswithme.util.StringUtils; import com.mapswithme.util.ThemeUtils; import com.mapswithme.util.UiUtils; +import com.mapswithme.util.statistics.Statistics; import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersAdapter; import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; @@ -62,8 +63,14 @@ class DownloaderAdapter extends RecyclerView.Adapter