From 60bcbf0060750f661f5ae53f197b29b71eae365c Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Sat, 5 Nov 2022 19:54:04 +0100 Subject: [PATCH] A lil cache fixing & search fixes --- app/build.gradle.kts | 6 +++--- .../main/java/com/lagradost/cloudstream3/CommonActivity.kt | 2 ++ .../com/lagradost/cloudstream3/ui/search/SearchFragment.kt | 6 +++--- .../ui/settings/extensions/ExtensionsFragment.kt | 4 +++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4a1fcada..f72eb321 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -47,8 +47,8 @@ android { minSdk = 21 targetSdk = 30 - versionCode = 54 - versionName = "3.2.2" + versionCode = 55 + versionName = "3.2.3" resValue("string", "app_version", "${defaultConfig.versionName}${versionNameSuffix ?: ""}") @@ -190,7 +190,7 @@ dependencies { // Networking // implementation("com.squareup.okhttp3:okhttp:4.9.2") // implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.1") - implementation("com.github.Blatzar:NiceHttp:0.3.4") + implementation("com.github.Blatzar:NiceHttp:0.3.5") // Util to skip the URI file fuckery 🙏 implementation("com.github.tachiyomiorg:unifile:17bec43") diff --git a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt index af04a1a2..342dc6f7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt @@ -61,6 +61,7 @@ object CommonActivity { } } + @MainThread fun showToast(act: Activity?, @StringRes message: Int, duration: Int) { if (act == null) return showToast(act, act.getString(message), duration) @@ -69,6 +70,7 @@ object CommonActivity { const val TAG = "COMPACT" /** duration is Toast.LENGTH_SHORT if null*/ + @MainThread fun showToast(act: Activity?, message: String?, duration: Int? = null) { if (act == null || message == null) { Log.w(TAG, "invalid showToast act = $act message = $message") diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt index e6e290c1..4da88af7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt @@ -131,9 +131,9 @@ class SearchFragment : Fragment() { context?.let { ctx -> val default = enumValues().sorted().filter { it != TvType.NSFW } .map { it.ordinal.toString() }.toSet() - val preferredTypes = PreferenceManager.getDefaultSharedPreferences(ctx) - .getStringSet(this.getString(R.string.prefer_media_type_key), default) - ?.mapNotNull { it.toIntOrNull() ?: return@mapNotNull null } ?: default + val preferredTypes = (PreferenceManager.getDefaultSharedPreferences(ctx) + .getStringSet(this.getString(R.string.prefer_media_type_key), default)?.ifEmpty { default } ?: default) + .mapNotNull { it.toIntOrNull() ?: return@mapNotNull null } val settings = ctx.getApiSettings() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt index 49f40879..fbf10499 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt @@ -200,7 +200,9 @@ class ExtensionsFragment : Fragment() { val url = dialog.repo_url_input?.text?.toString() ?.let { it1 -> RepositoryManager.parseRepoUrl(it1) } if (url.isNullOrBlank()) { - showToast(activity, R.string.error_invalid_data, Toast.LENGTH_SHORT) + main { + showToast(activity, R.string.error_invalid_data, Toast.LENGTH_SHORT) + } } else { val fixedName = if (!name.isNullOrBlank()) name else RepositoryManager.parseRepository(url)?.name ?: "No name"