From 99717ef1f17f18a53c5fb9d65033a7796ffe6f52 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Sat, 2 Oct 2021 19:10:50 +0200 Subject: [PATCH] fixed langs hopefully --- .../com/lagradost/cloudstream3/MainAPI.kt | 11 +++++-- .../cloudstream3/ui/search/SearchFragment.kt | 29 +++---------------- .../ui/settings/SettingsFragment.kt | 2 ++ 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index 585cc86d..d115ca1a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -76,14 +76,14 @@ object APIHolder { val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) val hashSet = HashSet() - hashSet.addAll(apis.map { it.name }) + val activeLangs = getApiProviderLangSettings() + hashSet.addAll(apis.filter { activeLangs.contains(it.lang) }.map { it.name }) val set = settingsManager.getStringSet( this.getString(R.string.search_providers_list_key), hashSet )?.toHashSet() ?: hashSet - val activeLangs = getApiProviderLangSettings() val list = HashSet() for (name in set) { val api = getApiFromNameNull(name) ?: continue @@ -361,6 +361,7 @@ interface LoadResponse { val tags: List? val duration: String? val trailerUrl: String? + val recommendations: List? } fun LoadResponse?.isEpisodeBased(): Boolean { @@ -396,7 +397,8 @@ data class TorrentLoadResponse( override val rating: Int? = null, override val tags: List? = null, override val duration: String? = null, - override val trailerUrl: String? = null + override val trailerUrl: String? = null, + override val recommendations: List? = null, ) : LoadResponse data class AnimeLoadResponse( @@ -423,6 +425,7 @@ data class AnimeLoadResponse( override val rating: Int? = null, override val duration: String? = null, override val trailerUrl: String? = null, + override val recommendations: List? = null, ) : LoadResponse data class MovieLoadResponse( @@ -441,6 +444,7 @@ data class MovieLoadResponse( override val tags: List? = null, override val duration: String? = null, override val trailerUrl: String? = null, + override val recommendations: List? = null, ) : LoadResponse data class TvSeriesEpisode( @@ -471,4 +475,5 @@ data class TvSeriesLoadResponse( override val tags: List? = null, override val duration: String? = null, override val trailerUrl: String? = null, + override val recommendations: List? = null, ) : LoadResponse 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 fdc2608a..a20bc163 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 @@ -1,13 +1,11 @@ package com.lagradost.cloudstream3.ui.search -import android.content.Context import android.content.res.Configuration import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.WindowManager -import android.view.inputmethod.InputMethodManager import android.widget.* import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.SearchView @@ -19,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView import com.google.android.material.switchmaterial.SwitchMaterial import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.APIHolder.apis +import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings import com.lagradost.cloudstream3.APIHolder.getApiSettings import com.lagradost.cloudstream3.APIHolder.getApiTypeSettings import com.lagradost.cloudstream3.mvvm.Resource @@ -115,8 +114,9 @@ class SearchFragment : Fragment() { searchMagIcon.scaleY = 0.65f search_filter.setOnClickListener { searchView -> val apiNamesSetting = activity?.getApiSettings() - if (apiNamesSetting != null) { - val apiNames = apis.map { it.name } + val langs = activity?.getApiProviderLangSettings() + if (apiNamesSetting != null && langs != null) { + val apiNames = apis.filter { langs.contains(it.lang) }.map { it.name } val builder = AlertDialog.Builder(searchView.context, R.style.AlertDialogCustom).setView(R.layout.provider_list) @@ -150,25 +150,6 @@ class SearchFragment : Fragment() { listView2.adapter = arrayAdapter2 listView2.choiceMode = AbsListView.CHOICE_MODE_MULTIPLE - - /*fun updateMulti() { - val set = HashSet() - - for ((index, api) in apis.withIndex()) { - if (listView?.checkedItemPositions[index]) { - set.addAll(api.supportedTypes) - } - } - - if (set.size == 0) { - set.addAll(TvType.values()) - } - - for ((index, choice) in typeChoices.withIndex()) { - listView2?.setItemChecked(index, choice.second.any { set.contains(it) }) - } - }*/ - for ((index, item) in apiNames.withIndex()) { listView.setItemChecked(index, apiNamesSetting.contains(item)) } @@ -227,8 +208,6 @@ class SearchFragment : Fragment() { isSupported ) } - - //updateMulti() } dialog.setOnDismissListener { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt index 223de62b..89525ce7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt @@ -9,6 +9,7 @@ import androidx.preference.PreferenceManager import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings +import com.lagradost.cloudstream3.APIHolder.getApiSettings import com.lagradost.cloudstream3.APIHolder.restrictedApis import com.lagradost.cloudstream3.DubStatus import com.lagradost.cloudstream3.MainActivity.Companion.setLocale @@ -128,6 +129,7 @@ class SettingsFragment : PreferenceFragmentCompat() { this.getString(R.string.provider_lang_key), selectedList.map { names[it].first }.toMutableSet() ).apply() + APIRepository.providersActive = it.context.getApiSettings() } }