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