Moves some interface activities to the Swing thread.

We really should be doing this anyway.
This commit is contained in:
Markil3
2021-10-31 16:01:07 -06:00
parent 8022104373
commit afce1a8628

View File

@@ -561,19 +561,25 @@ public class Interface extends JFrame implements SongDisplayListener, ComponentL
@Override @Override
public void updateSongs(Collection<? extends Song> songs) public void updateSongs(Collection<? extends Song> songs)
{
SwingUtilities.invokeLater(() ->
{ {
this.songList.listAlbums(songs); this.songList.listAlbums(songs);
this.centerView.setViewportView(this.songList); this.centerView.setViewportView(this.songList);
this.centerView.revalidate(); this.centerView.revalidate();
});
} }
@Override @Override
public void updateCollections(CollectionType type, Collection<?> collections) public void updateCollections(CollectionType type, Collection<?> collections)
{
SwingUtilities.invokeLater(() ->
{ {
this.collectionList.listCollection(type, collections); this.collectionList.listCollection(type, collections);
this.centerView.setViewportView(this.collectionList); this.centerView.setViewportView(this.collectionList);
this.collectionList.revalidate(); this.collectionList.revalidate();
this.centerView.revalidate(); this.centerView.revalidate();
});
} }
@Override @Override
@@ -643,6 +649,8 @@ public class Interface extends JFrame implements SongDisplayListener, ComponentL
@Override @Override
public <T> void onUpdate(DataProvider<T> provider, int updated, public <T> void onUpdate(DataProvider<T> provider, int updated,
int totalUpdate, String updating) int totalUpdate, String updating)
{
SwingUtilities.invokeLater(() ->
{ {
this.controls.setUpdateProgress(updated, totalUpdate, updating); this.controls.setUpdateProgress(updated, totalUpdate, updating);
if (updated == totalUpdate || totalUpdate == 0) if (updated == totalUpdate || totalUpdate == 0)
@@ -656,6 +664,7 @@ public class Interface extends JFrame implements SongDisplayListener, ComponentL
*/ */
this.updateSongs(songs); this.updateSongs(songs);
} }
});
} }
@Override @Override