Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugin-offline/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Mapbox welcomes participation and contributions from everyone.

### mapbox-android-plugin-offline-v9:0.10.0 - August 24, 2021
- Add throttle for offline plugin notification update [#1200](https://github.com/mapbox/mapbox-plugins-android/pull/1200)

### mapbox-android-plugin-offline-v9:0.9.0 - August 18, 2021
- Update compatibility for Android 12 [#1194](https://github.com/mapbox/mapbox-plugins-android/pull/1194)
- Bump maps sdk to 9.6.2 [#1194](https://github.com/mapbox/mapbox-plugins-android/pull/1194)
Expand Down
2 changes: 1 addition & 1 deletion plugin-offline/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.9.0-SNAPSHOT
VERSION_NAME=0.10.0-SNAPSHOT
POM_ARTIFACT_ID=mapbox-android-plugin-offline-v9
POM_NAME=Mapbox Android Offline Plugin
POM_DESCRIPTION=Mapbox Android Offline Plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class OfflineDownloadService extends Service {
// map offline regions to requests, ids are received with onStartCommand, these match serviceId
// in OfflineDownloadOptions
final LongSparseArray<OfflineRegion> regionLongSparseArray = new LongSparseArray<>();
final LongSparseArray<Integer> regionProgressSparseArray = new LongSparseArray<>();

@Override
public void onCreate() {
Expand Down Expand Up @@ -130,7 +131,7 @@ public void onCreate(OfflineRegion offlineRegion) {
= offlineDownload.toBuilder().uuid(offlineRegion.getID()).build();
OfflineDownloadStateReceiver.dispatchStartBroadcast(getApplicationContext(), options);
regionLongSparseArray.put(options.uuid(), offlineRegion);

regionProgressSparseArray.put(options.uuid(), 0);
launchDownload(options, offlineRegion);
showNotification(options);
}
Expand Down Expand Up @@ -209,6 +210,7 @@ private synchronized void removeOfflineRegion(int regionId) {
notificationManager.cancel(regionId);
}
regionLongSparseArray.remove(regionId);
regionProgressSparseArray.remove(regionId);
if (regionLongSparseArray.size() == 0) {
stopForeground(true);
}
Expand Down Expand Up @@ -266,11 +268,15 @@ void progressDownload(OfflineDownloadOptions offlineDownload, OfflineRegionStatu

offlineDownload = offlineDownload.toBuilder().progress(percentage).build();

if (percentage % 2 == 0 && regionLongSparseArray.get(offlineDownload.uuid().intValue()) != null) {
int uuid = offlineDownload.uuid().intValue();
Integer lastPercent = regionProgressSparseArray.get(uuid);
if (percentage % 2 == 0 && regionLongSparseArray.get(uuid) != null
&& lastPercent != null && percentage != lastPercent) {
regionProgressSparseArray.put(uuid, percentage);
OfflineDownloadStateReceiver.dispatchProgressChanged(this, offlineDownload, percentage);
if (notificationBuilder != null) {
notificationBuilder.setProgress(100, percentage, false);
notificationManager.notify(offlineDownload.uuid().intValue(), notificationBuilder.build());
notificationManager.notify(uuid, notificationBuilder.build());
}
}
}
Expand Down