diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownViewModel.java b/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownViewModel.java deleted file mode 100644 index 3cf17fa..0000000 --- a/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownViewModel.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.wbrawner.simplemarkdown; - -public class MarkdownViewModel { -/* - private static final String TAG = MarkdownViewModel.class.getSimpleName(); - private File file; - public MutableLiveData markdownLiveData; - private MutableLiveData htmlLiveData = new MutableLiveData<>();; - - public MarkdownViewModel() { - markdownLiveData = new MutableLiveData<>(); - } - - public void updateMarkdown(String data) { - if (markdownLiveData == null) - markdownLiveData = new MutableLiveData<>(); - markdownLiveData.postValue(data); - Runnable generateMarkdown = () -> { - AndDown andDown = new AndDown(); - int hoedownFlags = - AndDown.HOEDOWN_EXT_STRIKETHROUGH | AndDown.HOEDOWN_EXT_TABLES | - AndDown.HOEDOWN_EXT_UNDERLINE | AndDown.HOEDOWN_EXT_SUPERSCRIPT | - AndDown.HOEDOWN_EXT_FENCED_CODE; - htmlLiveData.postValue(andDown.markdownToHtml(markdownLiveData.getValue(), hoedownFlags, 0)); - }; - if (markdownLiveData.getValue() != null) - generateMarkdown.run(); - } - - public LiveData getHtml() { - return htmlLiveData; - } - - public void openFile(String filePath) { - file = new File(filePath); - } - - public String getFileName() { - if (file == null || file.getName().isEmpty()) - return "Untitled.md"; - return file.getName(); - } - - public boolean saveFile(String filePath, @Nullable String fileName) { - if (fileName == null) { - if (file != null) - fileName = file.getName(); - else - fileName = "Untitled.md"; - } - if (!filePath.endsWith("/")) - filePath += "/"; - final boolean result; - new AsyncTask() { - @Override - protected Void doInBackground(String... strings) { - try { - PrintWriter writer = new PrintWriter(strings[0], "UTF-8"); - writer.write(markdownLiveData.getValue()); - } catch (IOException e) { - Log.e(TAG, "Error saving file: ", e); - } - return null; - } - }.execute(filePath + fileName); - return true; - } - - public void requestSave(String s) { - // Do something to save the file? - } - - public String getMarkdown() { - return markdownLiveData.getValue(); - } */ -}