Fixed UI thread not being updated with new file drops

This commit is contained in:
Sollace 2018-06-03 14:28:59 +02:00
parent 28274b76fd
commit 086ff5a677

View file

@ -93,6 +93,8 @@ public class GuiSkins extends GuiScreen implements FutureCallback<SkinUploadResp
private static JFrame fileDrop; private static JFrame fileDrop;
private static GuiSkins instance;
private MinecraftProfileTexture.Type textureType = SKIN; private MinecraftProfileTexture.Type textureType = SKIN;
public GuiSkins() { public GuiSkins() {
@ -107,6 +109,8 @@ public class GuiSkins extends GuiScreen implements FutureCallback<SkinUploadResp
rm.renderViewEntity = this.localPlayer; rm.renderViewEntity = this.localPlayer;
this.reloadRemoteSkin(); this.reloadRemoteSkin();
this.fetchingSkin = true; this.fetchingSkin = true;
instance = this;
} }
protected EntityPlayerModel getModel(GameProfile profile) { protected EntityPlayerModel getModel(GameProfile profile) {
@ -199,6 +203,7 @@ public class GuiSkins extends GuiScreen implements FutureCallback<SkinUploadResp
fileDrop.setLocation(Display.getX(), Display.getY()); fileDrop.setLocation(Display.getX(), Display.getY());
return; return;
} }
fileDrop = new JFrame("Skin Drop"); fileDrop = new JFrame("Skin Drop");
fileDrop.setType(Type.UTILITY); fileDrop.setType(Type.UTILITY);
fileDrop.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); fileDrop.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
@ -222,7 +227,9 @@ public class GuiSkins extends GuiScreen implements FutureCallback<SkinUploadResp
DropTarget dt = new DropTarget(); DropTarget dt = new DropTarget();
fileDrop.setDropTarget(dt); fileDrop.setDropTarget(dt);
try { try {
dt.addDropTargetListener((FileDropListener) files -> files.stream().findFirst().ifPresent(this::loadLocalFile)); dt.addDropTargetListener((FileDropListener) files -> {
files.stream().findFirst().ifPresent(instance::loadLocalFile);
});
fileDrop.setVisible(true); fileDrop.setVisible(true);
fileDrop.requestFocusInWindow(); fileDrop.requestFocusInWindow();
} catch (Exception e) { } catch (Exception e) {