Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
fix: After clearing the cache, it will cause java.lang.Error: java.io…
Browse files Browse the repository at this point in the history
….IOException.
  • Loading branch information
painld6 committed Mar 2, 2021
1 parent 51ba8e5 commit f37d604
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
package com.example.ponycui_home.svgaplayer;

import android.app.Activity;
import android.content.Intent;
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.style.ForegroundColorSpan;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -23,27 +14,10 @@
import android.widget.ListView;
import android.widget.TextView;

import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGADynamicEntity;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAPlayer;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.opensource.svgaplayer.utils.log.SVGALogger;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

class SampleItem {

Expand All @@ -68,6 +42,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
this.setupData();
this.setupListView();
this.setupSVGAParser();
this.setupLogger();
setContentView(listView);
}

Expand Down Expand Up @@ -156,9 +131,13 @@ public boolean isEmpty() {
});
this.listView.setBackgroundColor(Color.WHITE);
}

void setupSVGAParser() {
SVGAParser.Companion.shareParser().init(this);
}

private void setupLogger() {
SVGALogger.INSTANCE.setLogEnabled(true);
}

}
9 changes: 9 additions & 0 deletions library/src/main/java/com/opensource/svgaplayer/SVGACache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ object SVGACache {

private var type: Type = Type.DEFAULT
private var cacheDir: String = "/"
get() {
if (field != "/") {
val dir = File(field)
if (!dir.exists()) {
dir.mkdirs()
}
}
return field
}

fun onCreate(context: Context?) {
onCreate(context, Type.DEFAULT)
Expand Down

0 comments on commit f37d604

Please sign in to comment.