|
|
|
@ -8,10 +8,10 @@ import android.graphics.Canvas |
|
|
|
|
import android.graphics.PixelFormat |
|
|
|
|
import android.graphics.drawable.BitmapDrawable |
|
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
|
import android.util.Log |
|
|
|
|
import org.json.JSONArray |
|
|
|
|
import org.json.JSONObject |
|
|
|
|
import splitties.init.appCtx |
|
|
|
|
import timber.log.Timber |
|
|
|
|
import java.io.* |
|
|
|
|
import java.util.* |
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger |
|
|
|
@ -70,11 +70,11 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
init { |
|
|
|
|
try { |
|
|
|
|
if (!cacheDir.exists() && !cacheDir.mkdirs()) { |
|
|
|
|
Log.i("ACache", "can't make dirs in %s" + cacheDir.absolutePath) |
|
|
|
|
Timber.i("can't make dirs in %s" + cacheDir.absolutePath) |
|
|
|
|
} |
|
|
|
|
mCache = ACacheManager(cacheDir, max_size, max_count) |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -96,7 +96,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
file.writeText(value) |
|
|
|
|
mCache.put(file) |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -131,7 +131,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
removeFile = true |
|
|
|
|
} |
|
|
|
|
} catch (e: IOException) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} finally { |
|
|
|
|
if (removeFile) |
|
|
|
|
remove(key) |
|
|
|
@ -269,7 +269,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
null |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} finally { |
|
|
|
|
if (removeFile) |
|
|
|
|
remove(key) |
|
|
|
@ -299,7 +299,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -318,18 +318,18 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
ois = ObjectInputStream(bis) |
|
|
|
|
return ois.readObject() |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} finally { |
|
|
|
|
try { |
|
|
|
|
bis?.close() |
|
|
|
|
} catch (e: IOException) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
ois?.close() |
|
|
|
|
} catch (e: IOException) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -427,7 +427,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
return f |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return null |
|
|
|
@ -488,7 +488,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false |
|
|
|
@ -662,7 +662,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
cacheCount.set(count) |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -693,7 +693,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
file.setLastModified(currentTime) |
|
|
|
|
lastUsageDates[file] = currentTime |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -727,7 +727,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -767,7 +767,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
|
} |
|
|
|
|
return fileSize |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printOnDebug() |
|
|
|
|
Timber.e(e) |
|
|
|
|
return 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|