Fixed some more NullPointerException errors

This commit is contained in:
William Brawner 2017-08-29 20:41:06 -06:00 committed by William Brawner
parent b0490105b3
commit b63cef8c1b

View file

@ -43,12 +43,14 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
public void loadMarkdown(String filePath) { public void loadMarkdown(String filePath) {
Runnable fileLoader = () -> { Runnable fileLoader = () -> {
int result = file.load(filePath); int result = file.load(filePath);
if (editView != null) {
if (result == MarkdownFile.SUCCESS) { if (result == MarkdownFile.SUCCESS) {
editView.setMarkdown(getMarkdown()); editView.setMarkdown(getMarkdown());
onMarkdownEdited(); onMarkdownEdited();
} else { } else {
editView.showFileLoadeddError(result); editView.showFileLoadeddError(result);
} }
}
}; };
fileLoader.run(); fileLoader.run();
} }
@ -62,6 +64,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
editView.setMarkdown(getMarkdown()); editView.setMarkdown(getMarkdown());
onMarkdownEdited(); onMarkdownEdited();
} else { } else {
if (editView != null)
editView.showFileLoadeddError(result); editView.showFileLoadeddError(result);
} }
}; };
@ -99,11 +102,13 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
Runnable fileSaver = () -> { Runnable fileSaver = () -> {
int code; int code;
code = file.save(filePath); code = file.save(filePath);
if (editView != null) {
if (code == MarkdownFile.SUCCESS) { if (code == MarkdownFile.SUCCESS) {
editView.showFileSavedMessage(); editView.showFileSavedMessage();
} else { } else {
editView.showFileSavedError(code); editView.showFileSavedError(code);
} }
}
}; };
fileSaver.run(); fileSaver.run();
} }
@ -173,6 +178,7 @@ public class MarkdownPresenterImpl implements MarkdownPresenter {
} }
loadMarkdown(in); loadMarkdown(in);
} catch (Exception e) { } catch (Exception e) {
if (editView != null)
editView.showFileLoadeddError(MarkdownFile.READ_ERROR); editView.showFileLoadeddError(MarkdownFile.READ_ERROR);
} }
} }