Fix JLatexMathPlugin (backgroundProvider null)
This commit is contained in:
parent
24151dff7d
commit
c68aeabcf9
@ -6,6 +6,7 @@ import android.os.Handler;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -262,12 +263,28 @@ public class JLatexMathPlugin extends AbstractMarkwonPlugin {
|
|||||||
cache.put(drawable, config.executorService.submit(new Runnable() {
|
cache.put(drawable, config.executorService.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
// @since 4.0.1 wrap in try-catch block and add error logging
|
||||||
|
try {
|
||||||
|
execute();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
Log.e(
|
||||||
|
"JLatexMathPlugin",
|
||||||
|
"Error displaying latex: `" + drawable.getDestination() + "`",
|
||||||
|
t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void execute() {
|
||||||
|
|
||||||
|
// @since 4.0.1 (background provider can be null)
|
||||||
|
final BackgroundProvider backgroundProvider = config.backgroundProvider;
|
||||||
|
|
||||||
// create JLatexMathDrawable
|
// create JLatexMathDrawable
|
||||||
|
//noinspection ConstantConditions
|
||||||
final JLatexMathDrawable jLatexMathDrawable =
|
final JLatexMathDrawable jLatexMathDrawable =
|
||||||
JLatexMathDrawable.builder(drawable.getDestination())
|
JLatexMathDrawable.builder(drawable.getDestination())
|
||||||
.textSize(config.textSize)
|
.textSize(config.textSize)
|
||||||
.background(config.backgroundProvider.provide())
|
.background(backgroundProvider != null ? backgroundProvider.provide() : null)
|
||||||
.align(config.align)
|
.align(config.align)
|
||||||
.fitCanvas(config.fitCanvas)
|
.fitCanvas(config.fitCanvas)
|
||||||
.padding(
|
.padding(
|
||||||
|
@ -47,24 +47,24 @@ public class LatexActivity extends Activity {
|
|||||||
+ latex + "$$\n\n something like **this**";
|
+ latex + "$$\n\n something like **this**";
|
||||||
|
|
||||||
final Markwon markwon = Markwon.builder(this)
|
final Markwon markwon = Markwon.builder(this)
|
||||||
// .usePlugin(ImagesPlugin.create(this))
|
// .usePlugin(JLatexMathPlugin.create(textView.getTextSize(), new JLatexMathPlugin.BuilderConfigure() {
|
||||||
.usePlugin(JLatexMathPlugin.create(textView.getTextSize(), new JLatexMathPlugin.BuilderConfigure() {
|
// @Override
|
||||||
@Override
|
// public void configureBuilder(@NonNull JLatexMathPlugin.Builder builder) {
|
||||||
public void configureBuilder(@NonNull JLatexMathPlugin.Builder builder) {
|
// builder
|
||||||
builder
|
// .backgroundProvider(new JLatexMathPlugin.BackgroundProvider() {
|
||||||
.backgroundProvider(new JLatexMathPlugin.BackgroundProvider() {
|
// @NonNull
|
||||||
@NonNull
|
// @Override
|
||||||
@Override
|
// public Drawable provide() {
|
||||||
public Drawable provide() {
|
// return new ColorDrawable(0x40ff0000);
|
||||||
return new ColorDrawable(0x40ff0000);
|
// }
|
||||||
}
|
// })
|
||||||
})
|
// .fitCanvas(true)
|
||||||
.fitCanvas(true)
|
// .align(JLatexMathDrawable.ALIGN_LEFT)
|
||||||
.align(JLatexMathDrawable.ALIGN_LEFT)
|
// .padding(48)
|
||||||
.padding(48)
|
// ;
|
||||||
;
|
// }
|
||||||
}
|
// }))
|
||||||
}))
|
.usePlugin(JLatexMathPlugin.create(textView.getTextSize()))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user