git://git.nikiroo.be
/
fanfix.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e915ed7
)
details: delay and do last one only
author
Niki Roo
<niki@nikiroo.be>
Wed, 8 Apr 2020 15:46:00 +0000
(17:46 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Wed, 8 Apr 2020 15:46:00 +0000
(17:46 +0200)
src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java
patch
|
blob
|
blame
|
history
diff --git
a/src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java
b/src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java
index da1af4c480af6f757c69b9bb53ef75b26ddb0e07..ced9c3b939f50d59e038bad8321faa17f001d23c 100644
(file)
--- a/
src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java
+++ b/
src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java
@@
-31,6
+31,8
@@
public class DetailsPanel extends JPanel {
private JLabel name;
private JLabel opt;
private JLabel name;
private JLabel opt;
+ private BookInfo info;
+
/**
* Create a new {@link DetailsPanel}.
*/
/**
* Create a new {@link DetailsPanel}.
*/
@@
-77,25
+79,41
@@
public class DetailsPanel extends JPanel {
* @param info the {@link BookInfo} to display
*/
public void setBook(final BookInfo info) {
* @param info the {@link BookInfo} to display
*/
public void setBook(final BookInfo info) {
+ this.info = info;
+
icon.setIcon(null);
if (info == null) {
name.setText(null);
opt.setText(null);
} else {
icon.setIcon(null);
if (info == null) {
name.setText(null);
opt.setText(null);
} else {
+ final String myId = info.getId();
+
name.setText(info.getMainInfo());
opt.setText(info.getSecondaryInfo(true));
new SwingWorker<Image, Void>() {
@Override
protected Image doInBackground() throws Exception {
name.setText(info.getMainInfo());
opt.setText(info.getSecondaryInfo(true));
new SwingWorker<Image, Void>() {
@Override
protected Image doInBackground() throws Exception {
- return BookBlock.generateCoverImage(Instance.getInstance().getLibrary(), info);
+ Thread.sleep(20);
+
+ BookInfo current = DetailsPanel.this.info;
+ if (current != null && current.getId().equals(myId)) {
+ return BookBlock.generateCoverImage(Instance.getInstance().getLibrary(), info);
+ }
+
+ return null;
}
@Override
protected void done() {
}
@Override
protected void done() {
- try {
- icon.setIcon(new ImageIcon(get()));
- } catch (InterruptedException e) {
- } catch (ExecutionException e) {
+ BookInfo current = DetailsPanel.this.info;
+ if (current != null && current.getId().equals(myId)) {
+ try {
+ Image img = get();
+ if (img != null)
+ icon.setIcon(new ImageIcon(img));
+ } catch (InterruptedException e) {
+ } catch (ExecutionException e) {
+ }
}
}
}.execute();
}
}
}.execute();