Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
30294782cb | ||
![]() |
e6b283e243 | ||
![]() |
c20f1520ab | ||
![]() |
b30a1e10a8 | ||
![]() |
08507c8a92 |
@ -1,5 +1,6 @@
|
||||
# https://docs.travis-ci.com/user/languages/android/
|
||||
language: android
|
||||
dist: trusty
|
||||
jdk: openjdk8
|
||||
sudo: false
|
||||
|
||||
|
@ -6,7 +6,7 @@ org.gradle.configureondemand=true
|
||||
android.enableBuildCache=true
|
||||
android.buildCacheDir=build/pre-dex-cache
|
||||
|
||||
VERSION_NAME=3.0.1
|
||||
VERSION_NAME=3.0.2
|
||||
|
||||
GROUP=ru.noties.markwon
|
||||
POM_DESCRIPTION=Markwon markdown for Android
|
||||
|
@ -80,12 +80,8 @@ public class JLatexMathPlugin extends AbstractMarkwonPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String makeDestination(@NonNull String latex) {
|
||||
return SCHEME + "://" + latex;
|
||||
}
|
||||
|
||||
private static final String SCHEME = "jlatexmath";
|
||||
private static final String SCHEME_START = SCHEME + "://";
|
||||
private static final String CONTENT_TYPE = "text/jlatexmath";
|
||||
|
||||
private final Config config;
|
||||
@ -112,9 +108,11 @@ public class JLatexMathPlugin extends AbstractMarkwonPlugin {
|
||||
|
||||
final RenderProps renderProps = visitor.renderProps();
|
||||
|
||||
ImageProps.DESTINATION.set(renderProps, makeDestination(latex));
|
||||
ImageProps.DESTINATION.set(renderProps, SCHEME_START + latex);
|
||||
ImageProps.REPLACEMENT_TEXT_IS_LINK.set(renderProps, false);
|
||||
ImageProps.IMAGE_SIZE.set(renderProps, new ImageSize(new ImageSize.Dimension(100, "%"), null));
|
||||
ImageProps.IMAGE_SIZE.set(
|
||||
renderProps,
|
||||
new ImageSize(new ImageSize.Dimension(100, "%"), null));
|
||||
|
||||
visitor.setSpansForNode(Image.class, length);
|
||||
}
|
||||
@ -132,7 +130,7 @@ public class JLatexMathPlugin extends AbstractMarkwonPlugin {
|
||||
ImageItem item = null;
|
||||
|
||||
try {
|
||||
final byte[] bytes = raw.substring(SCHEME.length()).getBytes("UTF-8");
|
||||
final byte[] bytes = raw.substring(SCHEME_START.length()).getBytes("UTF-8");
|
||||
item = new ImageItem(
|
||||
CONTENT_TYPE,
|
||||
new ByteArrayInputStream(bytes));
|
||||
|
@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.OkHttpClient;
|
||||
import ru.noties.markwon.AbstractMarkwonPlugin;
|
||||
import ru.noties.markwon.image.AsyncDrawableLoader;
|
||||
@ -28,20 +29,25 @@ public class OkHttpImagesPlugin extends AbstractMarkwonPlugin {
|
||||
|
||||
@NonNull
|
||||
public static OkHttpImagesPlugin create(@NonNull OkHttpClient okHttpClient) {
|
||||
return new OkHttpImagesPlugin(okHttpClient);
|
||||
return create((Call.Factory) okHttpClient);
|
||||
}
|
||||
|
||||
private final OkHttpClient client;
|
||||
@NonNull
|
||||
public static OkHttpImagesPlugin create(@NonNull Call.Factory callFactory) {
|
||||
return new OkHttpImagesPlugin(callFactory);
|
||||
}
|
||||
|
||||
OkHttpImagesPlugin(@NonNull OkHttpClient client) {
|
||||
this.client = client;
|
||||
private final Call.Factory callFactory;
|
||||
|
||||
OkHttpImagesPlugin(@NonNull Call.Factory callFactory) {
|
||||
this.callFactory = callFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureImages(@NonNull AsyncDrawableLoader.Builder builder) {
|
||||
builder.addSchemeHandler(
|
||||
Arrays.asList(NetworkSchemeHandler.SCHEME_HTTP, NetworkSchemeHandler.SCHEME_HTTPS),
|
||||
new OkHttpSchemeHandler(client)
|
||||
new OkHttpSchemeHandler(callFactory)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,9 @@ package ru.noties.markwon.image.okhttp;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
@ -18,10 +16,10 @@ class OkHttpSchemeHandler extends SchemeHandler {
|
||||
|
||||
private static final String HEADER_CONTENT_TYPE = "Content-Type";
|
||||
|
||||
private final OkHttpClient client;
|
||||
private final Call.Factory callFactory;
|
||||
|
||||
OkHttpSchemeHandler(@NonNull OkHttpClient client) {
|
||||
this.client = client;
|
||||
OkHttpSchemeHandler(@NonNull Call.Factory callFactory) {
|
||||
this.callFactory = callFactory;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -36,7 +34,7 @@ class OkHttpSchemeHandler extends SchemeHandler {
|
||||
|
||||
Response response = null;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
response = callFactory.newCall(request).execute();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user