Skip to content

Commit

Permalink
Merge branch 'NonNull-annotations'
Browse files Browse the repository at this point in the history
  • Loading branch information
christocracy committed Jun 28, 2024
2 parents 2672021 + b26ad30 commit c585fa5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Unreleased
* [Android] Add `@NonNull` annotations to flutter plugin methods.
* [Android] Enable `multidex` in Android /example.

## 1.3.5 — 2024-05-27
* Update analysis_options.yaml for pub.dev. There are no code changes from 1.3.4.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public class BackgroundFetchModule implements MethodCallHandler {

private static final String HEADLESS_JOB_SERVICE_CLASS = HeadlessTask.class.getName();

private FetchStreamHandler mFetchCallback;
private final FetchStreamHandler mFetchCallback;

private Context mContext;

private BinaryMessenger mMessenger;
private AtomicBoolean mIsAttachedToEngine = new AtomicBoolean(false);
private final AtomicBoolean mIsAttachedToEngine = new AtomicBoolean(false);
private MethodChannel mMethodChannel;
private EventChannel mEventChannelTask;

Expand Down Expand Up @@ -100,7 +100,7 @@ void setActivity(Activity activity) {

@SuppressWarnings("unchecked")
@Override
public void onMethodCall(MethodCall call, @NonNull Result result) {
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
if (call.method.equals(BackgroundFetch.ACTION_CONFIGURE)) {
Map<String, Object> params = (Map<String, Object>) call.arguments;
configure(params, result);
Expand Down Expand Up @@ -131,7 +131,7 @@ private void registerHeadlessTask(List<Object> callbacks, Result result) {
}
}

private void configure(Map<String, Object> params, Result result) {
private void configure(Map<String, Object> params, @NonNull Result result) {
BackgroundFetch adapter = BackgroundFetch.getInstance(mContext);
adapter.configure(buildConfig(params)
.setTaskId(FETCH_TASK_ID)
Expand All @@ -141,19 +141,19 @@ private void configure(Map<String, Object> params, Result result) {
result.success(adapter.status());
}

private void start(Result result) {
private void start(@NonNull Result result) {
BackgroundFetch adapter = BackgroundFetch.getInstance(mContext);
adapter.start(FETCH_TASK_ID);
result.success(adapter.status());
}

private void stop(@Nullable String taskId, Result result) {
private void stop(@Nullable String taskId, @NonNull Result result) {
BackgroundFetch adapter = BackgroundFetch.getInstance(mContext);
adapter.stop(taskId);
result.success(adapter.status());
}

private void status(Result result) {
private void status(@NonNull Result result) {
BackgroundFetch adapter = BackgroundFetch.getInstance(mContext);
result.success(adapter.status());
}
Expand All @@ -166,13 +166,14 @@ private void finish(String taskId, Result result) {
result.success(true);
}

private void scheduleTask(Map<String, Object> params, Result result) {
private void scheduleTask(Map<String, Object> params, @NonNull Result result) {
BackgroundFetch adapter = BackgroundFetch.getInstance(mContext);
adapter.scheduleTask(buildConfig(params).build());
result.success(true);
}

private BackgroundFetchConfig.Builder buildConfig(Map<String, Object>params) {
@NonNull
private BackgroundFetchConfig.Builder buildConfig(@NonNull Map<String, Object>params) {
BackgroundFetchConfig.Builder config = new BackgroundFetchConfig.Builder();

if (params.containsKey(BackgroundFetchConfig.FIELD_TASK_ID)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;

/** BackgroundFetchPlugin */
public class BackgroundFetchPlugin implements FlutterPlugin, ActivityAware {
Expand All @@ -14,7 +12,7 @@ public class BackgroundFetchPlugin implements FlutterPlugin, ActivityAware {
public BackgroundFetchPlugin() { }

@Override
public void onAttachedToEngine(FlutterPlugin.FlutterPluginBinding binding) {
public void onAttachedToEngine(@NonNull FlutterPlugin.FlutterPluginBinding binding) {
BackgroundFetchModule.getInstance().onAttachedToEngine(binding.getApplicationContext(), binding.getBinaryMessenger());
}

Expand All @@ -24,7 +22,7 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
}

@Override
public void onAttachedToActivity(ActivityPluginBinding activityPluginBinding) {
public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) {
BackgroundFetchModule.getInstance().setActivity(activityPluginBinding.getActivity());
}

Expand Down
4 changes: 3 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample"
multiDexEnabled true
minSdkVersion flutter.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode flutterVersionCode.toInteger()
Expand All @@ -65,5 +66,6 @@ flutter {
}

dependencies {

def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
}
18 changes: 0 additions & 18 deletions example/ios/Flutter/Flutter.podspec

This file was deleted.

6 changes: 3 additions & 3 deletions example/ios/Flutter/Generated.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ FLUTTER_BUILD_NUMBER=2
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=false
TREE_SHAKE_ICONS=true
PACKAGE_CONFIG=/Users/chris/workspace/background-geolocation/flutter/flutter_background_fetch/example/.dart_tool/package_config.json
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json
6 changes: 3 additions & 3 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.1.0"
export "FLUTTER_BUILD_NUMBER=2"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=true"
export "PACKAGE_CONFIG=/Users/chris/workspace/background-geolocation/flutter/flutter_background_fetch/example/.dart_tool/package_config.json"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"

0 comments on commit c585fa5

Please sign in to comment.