Skip to content

Commit

Permalink
[offline][android] Add setOffline method (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
shroff committed Mar 30, 2021
1 parent 108d6bb commit 74c656a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import android.content.Context;
import com.mapbox.mapboxsdk.net.ConnectivityReceiver;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -64,14 +64,17 @@ public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
installOfflineMapTiles(tilesDb);
result.success(null);
break;
case "setOffline":
boolean offline = methodCall.argument("offline");
ConnectivityReceiver.instance(context).setConnected(offline ? false : null);
result.success(null);
break;
case "mergeOfflineRegions":
OfflineManagerUtils.mergeRegions(result, context, methodCall.argument("path"));
break;

case "setOfflineTileCountLimit":
OfflineManagerUtils.setOfflineTileCountLimit(result, context, methodCall.<Number>argument("limit").longValue());
break;

case "downloadOfflineRegion":
// Get args from caller
Map<String, Object> definitionMap = (Map<String, Object>) methodCall.argument("definition");
Expand Down
12 changes: 12 additions & 0 deletions lib/src/global.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ Future<void> installOfflineMapTiles(String tilesDb) async {
);
}

Future<dynamic> setOffline(
bool offline, {
String accessToken,
}) =>
_globalChannel.invokeMethod(
'setOffline',
<String, dynamic>{
'offline': offline,
'accessToken': accessToken,
},
);

Future<List<OfflineRegion>> mergeOfflineRegions(
String path, {
String accessToken,
Expand Down

0 comments on commit 74c656a

Please sign in to comment.