Try a more heavy handed approach to get plugin ids for history changes.

This commit is contained in:
Koen J 2025-05-07 13:26:31 +02:00
commit 18102a2a73
3 changed files with 19 additions and 22 deletions

View file

@ -74,7 +74,7 @@ class HistoryFragment : MainFragment() {
private var _pager: IPager<HistoryVideo>? = null; private var _pager: IPager<HistoryVideo>? = null;
private val _results = arrayListOf<HistoryVideo>(); private val _results = arrayListOf<HistoryVideo>();
private var _loading = false; private var _loading = false;
//private val _toggleBar: ToggleBar private val _toggleBar: ToggleBar
private var _togglePluginsDisabled = hashSetOf<String>() private var _togglePluginsDisabled = hashSetOf<String>()
private var _automaticNextPageCounter = 0; private var _automaticNextPageCounter = 0;
@ -87,7 +87,7 @@ class HistoryFragment : MainFragment() {
_clearSearch = findViewById(R.id.button_clear_search); _clearSearch = findViewById(R.id.button_clear_search);
_editSearch = findViewById(R.id.edit_search); _editSearch = findViewById(R.id.edit_search);
_tagsView = findViewById(R.id.tags_text); _tagsView = findViewById(R.id.tags_text);
//_toggleBar = findViewById(R.id.toggle_bar) _toggleBar = findViewById(R.id.toggle_bar)
_tagsView.setPairs(listOf( _tagsView.setPairs(listOf(
Pair(context.getString(R.string.last_hour), 60L), Pair(context.getString(R.string.last_hour), 60L),
Pair(context.getString(R.string.last_24_hours), 24L * 60L), Pair(context.getString(R.string.last_24_hours), 24L * 60L),
@ -97,21 +97,21 @@ class HistoryFragment : MainFragment() {
Pair(context.getString(R.string.all_time), -1L) Pair(context.getString(R.string.all_time), -1L)
)); ));
/*val toggles = StatePlatform.instance.getEnabledClients() val toggles = StatePlatform.instance.getEnabledClients()
.filter { it is JSClient } .filter { it is JSClient }
.map { plugin -> .map { plugin ->
val pluginName = plugin.name.lowercase() val pluginName = plugin.name.lowercase()
ToggleBar.Toggle(if(Settings.instance.home.showHomeFiltersPluginNames) pluginName else "", plugin.icon, !_togglePluginsDisabled.contains(pluginName), { view, active -> ToggleBar.Toggle(if(Settings.instance.home.showHomeFiltersPluginNames) pluginName else "", plugin.icon, !_togglePluginsDisabled.contains(plugin.id), { view, active ->
if (active) { if (active) {
_togglePluginsDisabled.remove(pluginName) _togglePluginsDisabled.remove(plugin.id)
} else { } else {
_togglePluginsDisabled.add(pluginName) _togglePluginsDisabled.add(plugin.id)
} }
filtersChanged() filtersChanged()
}).withTag("plugins") }).withTag("plugins")
}.toTypedArray() }.toTypedArray()
_toggleBar.setToggles(*toggles)*/ _toggleBar.setToggles(*toggles)
_adapter = InsertedViewAdapterWithLoader(context, arrayListOf(), arrayListOf(), _adapter = InsertedViewAdapterWithLoader(context, arrayListOf(), arrayListOf(),
{ _results.size }, { _results.size },
@ -277,18 +277,14 @@ class HistoryFragment : MainFragment() {
} }
private fun filterResults(a: List<HistoryVideo>): List<HistoryVideo> { private fun filterResults(a: List<HistoryVideo>): List<HistoryVideo> {
return a val enabledPluginIds = StatePlatform.instance.getEnabledClients().map { it.id }.toHashSet()
val disabledPluginIds = _togglePluginsDisabled.toHashSet()
/*
//TODO: Not an ideal way to do this, plugin id would be better but it is null for HistoryVideo ?
val enabledPluginNames = StatePlatform.instance.getEnabledClients().map { it.name.lowercase() }.toHashSet()
val disabledPluginNames = _togglePluginsDisabled.toHashSet()
return a.filter { return a.filter {
val pluginName = it.video.id.platform.lowercase() val pluginId = it.video.id.pluginId ?: StatePlatform.instance.getContentClientOrNull(it.video.url)?.id ?: return@filter true
if (!enabledPluginNames.contains(pluginName)) if (!enabledPluginIds.contains(pluginId))
return@filter false return@filter false
return@filter !disabledPluginNames.contains(pluginName) return@filter !disabledPluginIds.contains(pluginId)
};*/ };
} }
private fun loadPagerInternal(pager: IPager<HistoryVideo>) { private fun loadPagerInternal(pager: IPager<HistoryVideo>) {

View file

@ -14,6 +14,7 @@ import com.futo.platformplayer.R
import com.futo.platformplayer.constructs.Event1 import com.futo.platformplayer.constructs.Event1
import com.futo.platformplayer.images.GlideHelper.Companion.crossfade import com.futo.platformplayer.images.GlideHelper.Companion.crossfade
import com.futo.platformplayer.models.HistoryVideo import com.futo.platformplayer.models.HistoryVideo
import com.futo.platformplayer.states.StatePlatform
import com.futo.platformplayer.toHumanNumber import com.futo.platformplayer.toHumanNumber
import com.futo.platformplayer.toHumanTime import com.futo.platformplayer.toHumanTime
import com.futo.platformplayer.views.others.ProgressBar import com.futo.platformplayer.views.others.ProgressBar
@ -75,7 +76,9 @@ class HistoryListViewHolder : ViewHolder {
_textName.text = v.video.name; _textName.text = v.video.name;
_textAuthor.text = v.video.author.name; _textAuthor.text = v.video.author.name;
_textVideoDuration.text = v.video.duration.toHumanTime(false); _textVideoDuration.text = v.video.duration.toHumanTime(false);
_thumbnailPlatform.setPlatformFromClientName(v.video.id.platform)
val pluginId = v.video.id.pluginId ?: StatePlatform.instance.getContentClientOrNull(v.video.url)?.id
_thumbnailPlatform.setPlatformFromClientID(pluginId)
if(v.video.isLive) { if(v.video.isLive) {
_containerDuration.visibility = View.GONE; _containerDuration.visibility = View.GONE;

View file

@ -107,14 +107,12 @@
android:textColor="@color/white" android:textColor="@color/white"
android:paddingStart="5dp" android:paddingStart="5dp"
android:paddingTop="15dp" android:paddingTop="15dp"
android:paddingBottom="8dp" android:paddingBottom="8dp" />
android:visibility="gone" />
<com.futo.platformplayer.views.ToggleBar <com.futo.platformplayer.views.ToggleBar
android:id="@+id/toggle_bar" android:id="@+id/toggle_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
android:visibility="gone" />
</LinearLayout> </LinearLayout>
</androidx.appcompat.widget.Toolbar> </androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>