use of com.intellij.openapi.project.ProjectType in project flutter-intellij by flutter.
the class AddToAppUtils method initializeAndDetectFlutter.
public static boolean initializeAndDetectFlutter(@NotNull Project project) {
MessageBusConnection connection = project.getMessageBus().connect(project);
// GRADLE_SYNC_TOPIC is not public in Android Studio 3.5. It is in 3.6. It isn't defined in 3.4.
// noinspection unchecked
Topic<GradleSyncListener> topic = getStaticFieldValue(GradleSyncState.class, Topic.class, "GRADLE_SYNC_TOPIC");
assert topic != null;
connection.subscribe(topic, makeSyncListener(project));
if (!FlutterModuleUtils.hasFlutterModule(project)) {
connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {
@Override
public void moduleAdded(@NotNull Project proj, @NotNull Module mod) {
if (AndroidUtils.FLUTTER_MODULE_NAME.equals(mod.getName()) || (FlutterUtils.flutterGradleModuleName(project)).equals(mod.getName())) {
// connection.disconnect(); TODO(messick) Test this deletion!
AppExecutorUtil.getAppExecutorService().execute(() -> {
GradleUtils.enableCoeditIfAddToAppDetected(project);
});
}
}
});
return false;
} else {
@Nullable ProjectType projectType = ProjectTypeService.getProjectType(project);
if (projectType != null && "Android".equals(projectType.getId())) {
// This is an add-to-app project.
connection.subscribe(DebuggerManagerListener.TOPIC, makeAddToAppAttachListener(project));
}
}
return true;
}
Aggregations