mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fix nsfw visibility (#1162)
This commit is contained in:
parent
ad27eb3b0e
commit
1a05651510
2 changed files with 12 additions and 4 deletions
|
@ -12,6 +12,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.lagradost.cloudstream3.AcraApplication.Companion.getActivity
|
||||
import com.lagradost.cloudstream3.PROVIDER_STATUS_DOWN
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.TvType
|
||||
import com.lagradost.cloudstream3.databinding.RepositoryItemBinding
|
||||
import com.lagradost.cloudstream3.plugins.PluginManager
|
||||
import com.lagradost.cloudstream3.plugins.VotingApi.getVotes
|
||||
|
@ -150,7 +151,7 @@ class PluginAdapter(
|
|||
R.drawable.ic_baseline_delete_outline_24
|
||||
else R.drawable.netflix_download
|
||||
|
||||
binding.nsfwMarker.isVisible = metadata.tvTypes?.contains("NSFW") ?: false
|
||||
binding.nsfwMarker.isVisible = metadata.tvTypes?.contains(TvType.NSFW.name) ?: false
|
||||
binding.actionButton.setImageResource(drawableInt)
|
||||
|
||||
binding.actionButton.setOnClickListener {
|
||||
|
|
|
@ -8,10 +8,12 @@ import androidx.lifecycle.LiveData
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||
import com.lagradost.cloudstream3.MainAPI.Companion.settingsForProvider
|
||||
import com.lagradost.cloudstream3.PROVIDER_STATUS_DOWN
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.TvType
|
||||
import com.lagradost.cloudstream3.amap
|
||||
import com.lagradost.cloudstream3.mvvm.launchSafe
|
||||
import com.lagradost.cloudstream3.plugins.PluginManager
|
||||
|
@ -97,6 +99,7 @@ class PluginsViewModel : ViewModel() {
|
|||
R.string.batch_download_nothing_to_download_format,
|
||||
txt(R.string.plugin)
|
||||
)
|
||||
|
||||
else -> txt(
|
||||
R.string.batch_download_start_format,
|
||||
list.size,
|
||||
|
@ -182,10 +185,14 @@ class PluginsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
private suspend fun updatePluginListPrivate(context: Context, repositoryUrl: String) {
|
||||
val isAdult = settingsForProvider.enableAdult
|
||||
val isAdult = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getStringSet(context.getString(R.string.prefer_media_type_key), emptySet())
|
||||
?.contains(TvType.NSFW.ordinal.toString()) == true
|
||||
|
||||
val plugins = getPlugins(repositoryUrl)
|
||||
val list = plugins.filter {
|
||||
return@filter !(it.second.tvTypes?.contains("NSFW") == true && !isAdult)
|
||||
// Show all non-nsfw plugins or all if nsfw is enabled
|
||||
it.second.tvTypes?.contains(TvType.NSFW.name) != true || isAdult
|
||||
}.map { plugin ->
|
||||
PluginViewData(plugin, isDownloaded(context, plugin.second.internalName, plugin.first))
|
||||
}
|
||||
|
@ -201,7 +208,7 @@ class PluginsViewModel : ViewModel() {
|
|||
if (tvTypes.isEmpty()) return this
|
||||
return this.filter {
|
||||
(it.plugin.second.tvTypes?.any { type -> tvTypes.contains(type) } == true) ||
|
||||
(tvTypes.contains("Others") && (it.plugin.second.tvTypes
|
||||
(tvTypes.contains(TvType.Others.name) && (it.plugin.second.tvTypes
|
||||
?: emptyList()).isEmpty())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue