Search in sources :

Example 1 with FD_NDK

use of com.android.SdkConstants.FD_NDK in project android by JetBrains.

the class InstallNdkHyperlink method execute.

@Override
protected void execute(@NotNull Project project) {
    File path = getNdkPath(project);
    if (path != null) {
        // Try to install SDK in local.properties.
        SelectNdkDialog dialog = new SelectNdkDialog(path.getPath(), false, true);
        dialog.setModal(true);
        if (dialog.showAndGet() && setNdkPath(project, dialog.getAndroidNdkPath())) {
            // Saving NDK path is successful.
            GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
        }
        return;
    }
    // There is no path. Try installing from SDK.
    AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    StudioLoggerProgressIndicator progressIndicator = new StudioLoggerProgressIndicator(getClass());
    RepoManager sdkManager = sdkHandler.getSdkManager(progressIndicator);
    StudioProgressRunner progressRunner = new StudioProgressRunner(false, /* backgroundable */
    false, /* cancellable */
    "Loading Remote SDK", true, /* in UI thread */
    project);
    RepoManager.RepoLoadedCallback onComplete = packages -> {
        Map<String, RemotePackage> remotePackages = packages.getRemotePackages();
        RemotePackage ndkPackage = remotePackages.get(FD_NDK);
        if (ndkPackage != null) {
            ModelWizardDialog dialog = createDialogForPaths(project, ImmutableList.of(ndkPackage.getPath()));
            if (dialog != null && dialog.showAndGet()) {
                GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
            }
            return;
        }
        notifyNdkPackageNotFound(project);
    };
    Runnable onError = () -> notifyNdkPackageNotFound(project);
    sdkManager.load(DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), ImmutableList.of(onError), progressRunner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Also used : AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) IOException(java.io.IOException) DEFAULT_EXPIRATION_PERIOD_MS(com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS) RemotePackage(com.android.repository.api.RemotePackage) LocalProperties(com.android.tools.idea.gradle.util.LocalProperties) File(java.io.File) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) Nullable(org.jetbrains.annotations.Nullable) SelectNdkDialog(com.android.tools.idea.sdk.SelectNdkDialog) StudioSettingsController(com.android.tools.idea.sdk.StudioSettingsController) ImmutableList(com.google.common.collect.ImmutableList) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) Map(java.util.Map) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) RepoManager(com.android.repository.api.RepoManager) Logger(com.intellij.openapi.diagnostic.Logger) NotNull(org.jetbrains.annotations.NotNull) FD_NDK(com.android.SdkConstants.FD_NDK) GradleSyncInvoker(com.android.tools.idea.gradle.project.sync.GradleSyncInvoker) SdkQuickfixUtils.createDialogForPaths(com.android.tools.idea.sdk.wizard.SdkQuickfixUtils.createDialogForPaths) SelectNdkDialog(com.android.tools.idea.sdk.SelectNdkDialog) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) File(java.io.File) Map(java.util.Map) RemotePackage(com.android.repository.api.RemotePackage) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog)

Aggregations

FD_NDK (com.android.SdkConstants.FD_NDK)1 RemotePackage (com.android.repository.api.RemotePackage)1 RepoManager (com.android.repository.api.RepoManager)1 DEFAULT_EXPIRATION_PERIOD_MS (com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS)1 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)1 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)1 LocalProperties (com.android.tools.idea.gradle.util.LocalProperties)1 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)1 SelectNdkDialog (com.android.tools.idea.sdk.SelectNdkDialog)1 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)1 StudioSettingsController (com.android.tools.idea.sdk.StudioSettingsController)1 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)1 StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)1 SdkQuickfixUtils.createDialogForPaths (com.android.tools.idea.sdk.wizard.SdkQuickfixUtils.createDialogForPaths)1 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)1 ImmutableList (com.google.common.collect.ImmutableList)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Project (com.intellij.openapi.project.Project)1 Messages (com.intellij.openapi.ui.Messages)1 File (java.io.File)1