diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/model/Readability.java b/app/src/main/java/com/wbrawner/simplemarkdown/model/Readability.java deleted file mode 100644 index 53d6ca3..0000000 --- a/app/src/main/java/com/wbrawner/simplemarkdown/model/Readability.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.wbrawner.simplemarkdown.model; - -import java.util.ArrayList; -import java.util.List; - -public class Readability { - private String content; - private static final String DELIMS = ".!?\n"; - - public Readability(String content) { - this.content = content; - } - - public List sentences() { - - ArrayList list = new ArrayList<>(); - - int startOfSentance = 0; - StringBuilder lineBuilder = new StringBuilder(); - for (int i = 0; i < content.length(); i++) { - String c = content.charAt(i) + ""; - if (DELIMS.contains(c)) { - list.add(new Sentence(content, startOfSentance, i)); - startOfSentance = i + 1; - lineBuilder = new StringBuilder(); - } else { - lineBuilder.append(c); - } - } - String line = lineBuilder.toString(); - if (!line.isEmpty()) list.add(new Sentence(content, startOfSentance, content.length())); - - return list; - } -} diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/model/Readability.kt b/app/src/main/java/com/wbrawner/simplemarkdown/model/Readability.kt new file mode 100644 index 0000000..aad2bee --- /dev/null +++ b/app/src/main/java/com/wbrawner/simplemarkdown/model/Readability.kt @@ -0,0 +1,29 @@ +package com.wbrawner.simplemarkdown.model + +import java.util.* + +class Readability(private val content: String) { + + fun sentences(): List { + val list = ArrayList() + var startOfSentance = 0 + var lineBuilder = StringBuilder() + for (i in 0 until content.length) { + val c = content[i] + "" + if (DELIMS.contains(c)) { + list.add(Sentence(content, startOfSentance, i)) + startOfSentance = i + 1 + lineBuilder = StringBuilder() + } else { + lineBuilder.append(c) + } + } + val line = lineBuilder.toString() + if (line.isNotEmpty()) list.add(Sentence(content, startOfSentance, content.length)) + return list + } + + companion object { + private const val DELIMS = ".!?\n" + } +}