Skip to content

Commit

Permalink
Merge pull request #4712 from alexzatsepin/MAPSME-2954-mycom-banner-fix
Browse files Browse the repository at this point in the history
[android] Added clearing the banners when search returns nothing
  • Loading branch information
mpimenov authored Nov 11, 2016
2 parents 889be13 + bf38230 commit 4472c50
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -740,14 +740,26 @@ void refreshData()
loadAds();
}

void setSearchResultsMode(Collection<CountryItem> results, String query)
void setSearchResultsMode(@NonNull Collection<CountryItem> results, String query)
{
mSearchResultsMode = true;
mSearchQuery = query.toLowerCase();

mItems.clear();
mItems.addAll(results);
processData();
if (results.isEmpty())
clearAds();
}

private void clearAds()
{
if (mAds.isEmpty())
return;

mAds.clear();
mAdsLoaded = false;
notifyDataSetChanged();
}

void resetSearchResultsMode()
Expand Down Expand Up @@ -1009,7 +1021,6 @@ public void onDataReady(@Nullable List<NativeAppwallBanner> banners)
mAdsLoading = false;
mAdsLoaded = true;

int oldSize = mAds.size();
mAds.clear();

if (banners != null)
Expand All @@ -1018,10 +1029,7 @@ public void onDataReady(@Nullable List<NativeAppwallBanner> banners)
mAds.add(banner);

mHeadersDecoration.invalidateHeaders();
if (oldSize == 0)
notifyItemRangeInserted(mNearMeCount, mAds.size());
else
notifyDataSetChanged();
notifyDataSetChanged();
}
}, mActivity);
}
Expand Down

0 comments on commit 4472c50

Please sign in to comment.