Skip to content

Commit 2c53a81

Browse files
authored
[CQ] AddToAppUtils: fix deprecated API use and unchecked calls (#8012)
Migrate to future-safe `modulesAdded` API and fix unchecked calls. (Removing another bit of noise from the run console.) ![image](https://github.com/user-attachments/assets/820a76c6-a99a-4251-9bab-f684fff60754) See: #7718.
1 parent 20e2330 commit 2c53a81

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

Diff for: flutter-studio/src/io/flutter/utils/AddToAppUtils.java

+18-11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.lang.reflect.Field;
3737
import java.lang.reflect.Modifier;
3838
import java.util.Collection;
39+
import java.util.List;
3940

4041
import org.jetbrains.annotations.NonNls;
4142
import org.jetbrains.annotations.NotNull;
@@ -59,24 +60,30 @@ public static boolean initializeAndDetectFlutter(@NotNull Project project) {
5960
if (!FlutterModuleUtils.hasFlutterModule(project)) {
6061
connection.subscribe(ModuleListener.TOPIC, new ModuleListener() {
6162
@Override
62-
public void moduleAdded(@NotNull Project proj, @NotNull Module mod) {
63-
if (AndroidUtils.FLUTTER_MODULE_NAME.equals(mod.getName()) ||
64-
(FlutterUtils.flutterGradleModuleName(project)).equals(mod.getName())) {
65-
//connection.disconnect(); TODO(messick) Test this deletion!
66-
AppExecutorUtil.getAppExecutorService().execute(() -> {
67-
GradleUtils.enableCoeditIfAddToAppDetected(project);
68-
});
63+
public void modulesAdded(@NotNull Project proj, @NotNull List<? extends Module> modules) {
64+
for (Module module : modules) {
65+
if (module == null) continue;
66+
if (AndroidUtils.FLUTTER_MODULE_NAME.equals(module.getName()) ||
67+
(FlutterUtils.flutterGradleModuleName(project)).equals(module.getName())) {
68+
//connection.disconnect(); TODO(messick) Test this deletion!
69+
AppExecutorUtil.getAppExecutorService().execute(() -> {
70+
GradleUtils.enableCoeditIfAddToAppDetected(project);
71+
});
72+
}
6973
}
74+
7075
}
7176
});
7277
return false;
7378
}
7479
else {
7580
Collection<ProjectType> projectTypes = ProjectTypeService.getProjectTypes(project);
76-
for(ProjectType projectType : projectTypes) {
77-
if (projectType != null && "Android".equals(projectType.getId())) {
78-
// This is an add-to-app project.
79-
connection.subscribe(DebuggerManagerListener.TOPIC, makeAddToAppAttachListener(project));
81+
if (projectTypes != null) {
82+
for (ProjectType projectType : projectTypes) {
83+
if (projectType != null && "Android".equals(projectType.getId())) {
84+
// This is an add-to-app project.
85+
connection.subscribe(DebuggerManagerListener.TOPIC, makeAddToAppAttachListener(project));
86+
}
8087
}
8188
}
8289
}

0 commit comments

Comments
 (0)