From 353685701f0a0363bd25e375a438fac1ccdfc107 Mon Sep 17 00:00:00 2001 From: Dmitry Donskoy Date: Tue, 7 Apr 2020 16:16:20 +0300 Subject: [PATCH] [android] Fixed show banner redundant event --- .../maps/downloader/OnmapDownloader.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java index 559eda5362..f8b15f24a4 100644 --- a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java +++ b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java @@ -106,7 +106,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener { updateStateInternal(shouldAutoDownload); - if (mPromoBanner == null || mCurrentCountry == null) + if (mPromoBanner == null || !hasMapDownloading(mCurrentCountry)) return; Statistics.ParameterBuilder builder = @@ -116,6 +116,16 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_BANNER_SHOW, builder); } + private static boolean hasMapDownloading(@Nullable CountryItem country) + { + if (country == null) return false; + + boolean enqueued = country.status == CountryItem.STATUS_ENQUEUED; + boolean progress = country.status == CountryItem.STATUS_PROGRESS; + boolean applying = country.status == CountryItem.STATUS_APPLYING; + return enqueued || progress || applying; + } + private void updateProgressState(boolean shouldAutoDownload) { updateStateInternal(shouldAutoDownload); @@ -293,11 +303,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener mPromoBanner = Framework.nativeGetDownloaderPromoBanner(mCurrentCountry.id); boolean isPromoFound = mPromoBanner != null; - - boolean enqueued = mCurrentCountry.status == CountryItem.STATUS_ENQUEUED; - boolean progress = mCurrentCountry.status == CountryItem.STATUS_PROGRESS; - boolean applying = mCurrentCountry.status == CountryItem.STATUS_APPLYING; - boolean isDownloading = enqueued || progress || applying; + boolean isDownloading = hasMapDownloading(mCurrentCountry); if (!isDownloading || !isPromoFound) {