Skip to content

Commit

Permalink
Crash fixed
Browse files Browse the repository at this point in the history
Fixed crash if the data/ folder is not existing
  • Loading branch information
MonsterDruide1 committed Aug 27, 2019
1 parent d4b4f24 commit 6c6e4d0
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions MiBand4Editor/src/display/SnapPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,22 @@ public SnapPanel(MiBand4Editor main) throws IOException {
this.main=main;
addMouseListener(this);
addMouseMotionListener(this);
BufferedReader br = new BufferedReader(new FileReader(new File(MiBand4Editor.currentPath.getAbsolutePath()+"\\watchface.json")));
String line = "";
StringBuilder builder = new StringBuilder();
while((line=br.readLine())!=null) {
builder.append(line);
}
br.close();

JSONObject all = new JSONObject(builder.toString());
JSONObject image = all.getJSONObject("Background").getJSONObject("Image");
backgroundCoords = new Point(image.getInt("X"),image.getInt("Y"));
try {
BufferedReader br = new BufferedReader(new FileReader(new File(MiBand4Editor.currentPath.getAbsolutePath()+"\\watchface.json")));
String line = "";
StringBuilder builder = new StringBuilder();
while((line=br.readLine())!=null) {
builder.append(line);
}
br.close();

JSONObject all = new JSONObject(builder.toString());
JSONObject image = all.getJSONObject("Background").getJSONObject("Image");
backgroundCoords = new Point(image.getInt("X"),image.getInt("Y"));
}
catch(IOException e) {
backgroundCoords = new Point(0,0);
}
}

public int getSnapDelta() {
Expand Down

0 comments on commit 6c6e4d0

Please sign in to comment.