diff options
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java index cbeb274..c53fdb0 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java @@ -1810,6 +1810,12 @@ public class AdtPlugin extends AbstractUIPlugin implements ILogger { * and updates opened projects. * <p/> * The operation is asynchronous and happens in a background eclipse job. + * <p/> + * This operation is called in multiple places and should be reasonably + * cheap and conservative. The goal is to automatically refresh the SDK + * when it is obvious it has changed so when not sure the code should + * tend to not reload and avoid reloading too often (which is an expensive + * operation that has a lot of user impact.) */ public void refreshSdk() { // SDK can't have changed if we haven't loaded it yet. @@ -1822,8 +1828,29 @@ public class AdtPlugin extends AbstractUIPlugin implements ILogger { @Override protected IStatus run(IProgressMonitor monitor) { // SDK has changed if its location path is different. - boolean changed = sdk.getSdkLocation() == null || - !sdk.getSdkLocation().equals(AdtPrefs.getPrefs().getOsSdkFolder()); + File location = sdk.getSdkFileLocation(); + boolean changed = location == null || !location.isDirectory(); + + if (!changed) { + assert location != null; + File prefLocation = new File(AdtPrefs.getPrefs().getOsSdkFolder()); + changed = !location.equals(prefLocation); + + if (changed) { + // Basic file path comparison indicates they are not the same. + // Let's dig a bit deeper. + try { + location = location.getCanonicalFile(); + prefLocation = prefLocation.getCanonicalFile(); + changed = !location.equals(prefLocation); + } catch (IOException ignore) { + // There's no real reason for the canonicalization to fail + // if the paths map to actual directories. And if they don't + // this should have been caught above. + } + } + } + if (!changed) { // Check whether the target directories has potentially changed. changed = sdk.haveTargetsChanged(); |