Skip to content

Commit

Permalink
add network image handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Dec 5, 2023
1 parent 3e790e4 commit 1f850d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
import io.noties.markwon.html.HtmlPlugin;
import io.noties.markwon.image.ImagesPlugin;
import io.noties.markwon.image.file.FileSchemeHandler;
import io.noties.markwon.image.gif.GifMediaDecoder;
import io.noties.markwon.image.network.NetworkSchemeHandler;
import io.noties.markwon.image.svg.SvgMediaDecoder;
import io.noties.markwon.image.network.OkHttpNetworkSchemeHandler;
import io.noties.markwon.movement.MovementMethodPlugin;
import io.realm.Realm;
import io.realm.RealmResults;
Expand All @@ -65,18 +64,13 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
.usePlugin(HtmlPlugin.create())
.usePlugin(ImagesPlugin.create())
.usePlugin(MovementMethodPlugin.none())
// .usePlugin(ImagesPlugin.create(plugin -> {
// plugin.addMediaDecoder(SvgMediaDecoder.create());
// }))
// .usePlugin(ImagesPlugin.create(plugin -> {
// plugin.addMediaDecoder(GifMediaDecoder.create());
// }))
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configure(@NonNull MarkwonPlugin.Registry registry) {
registry.require(ImagesPlugin.class, imagesPlugin -> {
imagesPlugin.addSchemeHandler(FileSchemeHandler.create());
imagesPlugin.addSchemeHandler(NetworkSchemeHandler.create());
imagesPlugin.addSchemeHandler(OkHttpNetworkSchemeHandler.create());
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import io.noties.markwon.image.ImagesPlugin;
import io.noties.markwon.image.file.FileSchemeHandler;
import io.noties.markwon.image.network.NetworkSchemeHandler;
import io.noties.markwon.image.network.OkHttpNetworkSchemeHandler;
import io.noties.markwon.movement.MovementMethodPlugin;
import io.realm.Case;
import io.realm.Realm;
Expand Down Expand Up @@ -84,6 +85,7 @@ public void configure(@NonNull MarkwonPlugin.Registry registry) {
registry.require(ImagesPlugin.class, imagesPlugin -> {
imagesPlugin.addSchemeHandler(FileSchemeHandler.create());
imagesPlugin.addSchemeHandler(NetworkSchemeHandler.create());
imagesPlugin.addSchemeHandler(OkHttpNetworkSchemeHandler.create());
}
);
}
Expand Down Expand Up @@ -235,7 +237,7 @@ public static String prependBaseUrlToImages(String markdownContent, String baseU
String relativePath = matcher.group(1);
String modifiedPath = relativePath.replaceFirst("resources/", "");
String fullUrl = baseUrl + modifiedPath;
matcher.appendReplacement(result, "<img src=" + fullUrl + " width=400 height=250/>");
matcher.appendReplacement(result, "<img src=" + fullUrl + " width=600 height=350/>");
}
matcher.appendTail(result);

Expand Down

0 comments on commit 1f850d2

Please sign in to comment.