1 /* 2 * aTunes 3 * Copyright (C) Alex Aranda, Sylvain Gaudard and contributors 4 * 5 * See http://www.atunes.org/wiki/index.php?title=Contributing for information about contributors 6 * 7 * http://www.atunes.org 8 * http://sourceforge.net/projects/atunes 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License 12 * as published by the Free Software Foundation; either version 2 13 * of the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 */ 20 21 package net.sourceforge.atunes.kernel.modules.covernavigator; 22 23 import java.lang.reflect.InvocationTargetException; 24 25 import javax.swing.SwingUtilities; 26 27 import net.sourceforge.atunes.model.IProcessListener; 28 import net.sourceforge.atunes.utils.Logger; 29 30 final class GetCoversProcessListener implements IProcessListener<Void> { 31 32 private final CoverNavigatorController controller; 33 34 /** 35 * @param controller 36 */ GetCoversProcessListener(final CoverNavigatorController controller)37 public GetCoversProcessListener(final CoverNavigatorController controller) { 38 this.controller = controller; 39 } 40 41 @Override processCanceled()42 public void processCanceled() { 43 update(); 44 } 45 46 @Override processFinished(final boolean ok, final Void result)47 public void processFinished(final boolean ok, final Void result) { 48 update(); 49 } 50 51 /** 52 * Called to update covers 53 */ update()54 private void update() { 55 try { 56 SwingUtilities.invokeAndWait(new Runnable() { 57 @Override 58 public void run() { 59 GetCoversProcessListener.this.controller.updateCovers(); 60 } 61 }); 62 } catch (InvocationTargetException e) { 63 Logger.error(e); 64 } catch (InterruptedException e) { 65 Logger.error(e); 66 } 67 } 68 }