ImagesPlugin print a warning for SVG and GIF instead of full stacktrace
This commit is contained in:
parent
fa01a50ae8
commit
1b7fbfb77f
@ -11,7 +11,6 @@ import java.io.InputStream;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import io.noties.markwon.image.DrawableUtils;
|
|
||||||
import io.noties.markwon.image.MediaDecoder;
|
import io.noties.markwon.image.MediaDecoder;
|
||||||
import pl.droidsonroids.gif.GifDrawable;
|
import pl.droidsonroids.gif.GifDrawable;
|
||||||
|
|
||||||
@ -97,9 +96,7 @@ public class GifMediaDecoder extends MediaDecoder {
|
|||||||
|
|
||||||
private static void validate() {
|
private static void validate() {
|
||||||
if (!GifSupport.hasGifSupport()) {
|
if (!GifSupport.hasGifSupport()) {
|
||||||
throw new IllegalStateException("`pl.droidsonroids.gif:android-gif-drawable:*` " +
|
throw new IllegalStateException(GifSupport.missingMessage());
|
||||||
"dependency is missing, please add to your project explicitly if you " +
|
|
||||||
"wish to use GIF media decoder");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package io.noties.markwon.image.gif;
|
package io.noties.markwon.image.gif;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
@ -13,8 +17,9 @@ public abstract class GifSupport {
|
|||||||
pl.droidsonroids.gif.GifDrawable.class.getName();
|
pl.droidsonroids.gif.GifDrawable.class.getName();
|
||||||
result = true;
|
result = true;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// @since 4.1.1-SNAPSHOT do not print stacktrace (it can become noisy)
|
// @since 4.1.1-SNAPSHOT instead of printing full stacktrace of the exception,
|
||||||
// t.printStackTrace();
|
// just print a warning to the console
|
||||||
|
Log.w("MarkwonImagesPlugin", missingMessage());
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
HAS_GIF = result;
|
HAS_GIF = result;
|
||||||
@ -24,6 +29,16 @@ public abstract class GifSupport {
|
|||||||
return HAS_GIF;
|
return HAS_GIF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.1.1-SNAPSHOT
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
static String missingMessage() {
|
||||||
|
return "`pl.droidsonroids.gif:android-gif-drawable:*` " +
|
||||||
|
"dependency is missing, please add to your project explicitly if you " +
|
||||||
|
"wish to use GIF media-decoder";
|
||||||
|
}
|
||||||
|
|
||||||
private GifSupport() {
|
private GifSupport() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,7 @@ public class SvgMediaDecoder extends MediaDecoder {
|
|||||||
|
|
||||||
private static void validate() {
|
private static void validate() {
|
||||||
if (!SvgSupport.hasSvgSupport()) {
|
if (!SvgSupport.hasSvgSupport()) {
|
||||||
throw new IllegalStateException("`com.caverock:androidsvg:*` dependency is missing, " +
|
throw new IllegalStateException(SvgSupport.missingMessage());
|
||||||
"please add to your project explicitly if you wish to use SVG media decoder");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package io.noties.markwon.image.svg;
|
package io.noties.markwon.image.svg;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
@ -13,8 +17,9 @@ public abstract class SvgSupport {
|
|||||||
com.caverock.androidsvg.SVG.class.getName();
|
com.caverock.androidsvg.SVG.class.getName();
|
||||||
result = true;
|
result = true;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// @since 4.1.1-SNAPSHOT do not print stacktrace (it can become noisy)
|
// @since 4.1.1-SNAPSHOT instead of printing full stacktrace of the exception,
|
||||||
// t.printStackTrace();
|
// just print a warning to the console
|
||||||
|
Log.w("MarkwonImagesPlugin", missingMessage());
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
HAS_SVG = result;
|
HAS_SVG = result;
|
||||||
@ -24,6 +29,15 @@ public abstract class SvgSupport {
|
|||||||
return HAS_SVG;
|
return HAS_SVG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.1.1-SNAPSHOT
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
static String missingMessage() {
|
||||||
|
return "`com.caverock:androidsvg:*` dependency is missing, " +
|
||||||
|
"please add to your project explicitly if you wish to use SVG media-decoder";
|
||||||
|
}
|
||||||
|
|
||||||
private SvgSupport() {
|
private SvgSupport() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user