diff --git a/app-sample/src/main/java/io/noties/markwon/app/samples/editor/EditorHeadingSample.java b/app-sample/src/main/java/io/noties/markwon/app/samples/editor/EditorHeadingSample.java index 915343f5..492d6a80 100644 --- a/app-sample/src/main/java/io/noties/markwon/app/samples/editor/EditorHeadingSample.java +++ b/app-sample/src/main/java/io/noties/markwon/app/samples/editor/EditorHeadingSample.java @@ -5,7 +5,7 @@ import java.util.concurrent.Executors; import io.noties.markwon.Markwon; import io.noties.markwon.app.sample.Tags; import io.noties.markwon.app.samples.editor.shared.MarkwonEditTextSample; -import io.noties.markwon.app.samples.editor.shared.HeadingEditHandler; +import io.noties.markwon.editor.handler.HeadingEditHandler; import io.noties.markwon.editor.MarkwonEditor; import io.noties.markwon.editor.MarkwonEditorTextWatcher; import io.noties.markwon.sample.annotations.MarkwonArtifact; diff --git a/app-sample/src/main/java/io/noties/markwon/app/samples/editor/WYSIWYGEditorSample.java b/app-sample/src/main/java/io/noties/markwon/app/samples/editor/WYSIWYGEditorSample.java index 01f916d8..0c36c870 100644 --- a/app-sample/src/main/java/io/noties/markwon/app/samples/editor/WYSIWYGEditorSample.java +++ b/app-sample/src/main/java/io/noties/markwon/app/samples/editor/WYSIWYGEditorSample.java @@ -15,7 +15,6 @@ import io.noties.markwon.SoftBreakAddsNewLinePlugin; import io.noties.markwon.app.sample.Tags; import io.noties.markwon.app.samples.editor.shared.BlockQuoteEditHandler; import io.noties.markwon.app.samples.editor.shared.CodeEditHandler; -import io.noties.markwon.app.samples.editor.shared.HeadingEditHandler; import io.noties.markwon.app.samples.editor.shared.LinkEditHandler; import io.noties.markwon.app.samples.editor.shared.MarkwonEditTextSample; import io.noties.markwon.app.samples.editor.shared.StrikethroughEditHandler; @@ -23,6 +22,7 @@ import io.noties.markwon.editor.MarkwonEditor; import io.noties.markwon.editor.MarkwonEditorTextWatcher; import io.noties.markwon.editor.PersistedSpans; import io.noties.markwon.editor.handler.EmphasisEditHandler; +import io.noties.markwon.editor.handler.HeadingEditHandler; import io.noties.markwon.editor.handler.StrongEmphasisEditHandler; import io.noties.markwon.sample.annotations.MarkwonArtifact; import io.noties.markwon.sample.annotations.MarkwonSampleInfo; diff --git a/markwon-editor/build.gradle b/markwon-editor/build.gradle index 884f6fb6..393759ba 100644 --- a/markwon-editor/build.gradle +++ b/markwon-editor/build.gradle @@ -11,6 +11,11 @@ android { versionCode 1 versionName version } + + compileOptions { + targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 + } } dependencies { diff --git a/markwon-editor/src/main/java/io/noties/markwon/editor/handler/HeadingEditHandler.java b/markwon-editor/src/main/java/io/noties/markwon/editor/handler/HeadingEditHandler.java index 70652bbc..ce4b5b25 100644 --- a/markwon-editor/src/main/java/io/noties/markwon/editor/handler/HeadingEditHandler.java +++ b/markwon-editor/src/main/java/io/noties/markwon/editor/handler/HeadingEditHandler.java @@ -1,4 +1,4 @@ -package it.niedermann.android.markdown.markwon.handler; +package io.noties.markwon.editor.handler; import android.text.Editable; import android.text.Spanned; @@ -13,7 +13,6 @@ import io.noties.markwon.editor.PersistedSpans; public class HeadingEditHandler implements EditHandler { - private MarkwonTheme theme; @Override @@ -23,12 +22,12 @@ public class HeadingEditHandler implements EditHandler { @Override public void configurePersistedSpans(@NonNull PersistedSpans.Builder builder) { - builder.persistSpan(Heading1Span.class, new Runnable() { new Heading1Span(theme);}); - builder.persistSpan(Heading2Span.class, new Runnable() { new Heading2Span(theme);}); - builder.persistSpan(Heading3Span.class, new Runnable() { new Heading3Span(theme);}); - builder.persistSpan(Heading4Span.class, new Runnable() { new Heading4Span(theme);}); - builder.persistSpan(Heading5Span.class, new Runnable() { new Heading5Span(theme);}); - builder.persistSpan(Heading6Span.class, new Runnable() { new Heading6Span(theme);}); + builder.persistSpan(Heading1Span.class, () -> new Heading1Span(theme)); + builder.persistSpan(Heading2Span.class, () -> new Heading2Span(theme)); + builder.persistSpan(Heading3Span.class, () -> new Heading3Span(theme)); + builder.persistSpan(Heading4Span.class, () -> new Heading4Span(theme)); + builder.persistSpan(Heading5Span.class, () -> new Heading5Span(theme)); + builder.persistSpan(Heading6Span.class, () -> new Heading6Span(theme)); } @Override @@ -39,7 +38,7 @@ public class HeadingEditHandler implements EditHandler { @NonNull HeadingSpan span, int spanStart, int spanTextLength) { - HeadingSpan newSpan; + final HeadingSpan newSpan; switch (span.getLevel()) { case 1: @@ -64,8 +63,8 @@ public class HeadingEditHandler implements EditHandler { return; } - int newStart = getNewSpanStart(input, spanStart); - int newEnd = findEnd(input, newStart, newSpan.getLevel()); + final int newStart = getNewSpanStart(input, spanStart); + final int newEnd = findEnd(input, newStart, newSpan.getLevel()); editable.setSpan( newSpan, @@ -77,24 +76,24 @@ public class HeadingEditHandler implements EditHandler { private int findEnd(String input, int searchFrom, int spanLevel) { int end = searchFrom + spanLevel; - int strLength = input.length(); - while (end < strLength-1) { + final int strLength = input.length(); + while (end < strLength - 1) { end++; if (input.charAt(end) == '\n') { break; } } - return end+1; + return end + 1; } private int getNewSpanStart(String input, int spanStart) { - int start = spanStart; while (start >= 0 && input.charAt(start) != '\n') { start--; } start += 1; + return start; }