mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-29 22:24:29 +02:00
Add search type selector to suggestions fragment.
This commit is contained in:
parent
63761cfc9a
commit
daa91986ef
@ -18,6 +18,8 @@ import com.futo.platformplayer.states.StatePlatform
|
|||||||
import com.futo.platformplayer.stores.FragmentedStorage
|
import com.futo.platformplayer.stores.FragmentedStorage
|
||||||
import com.futo.platformplayer.stores.SearchHistoryStorage
|
import com.futo.platformplayer.stores.SearchHistoryStorage
|
||||||
import com.futo.platformplayer.views.adapters.SearchSuggestionAdapter
|
import com.futo.platformplayer.views.adapters.SearchSuggestionAdapter
|
||||||
|
import com.futo.platformplayer.views.others.RadioGroupView
|
||||||
|
import com.futo.platformplayer.views.others.TagsView
|
||||||
|
|
||||||
data class SuggestionsFragmentData(val query: String, val searchType: SearchType, val channelUrl: String? = null);
|
data class SuggestionsFragmentData(val query: String, val searchType: SearchType, val channelUrl: String? = null);
|
||||||
|
|
||||||
@ -28,6 +30,7 @@ class SuggestionsFragment : MainFragment {
|
|||||||
|
|
||||||
private var _recyclerSuggestions: RecyclerView? = null;
|
private var _recyclerSuggestions: RecyclerView? = null;
|
||||||
private var _llmSuggestions: LinearLayoutManager? = null;
|
private var _llmSuggestions: LinearLayoutManager? = null;
|
||||||
|
private var _radioGroupView: RadioGroupView? = null;
|
||||||
private val _suggestions: ArrayList<String> = ArrayList();
|
private val _suggestions: ArrayList<String> = ArrayList();
|
||||||
private var _query: String? = null;
|
private var _query: String? = null;
|
||||||
private var _searchType: SearchType = SearchType.VIDEO;
|
private var _searchType: SearchType = SearchType.VIDEO;
|
||||||
@ -73,6 +76,15 @@ class SuggestionsFragment : MainFragment {
|
|||||||
recyclerSuggestions.adapter = _adapterSuggestions;
|
recyclerSuggestions.adapter = _adapterSuggestions;
|
||||||
_recyclerSuggestions = recyclerSuggestions;
|
_recyclerSuggestions = recyclerSuggestions;
|
||||||
|
|
||||||
|
_radioGroupView = view.findViewById<RadioGroupView>(R.id.radio_group).apply {
|
||||||
|
onSelectedChange.subscribe {
|
||||||
|
if (it.size != 1)
|
||||||
|
_searchType = SearchType.VIDEO
|
||||||
|
else
|
||||||
|
_searchType = (it[0] ?: SearchType.VIDEO) as SearchType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadSuggestions();
|
loadSuggestions();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -103,31 +115,27 @@ class SuggestionsFragment : MainFragment {
|
|||||||
_channelUrl = null;
|
_channelUrl = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_radioGroupView?.setOptions(listOf(Pair("Media", SearchType.VIDEO), Pair("Creators", SearchType.CREATOR), Pair("Playlists", SearchType.PLAYLIST)), listOf(_searchType), false, true)
|
||||||
|
|
||||||
topBar?.apply {
|
topBar?.apply {
|
||||||
if (this is SearchTopBarFragment) {
|
if (this is SearchTopBarFragment) {
|
||||||
onSearch.subscribe(this) {
|
onSearch.subscribe(this) {
|
||||||
if (_searchType == SearchType.CREATOR) {
|
if(it.isHttpUrl()) {
|
||||||
navigate<CreatorSearchResultsFragment>(it);
|
if(StatePlatform.instance.hasEnabledPlaylistClient(it))
|
||||||
} else if (_searchType == SearchType.PLAYLIST) {
|
navigate<RemotePlaylistFragment>(it);
|
||||||
navigate<PlaylistSearchResultsFragment>(it);
|
else if(StatePlatform.instance.hasEnabledChannelClient(it))
|
||||||
} else {
|
navigate<ChannelFragment>(it);
|
||||||
if(it.isHttpUrl()) {
|
else {
|
||||||
if(StatePlatform.instance.hasEnabledPlaylistClient(it))
|
val url = it;
|
||||||
navigate<RemotePlaylistFragment>(it);
|
activity?.let {
|
||||||
else if(StatePlatform.instance.hasEnabledChannelClient(it))
|
close()
|
||||||
navigate<ChannelFragment>(it);
|
if(it is MainActivity)
|
||||||
else {
|
it.navigate(it.getFragment<VideoDetailFragment>(), url);
|
||||||
val url = it;
|
|
||||||
activity?.let {
|
|
||||||
close()
|
|
||||||
if(it is MainActivity)
|
|
||||||
it.navigate(it.getFragment<VideoDetailFragment>(), url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
navigate<ContentSearchResultsFragment>(SuggestionsFragmentData(it, SearchType.VIDEO, _channelUrl));
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
navigate<ContentSearchResultsFragment>(SuggestionsFragmentData(it, _searchType, _channelUrl));
|
||||||
};
|
};
|
||||||
|
|
||||||
onTextChange.subscribe(this) {
|
onTextChange.subscribe(this) {
|
||||||
@ -189,6 +197,7 @@ class SuggestionsFragment : MainFragment {
|
|||||||
super.onDestroyMainView();
|
super.onDestroyMainView();
|
||||||
_getSuggestions.onError.clear();
|
_getSuggestions.onError.clear();
|
||||||
_recyclerSuggestions = null;
|
_recyclerSuggestions = null;
|
||||||
|
_radioGroupView = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
@ -1,14 +1,58 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
tools:context=".fragment.mainactivity.main.SuggestionsFragment">
|
tools:context=".fragment.mainactivity.main.SuggestionsFragment">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/app_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
app:elevation="0dp">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="0dp"
|
||||||
|
app:layout_scrollFlags="scroll"
|
||||||
|
app:contentInsetStart="0dp"
|
||||||
|
app:contentInsetEnd="0dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/container_toolbar_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<com.futo.platformplayer.views.announcements.AnnouncementView
|
||||||
|
android:id="@+id/announcement_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<com.futo.platformplayer.views.others.RadioGroupView
|
||||||
|
android:id="@+id/radio_group"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/list_suggestions"
|
android:id="@+id/list_suggestions"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
</FrameLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
x
Reference in New Issue
Block a user