-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated A{I to Support New Release Format - Updated dependencies - Minor Bug Fixes
- Loading branch information
Showing
21 changed files
with
168 additions
and
93 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/src/main/java/info/horriblesubs/sher/data/subsplease/api/model/ItemReleasePage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package info.horriblesubs.sher.data.subsplease.api.model | ||
|
||
data class ItemReleasePage( | ||
var episode: LinkedHashMap<String, ItemRelease>? = null, | ||
var batch: LinkedHashMap<String, ItemRelease>? = null | ||
) |
64 changes: 64 additions & 0 deletions
64
app/src/main/java/info/horriblesubs/sher/libs/preference/prefs/AppCachePreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package info.horriblesubs.sher.libs.preference.prefs | ||
|
||
import info.horriblesubs.sher.App | ||
import info.horriblesubs.sher.libs.preference.model.BasePreference | ||
import java.io.File | ||
|
||
object AppCachePreference: BasePreference<String>() { | ||
|
||
override val key: String get() = "app_cache" | ||
override val type: Int get() = DEFAULT | ||
override val defaultValue = "0" | ||
override var value = "0" | ||
get() { | ||
var size = 0F | ||
size += getDirSize(App.get().externalCacheDir) | ||
size += getDirSize(App.get().cacheDir) | ||
val float = ((size /1024)/1024) | ||
return "$float" | ||
} | ||
|
||
init { | ||
summaryProvider = object : TextProvider<String> { | ||
override fun provideText(preference: BasePreference<String>): String = | ||
"Tap to clear ${(preference as AppCachePreference).value}MB of application cache." | ||
} | ||
title = "Reset Application Cache" | ||
} | ||
|
||
private fun getDirSize(dir: File?): Float { | ||
var size = 0F | ||
dir?.listFiles()?.forEach { | ||
size += if (it != null && it.isDirectory) getDirSize(it) | ||
else if (it != null && it.isFile) it.length().toFloat() | ||
else 0F | ||
} | ||
return size | ||
} | ||
|
||
fun deleteCache() = try { | ||
deleteDir(App.get().externalCacheDir) | ||
deleteDir(App.get().cacheDir) | ||
true | ||
} catch (e: Exception) { | ||
e.printStackTrace() | ||
false | ||
} | ||
|
||
private fun deleteDir(dir: File?) { | ||
when { | ||
dir?.isDirectory == true -> { | ||
(dir.list() ?: arrayOf()).forEach { | ||
deleteDir(File(dir, it)) | ||
} | ||
dir.delete() | ||
} | ||
dir?.isFile == true -> dir.delete() | ||
} | ||
} | ||
|
||
|
||
override fun migrate() { | ||
deleteCache() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.