From 0a59520e0f1c729ad3dba7e7680bf62fcc715898 Mon Sep 17 00:00:00 2001 From: Jerome Gaillard Date: Mon, 3 Aug 2015 11:50:48 -0500 Subject: Comments about invokeLater and code cleaning Following up on comment in http://r.android.com/161090 Change-Id: Ifb162ff53cdf3f2da6a52acc5b21f1be8ba76a88 --- .../tools/idea/editors/theme/ThemeEditorComponent.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'android') diff --git a/android/src/com/android/tools/idea/editors/theme/ThemeEditorComponent.java b/android/src/com/android/tools/idea/editors/theme/ThemeEditorComponent.java index 053c3a6a6a2..d62a724e42e 100644 --- a/android/src/com/android/tools/idea/editors/theme/ThemeEditorComponent.java +++ b/android/src/com/android/tools/idea/editors/theme/ThemeEditorComponent.java @@ -166,7 +166,6 @@ public class ThemeEditorComponent extends Splitter { private final ResourceChangeListener myResourceChangeListener; private boolean myIsSubscribedResourceNotification; - private final GoToListener myGoToListener; private MutableCollectionComboBoxModel myModuleComboModel; /** Next pending search. The {@link ScheduledFuture} allows us to cancel the next search before it runs. */ @@ -224,7 +223,7 @@ public class ThemeEditorComponent extends Splitter { myPreviewPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); ResourcesCompletionProvider completionProvider = new ResourcesCompletionProvider(myThemeEditorContext); - myGoToListener = new GoToListener() { + GoToListener goToListener = new GoToListener() { @Override public void goTo(@NotNull EditedStyleItem value) { ResourceResolver resolver = myThemeEditorContext.getResourceResolver(); @@ -251,7 +250,7 @@ public class ThemeEditorComponent extends Splitter { ThemeEditorComponent.this.goToParent(); } }; - myAttributesTable.setGoToListener(myGoToListener); + myAttributesTable.setGoToListener(goToListener); final AttributeReferenceRendererEditor styleEditor = new AttributeReferenceRendererEditor(project, completionProvider); final JScrollPane scroll = myPanel.getAttributesScrollPane(); @@ -582,9 +581,8 @@ public class ThemeEditorComponent extends Splitter { renameDialog.show(); if (renameDialog.isOK()) { String newName = renameDialog.getNewName(); - String newQualifiedName = selectedTheme.getQualifiedName().replace(selectedTheme.getName(), newName); // We don't need to call reload here, because myResourceChangeListener will take care of it - myThemeName = newQualifiedName; + myThemeName = selectedTheme.getQualifiedName().replace(selectedTheme.getName(), newName); mySubStyleName = null; return true; } @@ -675,6 +673,7 @@ public class ThemeEditorComponent extends Splitter { return; } + // Need invokeLater to wait for the theme resolver to be aware of the newly created style through the resource change listener ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { @@ -719,6 +718,8 @@ public class ThemeEditorComponent extends Splitter { // We don't need to call reload, because myResourceChangeListener will take care of it myThemeName = newThemeName; mySubStyleName = newStyleName; + + // Need invokeLater to wait for the theme resolver to be aware of the newly created theme through the resource change listener ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { -- cgit v1.2.3